From 2bb250d135a473f2a1dbf3640a782f0af0498d4b Mon Sep 17 00:00:00 2001 From: kimura Date: Wed, 27 Oct 2021 09:55:09 +0900 Subject: [PATCH] =?UTF-8?q?=E3=81=8A=E5=AE=A2=E3=81=95=E3=82=93=E8=A1=8C?= =?UTF-8?q?=E5=8B=95=E3=83=91=E3=82=BF=E3=83=BC=E3=83=B3CenterStop?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../marketing/Scripts/CustomerController.cs | 46 ++++++++++++++----- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs index 8afb7349..7cc2a450 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs @@ -22,6 +22,7 @@ public enum CustomerState { Walk, WalkShop, + CenterStop, Wait, Order, Leave, @@ -33,7 +34,6 @@ public class CustomerController : MonoBehaviour { public int OrderCount; public CustomerAnimator CustomerPrefab; - public bool IsCustomer; public bool IsPause; // 歩道の幅(min,max) @@ -94,13 +94,15 @@ public class CustomerController : MonoBehaviour purchased.AddTo(this); durationDelta = 0f; - Observable.Interval(TimeSpan.FromSeconds(.1f)).Subscribe(_ => - { - // if (Vector3.Distance(transform.localPosition, wayPoint) < .09f) - // { - // Debug.Log($"{transform.localPosition}, {wayPoint}, {currentMovingType.Value}, {moveEndSubject.Value} {GetHashCode()}"); - // } - }).AddTo(this); +#if UNITY_EDITOR + // Observable.Interval(TimeSpan.FromSeconds(.1f)).Subscribe(_ => + // { + // if (Vector3.Distance(transform.localPosition, wayPoint) < .09f) + // { + // Debug.Log($"{transform.localPosition}, {wayPoint}, {currentMovingType.Value}, {moveEndSubject.Value} {GetHashCode()}"); + // } + // }).AddTo(this); +#endif this.UpdateAsObservable().Subscribe(_ => { if (IsPause) @@ -136,11 +138,26 @@ public class CustomerController : MonoBehaviour public void Setup(List newOrderPositions) { - orderPositions = newOrderPositions; walkSideDirection = Mathf.Sign(Random.value - .5f); - beginPos = Vector3.zero; - beginPos.x = leftEndPosision * walkSideDirection; - beginPos.y = Random.Range(walkSideMidPos, walkSideBottomPos); + var pos = Vector3.zero; + pos.x = leftEndPosision * walkSideDirection; + pos.y = Random.Range(walkSideMidPos, walkSideBottomPos); + Setup(newOrderPositions, pos); + } + + public void SetupCenter(List newOrderPositions) + { + walkSideDirection = Mathf.Sign(Random.value - .5f); + var pos = Vector3.zero; + pos.x = Random.Range(-stopPositionRange, stopPositionRange) + stopPosision; + pos.y = Random.Range(walkSideMidPos, walkSideBottomPos); + Setup(newOrderPositions, pos); + } + + private void Setup(List newOrderPositions, Vector2 position) + { + orderPositions = newOrderPositions; + beginPos = position; transform.localPosition = beginPos; currentMovingType.Value = CustomerMovingType.StayBack; moveEndSubject.Value = CustomerMovingType.StayBack; @@ -163,6 +180,11 @@ public class CustomerController : MonoBehaviour case CustomerState.WalkShop: ForceSetMove(CustomerMovingType.WalkCenter); break; + case CustomerState.CenterStop: + // 中央付近で立ち止まる + ForceSetMove(CustomerMovingType.WalkCenter); + AddMove(CustomerMovingType.StayBack); + break; case CustomerState.Wait: // 店に向かう&順番待ち // 近くの場合その場に待機