From c13c5ee529236028d9c8416fe44c0a14b4d22c58 Mon Sep 17 00:00:00 2001 From: kimura Date: Mon, 16 May 2022 18:47:02 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=9C=E3=83=BC=E3=83=8A=E3=82=B9=E5=8F=8D?= =?UTF-8?q?=E6=98=A0=E5=87=A6=E7=90=86=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/marketing/Scripts/CustomerFlow.cs | 27 ++++++++++++------- .../MyGame/Scenes/marketing/Scripts/Market.cs | 9 +++++++ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerFlow.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerFlow.cs index 2b7f8321..8da67230 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerFlow.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/CustomerFlow.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using UniRx; using UnityEngine; @@ -19,7 +20,8 @@ public class CustomerFlow : MonoBehaviour private IObservable vipCustomerObservable; private readonly Subject> vipCustomerSubject = new Subject>(); private IObservable tastingCustomerObservable; - private static readonly float checkHeartInterval = 1f; + private static readonly float CheckHeartInterval = 1f; + private static readonly float TenMinutes = 60f * 10; [Header("1分間あたりの歩行者数")] [SerializeField] private float walkerInterval = 60f / 6; @@ -39,6 +41,9 @@ public class CustomerFlow : MonoBehaviour public float TastingCustomerInterval => tastingCustomerInterval; private int adActiveCount = 0; + // bonus + private int customerBonus; + private int adWalkerBonus; public IObservable Flow => walkerObservable.Merge(customerObservable, adWalkerObservable, vipCustomerObservable, tastingCustomerObservable); @@ -49,17 +54,15 @@ public class CustomerFlow : MonoBehaviour var shopLevelList = SpreadsheetDataManager.Instance.GetBaseDataList(Const.ShopLevelDataSheet); shopLevelList = shopLevelList.Where(data => data.shopLevel != Const.SpecialShopLevel).ToList(); - // 10分間期待値を来客の間隔に変換 - var intervalList = shopLevelList.Select(shopLevel => (heart: shopLevel.heart, interval: 60f * 10 / shopLevel.customer)); // 1秒間隔でハートを確認 - var changeCustomerFlowObservable = Observable.Interval(TimeSpan.FromSeconds(checkHeartInterval)) - .Select(_ => GameDataManager.GameData.Heart) - .DistinctUntilChanged() - .Select(heart => intervalList.Last(x => x.heart <= heart).interval); - + var changeCustomerFlowObservable = Observable.Interval(TimeSpan.FromSeconds(CheckHeartInterval)) + .Select(_ => GameDataManager.GameData.Heart); + // お客さん出現タイマー customerObservable = changeCustomerFlowObservable + .DistinctUntilChanged() + .Select(heart => TenMinutes / (shopLevelList.Last(x => x.heart <= heart).customer + customerBonus)) // 10分間期待値を来客の間隔に変換 .DistinctUntilChanged() // .Do(x => Debug.Log($"changeInterval:{x}")) .Select(customerInterval => Observable.Interval(TimeSpan.FromSeconds(customerInterval))) @@ -121,7 +124,7 @@ public class CustomerFlow : MonoBehaviour private IObservable AdWalkerTimer() { - return Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(adWalkerDuration/adWalkerCount)) + return Observable.Timer(TimeSpan.Zero, TimeSpan.FromSeconds(adWalkerDuration/(adWalkerCount + adWalkerBonus))) .Take(TimeSpan.FromSeconds(adWalkerDuration)) .AsUnitObservable(); } @@ -132,4 +135,10 @@ public class CustomerFlow : MonoBehaviour .Take(vipCustomerCount) .AsUnitObservable()); } + + public void UpdateBonus(Dictionary bonusList) + { + customerBonus = bonusList[ShopCustomizeBonusCategory.Customer].value; + adWalkerBonus = bonusList[ShopCustomizeBonusCategory.AdWalker].value; + } } diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs index 8c13b304..7c66c408 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs @@ -61,6 +61,7 @@ public class Market : SingletonMonoBehaviour private int orderIndex; private int oneByOneIndex = 0; + private int salesBonus = 0; private GameData gameData; // Start is called before the first frame update @@ -442,6 +443,7 @@ public class Market : SingletonMonoBehaviour gameData.ShopStock.RemoveAt(targetIndex); gameData.AddSalesCount(stockData.FlavorId, 1, stockData.Rarity); coin += productData.GetRarityPrice(rarityData.Rarity); + coin += salesBonus; } return coin; } @@ -562,6 +564,13 @@ public class Market : SingletonMonoBehaviour customerFlow.StartVip(); } + public void UpdateBonus(Dictionary bonusList) + { + // sales + salesBonus = bonusList[ShopCustomizeBonusCategory.Sales].value; + customerFlow.UpdateBonus(bonusList); + } + public CustomerController SetTutorialCustomer() { var customerController = SpawnCustomer();