From 49936617ba277dd42e8f16d7307a5e99291a5251 Mon Sep 17 00:00:00 2001 From: kimura Date: Mon, 6 Sep 2021 11:54:01 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=E3=83=8F=E3=83=BC=E3=83=88=E3=83=91?= =?UTF-8?q?=E3=83=BC=E3=83=86=E3=82=A3=E3=82=AF=E3=83=AB=E3=81=AE=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/marketing/Prefabs/Customer.prefab | 45 ++++++++++++++----- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Customer.prefab b/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Customer.prefab index bf20e423..fa8e4795 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Customer.prefab +++ b/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Customer.prefab @@ -1,5 +1,16 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!210 &1027147620336589506 +SortingGroup: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5409985849609444268} + m_Enabled: 1 + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 23 --- !u!1 &5409985849651702440 GameObject: m_ObjectHideFlags: 0 @@ -80,6 +91,17 @@ MonoBehaviour: bigHeart: {fileID: 7988005957398545984} smallHeart: {fileID: 992423202615605163} target: {fileID: 0} +--- !u!210 &3225622249943924906 +SortingGroup: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5409985851148247169} + m_Enabled: 1 + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 23 --- !u!61 &3337152902562194938 BoxCollider2D: m_ObjectHideFlags: 0 @@ -106,17 +128,6 @@ BoxCollider2D: serializedVersion: 2 m_Size: {x: 2, y: 2} m_EdgeRadius: 0 ---- !u!210 &7449452199590198578 -SortingGroup: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5409985851491668855} - m_Enabled: 1 - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 23 --- !u!1001 &631677504613307640 PrefabInstance: m_ObjectHideFlags: 0 @@ -234,12 +245,24 @@ Animator: type: 3} m_PrefabInstance: {fileID: 631677504613307640} m_PrefabAsset: {fileID: 0} +--- !u!1 &5409985849609444268 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 4886416730379292500, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + m_PrefabInstance: {fileID: 631677504613307640} + m_PrefabAsset: {fileID: 0} --- !u!212 &1950136324089803489 stripped SpriteRenderer: m_CorrespondingSourceObject: {fileID: 1428887861354145305, guid: db654393793a67d45a7d0b70a68b73a6, type: 3} m_PrefabInstance: {fileID: 631677504613307640} m_PrefabAsset: {fileID: 0} +--- !u!1 &5409985851148247169 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 4886416728696845433, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + m_PrefabInstance: {fileID: 631677504613307640} + m_PrefabAsset: {fileID: 0} --- !u!212 &1950136324150437342 stripped SpriteRenderer: m_CorrespondingSourceObject: {fileID: 1428887861146841382, guid: db654393793a67d45a7d0b70a68b73a6, From d3f8f5064d681b28ff2ef9e8f6aa24e0574246c0 Mon Sep 17 00:00:00 2001 From: kimura Date: Wed, 8 Sep 2021 12:29:27 +0900 Subject: [PATCH 2/5] =?UTF-8?q?=E3=83=8F=E3=83=BC=E3=83=88=E3=81=AETarget?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E6=96=B9=E6=B3=95=E3=82=92=E5=A4=89=E6=9B=B4?= =?UTF-8?q?=20=E3=81=8A=E5=AE=A2=E3=81=95=E3=82=93=E3=81=AE=E5=90=91?= =?UTF-8?q?=E3=81=8D=E3=81=AE=E3=81=BF=E5=8F=8D=E8=BB=A2=E3=81=95=E3=81=9B?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resources/Avatars/customer_normal.prefab | 16 +++++++++++++ .../Scenes/marketing/Prefabs/Customer.prefab | 24 ++++++++++++++++++- .../marketing/Scripts/CustomerController.cs | 11 +++++++-- .../marketing/Scripts/CustomerDirection.cs | 24 +++++++++++++++++++ .../Scripts/CustomerDirection.cs.meta | 3 +++ .../marketing/Scripts/HeartAnimation.cs | 8 ++++++- .../MyGame/Scenes/marketing/Scripts/Market.cs | 1 + 7 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerDirection.cs create mode 100644 popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerDirection.cs.meta diff --git a/popcorn/Assets/MyGame/Resources/Avatars/customer_normal.prefab b/popcorn/Assets/MyGame/Resources/Avatars/customer_normal.prefab index 800e50a6..7fa9dfe7 100644 --- a/popcorn/Assets/MyGame/Resources/Avatars/customer_normal.prefab +++ b/popcorn/Assets/MyGame/Resources/Avatars/customer_normal.prefab @@ -5301,6 +5301,7 @@ GameObject: m_Component: - component: {fileID: 4886416728471897984} - component: {fileID: 4886416728471897985} + - component: {fileID: 5450916343452979085} m_Layer: 0 m_Name: customer_normal m_TagString: Untagged @@ -5346,6 +5347,21 @@ Animator: m_HasTransformHierarchy: 1 m_AllowConstantClipSamplingOptimization: 1 m_KeepAnimatorControllerStateOnDisable: 0 +--- !u!114 &5450916343452979085 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4886416728471897999} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0eb44b30c9454383898faae0c3666b94, type: 3} + m_Name: + m_EditorClassIdentifier: + bodySides: + - {fileID: 4886416730379292501} + - {fileID: 4886416728696845434} --- !u!1 &4886416728477582529 GameObject: m_ObjectHideFlags: 0 diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Customer.prefab b/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Customer.prefab index fa8e4795..909143db 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Customer.prefab +++ b/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Customer.prefab @@ -57,6 +57,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: animator: {fileID: 5409985851491668857} + customerDirection: {fileID: 4855338754077236085} orderPopup: {fileID: 5409985850085678672} leftPopcorn: {fileID: 1950136324582499262} rightPopcorn: {fileID: 1950136324150437342} @@ -90,7 +91,6 @@ MonoBehaviour: m_EditorClassIdentifier: bigHeart: {fileID: 7988005957398545984} smallHeart: {fileID: 992423202615605163} - target: {fileID: 0} --- !u!210 &3225622249943924906 SortingGroup: m_ObjectHideFlags: 0 @@ -215,6 +215,16 @@ PrefabInstance: propertyPath: m_IsActive value: 0 objectReference: {fileID: 0} + - target: {fileID: 6511433195714067906, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7358655632798716600, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} - target: {fileID: 8422870931014696725, guid: db654393793a67d45a7d0b70a68b73a6, type: 3} propertyPath: m_IsActive @@ -245,6 +255,18 @@ Animator: type: 3} m_PrefabInstance: {fileID: 631677504613307640} m_PrefabAsset: {fileID: 0} +--- !u!114 &4855338754077236085 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 5450916343452979085, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + m_PrefabInstance: {fileID: 631677504613307640} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5409985851491668855} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0eb44b30c9454383898faae0c3666b94, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &5409985849609444268 stripped GameObject: m_CorrespondingSourceObject: {fileID: 4886416730379292500, guid: db654393793a67d45a7d0b70a68b73a6, diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs index 4bd949d0..419829b0 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs @@ -37,6 +37,7 @@ public class CustomerController : MonoBehaviour private static readonly int WalkSideEat = Animator.StringToHash("WalkSideEat"); [SerializeField] private Animator animator; + [SerializeField] private CustomerDirection customerDirection; [SerializeField] private GameObject orderPopup; [SerializeField] private SpriteRenderer leftPopcorn; @@ -250,8 +251,14 @@ public class CustomerController : MonoBehaviour private void SetWayPoint(Vector3 point) { wayPoint = point; - wayPoint.z = wayPoint.y + Mathf.Abs(walkSideBottomPos); - transform.localRotation = Quaternion.Euler((wayPoint - transform.localPosition).x >= 0 ? Vector3.zero : Vector3.up * 180); + if ((wayPoint - transform.localPosition).x >= 0) + { + customerDirection.SetDefaultSide(); + } + else + { + customerDirection.SetFlipSide(); + } } public void ShowWantFlavor(int flavor) diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerDirection.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerDirection.cs new file mode 100644 index 00000000..efefb2c5 --- /dev/null +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerDirection.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +public class CustomerDirection : MonoBehaviour +{ + [SerializeField] private List bodySides = new List(); + + public void SetDefaultSide() + { + foreach (var bodySide in bodySides) + { + bodySide.localRotation = Quaternion.Euler(Vector3.zero); + } + } + + public void SetFlipSide() + { + foreach (var bodySide in bodySides) + { + bodySide.localRotation = Quaternion.Euler(Vector3.up * 180); + } + } +} diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerDirection.cs.meta b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerDirection.cs.meta new file mode 100644 index 00000000..b854fc5a --- /dev/null +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerDirection.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0eb44b30c9454383898faae0c3666b94 +timeCreated: 1631070899 \ No newline at end of file diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/HeartAnimation.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/HeartAnimation.cs index 0d8a3a7d..a74ac88d 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/HeartAnimation.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/HeartAnimation.cs @@ -5,10 +5,16 @@ public class HeartAnimation : MonoBehaviour { [SerializeField] private GameObject bigHeart; [SerializeField] private GameObject smallHeart; - [SerializeField] private Transform target; + private Transform target; private float animationDelay = .3f; private float animationDuration = .5f; private float heartToMeterDuration = .4f; + + public void SetTarget(Transform transform) + { + target = transform; + } + public void GetHeart(Action callback = null) { smallHeart.SetActive(false); diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs index e3b232ad..f43b4aa0 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs @@ -246,6 +246,7 @@ public class Market : MonoBehaviour { customerController.HideOrderPopup(); var heartAnimation = customerController.GetComponent(); + heartAnimation.SetTarget(HeartMeter.Instance.transform); heartAnimation.GetHeart(() => { HeartMeter.Instance.AddHeart(1); From cdbb2113ed316f9b42c5b796810dfc33910f4f64 Mon Sep 17 00:00:00 2001 From: kimura Date: Wed, 8 Sep 2021 12:33:19 +0900 Subject: [PATCH 3/5] =?UTF-8?q?=E3=81=8A=E5=AE=A2=E3=81=95=E3=82=93?= =?UTF-8?q?=E3=81=AE=E9=87=8D=E3=81=AA=E3=82=8A=E8=A7=A3=E6=B1=BA=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E3=82=92=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyGame/Scenes/marketing/Scripts/CustomerController.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs index 419829b0..3cb386ec 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs @@ -85,8 +85,11 @@ public class CustomerController : MonoBehaviour durationDelta = 0f; this.UpdateAsObservable().Subscribe(_ => { - transform.localPosition = Vector3.MoveTowards(transform.localPosition, wayPoint, speed * Time.deltaTime); - if (Vector3.Distance(transform.localPosition, wayPoint) < .01f) + var localPosition = transform.localPosition; + localPosition = Vector2.MoveTowards(localPosition, wayPoint, speed * Time.deltaTime); + localPosition = localPosition + Vector3.forward * (localPosition.y + Mathf.Abs(walkSideBottomPos)); + transform.localPosition = localPosition; + if (Vector2.Distance(localPosition, wayPoint) < .01f) { if (durationDelta < completedDuration) { From aeae4ad8f62d54b35501b506c62406c44ecf4fc4 Mon Sep 17 00:00:00 2001 From: kimura Date: Wed, 8 Sep 2021 12:34:59 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E5=87=A6=E7=90=86?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyGame/Scenes/marketing/Scripts/Market.cs | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs index f43b4aa0..cc1df082 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs @@ -422,24 +422,6 @@ public class Market : MonoBehaviour .OrderBy(_ => Random.value).ToList(); } - private void RefillOneProduct() - { - foreach (var tank in GameDataManager.GameData.StorageTanks) - { - if (tank.Stock == 0) - { - continue; - } - if (GameDataManager.GameData.ShopStock.Count == ShopStockCount) - { - break; - } - GameDataManager.GameData.ShopStock.Add(tank.FlavorId); - tank.Stock--; - } - GameDataManager.SaveGameData(); - } - private void RefillProduct() { // 手前のタンクから出し多分stockをへらす @@ -488,10 +470,4 @@ public class Market : MonoBehaviour } Debug.Log(shopStockString); } - - // Update is called once per frame - void Update() - { - - } } From 99f11ac6dc4052f18ccbe26ce1a7e0dc4ebbcb06 Mon Sep 17 00:00:00 2001 From: kimura Date: Wed, 8 Sep 2021 12:37:10 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=E3=82=BF=E3=83=83=E3=83=97=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=9F=E3=82=89=E8=B3=BC=E5=85=A5=E3=81=AB=E5=90=91?= =?UTF-8?q?=E3=81=8B=E3=81=86=E5=87=A6=E7=90=86=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../marketing/Scripts/CustomerController.cs | 56 ++++++++----- .../MyGame/Scenes/marketing/Scripts/Market.cs | 78 +++++++++++-------- 2 files changed, 79 insertions(+), 55 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs index 3cb386ec..a8ce3c31 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs @@ -21,6 +21,7 @@ public enum CustomerMovingType public enum CustomerState { Walk, + WalkShop, Wait, Order, Leave, @@ -68,6 +69,7 @@ public class CustomerController : MonoBehaviour private Vector3 beginPos; private Vector3 wayPoint; private CustomerMovingType currentMovingType; + private bool isMoveOverride; private List<(CustomerMovingType type, float duration)> moves = new List<(CustomerMovingType, float)>(); private float speed = 0f; private float completedDuration; @@ -96,8 +98,12 @@ public class CustomerController : MonoBehaviour durationDelta += Time.deltaTime; return; } - durationDelta = 0f; moveEndSubject.Value = currentMovingType; + if (isMoveOverride) + { + isMoveOverride = false; + return; + } if (moves.Count > 0) { var move = moves[0]; @@ -115,7 +121,9 @@ public class CustomerController : MonoBehaviour beginPos.x = leftEndPosision * walkSideDirection; beginPos.y = Random.Range(walkSideMidPos, walkSideBottomPos); transform.localPosition = beginPos; - currentMovingType = CustomerMovingType.StayBackOrder; + currentMovingType = CustomerMovingType.StayBack; + moveEndSubject.Value = CustomerMovingType.StayBack; + isMoveOverride = false; SetWayPoint(beginPos); } @@ -126,25 +134,19 @@ public class CustomerController : MonoBehaviour switch (state) { case CustomerState.Walk: - SetMove(CustomerMovingType.WalkCenter); + ForceSetMove(CustomerMovingType.WalkCenter); // 数秒立ち止まる AddMove(CustomerMovingType.StayBack, 2f); AddMove(CustomerMovingType.WalkSide); break; + case CustomerState.WalkShop: + ForceSetMove(CustomerMovingType.WalkCenter); + break; case CustomerState.Wait: // 店に向かう&順番待ち // 近くの場合その場に待機 // まだ遠い場合待機場所に移動 - moves.Clear(); - if (currentMovingType == CustomerMovingType.StayBack) - { - SetMove(CustomerMovingType.WalkBackHalf); - } - else - { - SetMove(CustomerMovingType.WalkCenter); - AddMove(CustomerMovingType.WalkBackHalf); - } + ForceSetMove(CustomerMovingType.WalkBackHalf); AddMove(CustomerMovingType.StayBack); break; case CustomerState.Order: @@ -153,8 +155,7 @@ public class CustomerController : MonoBehaviour AddMove(CustomerMovingType.StayBackOrder); break; case CustomerState.Leave: - moves.Clear(); - SetMove(CustomerMovingType.WalkSide); + ForceSetMove(CustomerMovingType.WalkSide); break; case CustomerState.EatingLeave: AddMove(CustomerMovingType.WalkFrontEat); @@ -170,6 +171,13 @@ public class CustomerController : MonoBehaviour moves.Add((type, duration)); } + private void ForceSetMove(CustomerMovingType type, float duration = 0f) + { + moves.Clear(); + isMoveOverride = true; + SetMove(type, duration); + } + // キャラの奥行き描画順のため、y方向に対応したz軸を設定 private void SetMove(CustomerMovingType type, float duration = 0f) { @@ -178,10 +186,11 @@ public class CustomerController : MonoBehaviour return; } completedDuration = duration; + durationDelta = 0f; switch (type) { case CustomerMovingType.WalkSide: - SetWayPoint(new Vector3(-leftEndPosision * walkSideDirection, wayPoint.y)); + SetWayPoint(new Vector3(-leftEndPosision * walkSideDirection, transform.localPosition.y)); speed = walkSideSpeed; // アニメーション違和感回避 if (currentMovingType == CustomerMovingType.WalkCenter) @@ -191,13 +200,11 @@ public class CustomerController : MonoBehaviour animator.SetTrigger(WalkSide); break; case CustomerMovingType.WalkSideEat: - SetWayPoint(new Vector3(-leftEndPosision * walkSideDirection, wayPoint.y)); + SetWayPoint(new Vector3(-leftEndPosision * walkSideDirection, transform.localPosition.y)); speed = walkSideSpeed; animator.SetTrigger(WalkSideEat); break; case CustomerMovingType.WalkCenter: - // 通り過ぎた人はwalkSideDirection基準にするとあるき過ぎるので改善したい - // 立ち止まったあと戻ってしまう場合があるので、中央付近だと戻りがないようにする if (Mathf.Abs(transform.localPosition.x - stopPosision) <= stopPositionRange) { SetWayPoint(new Vector3(transform.localPosition.x, beginPos.y)); @@ -224,18 +231,25 @@ public class CustomerController : MonoBehaviour animator.SetTrigger(StayBack); break; case CustomerMovingType.WalkBack: + // 購入場所に行く SetWayPoint(new Vector3(Random.value * orderPositionRange * walkSideDirection, orderPosision)); speed = walkFrontBackSpeed; animator.SetTrigger(WalkBack); break; case CustomerMovingType.WalkBackHalf: // 待機列に入る - SetWayPoint(new Vector3(wayPoint.x, waitOrderPosision)); + if (Mathf.Abs(transform.localPosition.x - stopPosision) <= stopPositionRange) + { + SetWayPoint(new Vector3(transform.localPosition.x, waitOrderPosision)); + } + else + { + SetWayPoint(new Vector3(stopPosision - Random.value * stopPositionRange * walkSideDirection, waitOrderPosision)); + } speed = walkFrontBackSpeed; animator.SetTrigger(WalkBack); break; case CustomerMovingType.WalkFront: - // 購入場所に行く SetWayPoint(new Vector3(wayPoint.x, Random.Range(walkSideLeavePos, walkSideTopPosition))); speed = walkFrontBackSpeed; animator.SetTrigger(WalkFront); diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs index cc1df082..89bf5b03 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs @@ -115,38 +115,31 @@ public class Market : MonoBehaviour .Select(x => x.Value) .Subscribe(customerController => { - customerController.State.Subscribe(c => - { - if (c == CustomerState.EatingLeave) + customerController.State + .Where(x => x == CustomerState.EatingLeave) + .Subscribe(c => { Debug.Log($"aa order:{customerList.Count(x => x.State.Value == CustomerState.Order)} EatingLeave"); orderSubject.OnNext(default); - } - }).AddTo(customerController); + }).AddTo(customerController); + if (shopState.Value == ShopState.Close) + { + customerController.ChangeCustomerState(CustomerState.Leave); + return; + } // 店に向かう customerController.ChangeCustomerState(CustomerState.Wait); - shopState.Subscribe(x => - { - switch (x) + shopState + .Where(x => x == ShopState.Close) + .Subscribe(x => { - case ShopState.Open: - case ShopState.Busy: - break; - case ShopState.Close: - // 売り切れの場合帰る - if (customerController.State.Value == CustomerState.Order) - { - return; - } - this.CallWaitForSeconds(Random.Range(0f, .4f), () => - { - customerController.ChangeCustomerState(CustomerState.Leave); - }); - break; - default: - throw new ArgumentOutOfRangeException(nameof(x), x, null); - } - }).AddTo(customerController); + // 売り切れの場合帰る + if (customerController.State.Value == CustomerState.Order) + { + return; + } + customerController.ChangeCustomerState(CustomerState.Leave); + }).AddTo(customerController); }).AddTo(this); requestSubject.BatchFrame().Subscribe(customers => @@ -356,6 +349,16 @@ public class Market : MonoBehaviour customerList.Remove(customerController); Destroy(customer); break; + case CustomerMovingType.WalkCenter: + if (shopState.Value == ShopState.Close) + { + customerController.ChangeCustomerState(CustomerState.Leave); + } + if (customerController.State.Value == CustomerState.WalkShop) + { + customerList.Add(customerController); + } + break; case CustomerMovingType.WalkBackHalf: waitCustomerList.Add(customerController); break; @@ -368,20 +371,27 @@ public class Market : MonoBehaviour }).AddTo(customerController); var customerObject = customer.transform.GetChild(0).gameObject; + var eventTrigger = customerObject.AddComponent(); if (x.isCustomer) { - // 購入客リスト追加 - customerList.Add(customerController); - if (customerObject.TryGetComponent(typeof(Collider2D), out var target)) - { - Destroy(target); - } + // 近くまで歩く(タップされたらcustomerList.Add() + customerController.ChangeCustomerState(CustomerState.WalkShop); + eventTrigger.OnPointerClickAsObservable() + .TakeUntil(customerController.MoveEndObservable.Where(type => type == CustomerMovingType.WalkCenter)) + .Take(1) + .Subscribe(_ => + { + customerList.Add(customerController); + if (customerObject.TryGetComponent(typeof(Collider2D), out var target)) + { + Destroy(target); + } + }).AddTo(customerController); } else { - // 歩行者はタップ後購入客 + // 歩行者はタップ後customerList.Add() customerController.ChangeCustomerState(CustomerState.Walk); - var eventTrigger = customerObject.AddComponent(); eventTrigger.OnPointerClickAsObservable().Take(1).Subscribe(_ => { customerList.Add(customerController);