From d2453258637eee70da9a19c975908ad3d6d70147 Mon Sep 17 00:00:00 2001 From: kimura Date: Wed, 25 Aug 2021 13:51:36 +0900 Subject: [PATCH] =?UTF-8?q?=E6=AD=A9=E8=A1=8C=E5=87=A6=E7=90=86=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/marketing/Prefabs/Customer.prefab | 156 ++++++++++++++++++ .../marketing/Prefabs/Customer.prefab.meta | 7 + .../marketing/Scripts/CustomerController.cs | 89 ++++++++++ .../Scripts/CustomerController.cs.meta | 3 + .../MyGame/Scenes/marketing/Scripts/Market.cs | 23 ++- 5 files changed, 273 insertions(+), 5 deletions(-) create mode 100644 popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Customer.prefab create mode 100644 popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Customer.prefab.meta create mode 100644 popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs create mode 100644 popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs.meta diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Customer.prefab b/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Customer.prefab new file mode 100644 index 00000000..d2164424 --- /dev/null +++ b/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Customer.prefab @@ -0,0 +1,156 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &5409985849651702440 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5409985849651702441} + - component: {fileID: 5715829407227760309} + - component: {fileID: 1385243083193661112} + m_Layer: 0 + m_Name: Customer + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5409985849651702441 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5409985849651702440} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: -1.55, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 5409985851491668856} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &5715829407227760309 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5409985849651702440} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3aa8dec9a88540bf93de4c93663335ec, type: 3} + m_Name: + m_EditorClassIdentifier: + walkSideTopPos: -1.55 + walkSideBottomPos: -6.5 + walkSideSpeed: 1.3 + walkFrontSpeed: 1 + animator: {fileID: 5409985851491668857} +--- !u!114 &1385243083193661112 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5409985849651702440} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 786931d1da2c4b1c8ce9519c9b3c32fd, type: 3} + m_Name: + m_EditorClassIdentifier: + animator: {fileID: 0} +--- !u!1001 &631677504613307640 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 5409985849651702441} + m_Modifications: + - target: {fileID: 4886416728471897984, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + propertyPath: m_RootOrder + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4886416728471897984, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4886416728471897984, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4886416728471897984, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4886416728471897984, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4886416728471897984, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4886416728471897984, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4886416728471897984, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4886416728471897984, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4886416728471897984, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4886416728471897984, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4886416728471897999, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + propertyPath: m_Name + value: NormalBody + objectReference: {fileID: 0} + - target: {fileID: 4886416729748261544, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4886416730379292500, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + propertyPath: m_IsActive + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: db654393793a67d45a7d0b70a68b73a6, type: 3} +--- !u!4 &5409985851491668856 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 4886416728471897984, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + m_PrefabInstance: {fileID: 631677504613307640} + m_PrefabAsset: {fileID: 0} +--- !u!95 &5409985851491668857 stripped +Animator: + m_CorrespondingSourceObject: {fileID: 4886416728471897985, guid: db654393793a67d45a7d0b70a68b73a6, + type: 3} + m_PrefabInstance: {fileID: 631677504613307640} + m_PrefabAsset: {fileID: 0} diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Customer.prefab.meta b/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Customer.prefab.meta new file mode 100644 index 00000000..8b35f1e1 --- /dev/null +++ b/popcorn/Assets/MyGame/Scenes/marketing/Prefabs/Customer.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6fbb038c9aae840f2bea57bce30740f7 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs new file mode 100644 index 00000000..b39cb896 --- /dev/null +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs @@ -0,0 +1,89 @@ +using System; +using UniRx; +using UniRx.Triggers; +using UnityEditor.UIElements; +using UnityEngine; +using Random = UnityEngine.Random; + +public enum CustomerMovingType +{ + WalkFront, + WalkSide, + WalkBack, + StayBack, + WalkFrontEat, + WalkSideEat, +} +public class CustomerController : MonoBehaviour +{ + private static readonly int WalkFront = Animator.StringToHash("WalkFront"); + private static readonly int WalkSide = Animator.StringToHash("WalkSide"); + private static readonly int WalkBack = Animator.StringToHash("WalkBack"); + private static readonly int StayBack = Animator.StringToHash("StayBack"); + private static readonly int WalkFrontEat = Animator.StringToHash("WalkFrontEat"); + private static readonly int WalkSideEat = Animator.StringToHash("WalkSideEat"); + + // 画面端 + private float leftEndPosision = -10f; + // 歩道の幅(min,max) + [SerializeField] private float walkSideTopPos = -1.55f; + [SerializeField] private float walkSideBottomPos = -6.50f; + + // 歩行速度 + [SerializeField] private float walkSideSpeed = 1.3f; // 1.3f + [SerializeField] private float walkFrontSpeed = 1.0f; // 1.0f + private Vector3 speed = Vector3.zero; + // 停止時間 + // 左右どちらから出るか + + [SerializeField] private Animator animator; + private void Start() + { + this.UpdateAsObservable().Subscribe(_ => + { + transform.localPosition += speed * Time.deltaTime; + }).AddTo(this); + } + + public void Setup() + { + var tmpPos = Vector3.zero; + tmpPos.x = leftEndPosision; + tmpPos.y = Random.Range(walkSideTopPos, walkSideBottomPos); + transform.localPosition = tmpPos; + } + + public void SetMove(CustomerMovingType type) + { + switch (type) + { + case CustomerMovingType.WalkFront: + animator.SetTrigger(WalkFront); + break; + case CustomerMovingType.WalkSide: + speed = Vector3.right * walkSideSpeed; + animator.SetTrigger(WalkSide); + break; + case CustomerMovingType.WalkBack: + animator.SetTrigger(WalkBack); + break; + case CustomerMovingType.StayBack: + speed = Vector3.zero; + animator.SetTrigger(StayBack); + break; + case CustomerMovingType.WalkFrontEat: + animator.SetTrigger(WalkFrontEat); + break; + case CustomerMovingType.WalkSideEat: + animator.SetTrigger(WalkSideEat); + break; + default: + throw new ArgumentOutOfRangeException(nameof(type), type, null); + } + } + + public void SetCustomerType() + { + + } +} \ No newline at end of file diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs.meta b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs.meta new file mode 100644 index 00000000..0dd99678 --- /dev/null +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3aa8dec9a88540bf93de4c93663335ec +timeCreated: 1629854874 \ No newline at end of file diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs index b0be6fe1..3f9b4ce4 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs @@ -12,26 +12,39 @@ public class Market : MonoBehaviour [SerializeField] private ShopStockView stockView; [SerializeField] private MarketCartView cartView; + [SerializeField] private GameObject customerPrefab; // Start is called before the first frame update void Start() { var gameData = GameDataManager.GameData; CoinManager.Instance.ChangeCoin(gameData.coin); - // 在庫数表示 - stockView.SetStock(gameData.StorageTanks); - // 全レシピ var allRecipe = RecipeData.GetAllRecipe(); - + // 在庫数表示 + stockView.SetStock(gameData.StorageTanks); StockFlavorLog(); // 陳列 var displayFlavors = gameData.ShopStock.Select(x => x).ToList(); cartView.SetStock(displayFlavors); - // 売り順決定 var shuffledOrder = ShuffleOrder(displayFlavors.Count); + + // お客さん出現パターン確率計算と行動パターン計算 + Observable.Interval(TimeSpan.FromSeconds(.5f)).Take(5).Subscribe(_ => + { + var customer = Instantiate(customerPrefab); + var customerController = customer.GetComponent(); + customerController.SetMove(CustomerMovingType.WalkSide); + customerController.Setup(); + var heartAnimation = customer.GetComponent(); + Observable.Timer(TimeSpan.FromSeconds(2f)).Subscribe(__ => + { + heartAnimation.GetHeart(); + }); + }).AddTo(this); + // お客さんの出現タイミング(10秒間に1回) Observable.Timer(TimeSpan.FromSeconds(2f), TimeSpan.FromSeconds(10f))