From cb6601de8a8f1b1e5b56f6a2e4597d0ae1a46ddd Mon Sep 17 00:00:00 2001 From: kimura Date: Mon, 29 Nov 2021 15:01:36 +0900 Subject: [PATCH] =?UTF-8?q?Market=E3=82=92=E8=A8=AD=E5=AE=9A=E3=82=AF?= =?UTF-8?q?=E3=83=A9=E3=82=B9=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyGame/Scenes/Title/Scripts/Title.cs | 2 +- .../MyGame/Scenes/marketing/Scripts/Market.cs | 44 +++++-------------- 2 files changed, 11 insertions(+), 35 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/Title/Scripts/Title.cs b/popcorn/Assets/MyGame/Scenes/Title/Scripts/Title.cs index 4efee0e3..477083da 100644 --- a/popcorn/Assets/MyGame/Scenes/Title/Scripts/Title.cs +++ b/popcorn/Assets/MyGame/Scenes/Title/Scripts/Title.cs @@ -46,7 +46,7 @@ public class Title : MonoBehaviour .Subscribe(t => { // 一般客orセレブ - var (isSpecial, orderCount) = Market.GetCustomerData(false); + var (isSpecial, orderCount) = Market.Instance.GetCustomerData(false); // 複数パターンある場合ChooseRandom var prefab = isSpecial ? customerData.ChooseSpecialPrefab() : customerData.ChooseNormalPrefab(); diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs index cc086b3f..c1aa1e62 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Linq; +using MyGame.Scenes.marketing.Scripts; using TMPro; using UniRx; using UniRx.Triggers; @@ -18,21 +19,15 @@ public enum ShopState public class Market : SingletonMonoBehaviour { public static readonly int ShopStockCount = 20; - private static readonly int SpecialOrderCount = 5; - private static readonly (int want, float weight)[] CustomerWeightTable = { - (1, 75f), - (2, 15f), - (3, 3.5f), - (4, 1.25f), - (5, .25f), - (0, 5f), - }; - private static readonly float walkerSpecialRate = .01f; - private static readonly float customerSpecialRate = .01f; + + // 購入時アニメーションタイミング + private static readonly float waitSellTime = 1.5f; + private static readonly float waitRefillTime = 1f; [SerializeField] private CustomerFlow customerFlow; [SerializeField] private GameObject orderPosisionObject; [SerializeField] private CustomerData customerData; + [SerializeField] private CustomerSetting customerSetting; [SerializeField] private CustomerController customerControllerPrefab; public List DisplayFlavors => displayFlavors; @@ -229,13 +224,13 @@ public class Market : SingletonMonoBehaviour } } - this.CallWaitForSeconds(1.5f, () => + this.CallWaitForSeconds(waitSellTime, () => { sellObservable.OnNext(coin); sellOrderSubject.OnNext(orders); CheckStock(gameData.ShopStock); - this.CallWaitForSeconds(1f, () => + this.CallWaitForSeconds(waitRefillTime, () => { refillSubject.OnNext((isReorder, refillList)); foreach (var controller in customers) @@ -341,28 +336,9 @@ public class Market : SingletonMonoBehaviour } - public static (bool isSpecial, int orderCount) GetCustomerData (bool isCustomer) + public (bool isSpecial, int orderCount) GetCustomerData (bool isCustomer) { - var specialRate = isCustomer ? walkerSpecialRate : customerSpecialRate; - var isSpecial = Random.value < specialRate; - - // セレブは5個購入固定 - return isSpecial ? (true, specialOrderCount: SpecialOrderCount) : (false, GetOrderCount()); - } - - // お客さん出現パターン確率計算と行動パターン計算 - private static int GetOrderCount() - { - var randomPoint = Random.value * CustomerWeightTable.Sum(x => x.weight); - foreach (var value in CustomerWeightTable) - { - if (randomPoint < value.weight) - { - return value.want; - } - randomPoint -= value.weight; - } - return CustomerWeightTable.Last().want; + return customerSetting.GetCustomerData(isCustomer); } private CustomerController SpawnCustomer()