From e3bb5c1c670f830986f8df7d127a6ba00d62c6fd Mon Sep 17 00:00:00 2001 From: kimura Date: Fri, 22 Oct 2021 10:09:37 +0900 Subject: [PATCH] =?UTF-8?q?=E8=B2=A9=E5=A3=B2=E3=83=97=E3=83=AD=E3=83=A2?= =?UTF-8?q?=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E6=99=82=E3=81=AE=E3=82=A2?= =?UTF-8?q?=E3=83=8B=E3=83=A1=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E6=8C=99?= =?UTF-8?q?=E5=8B=95=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../marketing/Scripts/BrotherPinkView.cs | 33 +++++++++++-------- .../MyGame/Scenes/marketing/Scripts/Market.cs | 23 ++++++++++--- .../Scenes/marketing/Scripts/MarketManager.cs | 27 +++++++++++++-- 3 files changed, 62 insertions(+), 21 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/BrotherPinkView.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/BrotherPinkView.cs index a191cd03..09e3292d 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/BrotherPinkView.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/BrotherPinkView.cs @@ -98,10 +98,11 @@ public class BrotherPinkView : SingletonMonoBehaviour target.localPosition = pinkTransform.localPosition; target.localRotation = pinkTransform.localRotation; }).AddTo(animator); - if (!isManyCustomer) + if (isManyCustomer || isPromotion) { - SetPinkMove(); + return; } + SetPinkMove(); } private void SetPinkMove() @@ -158,24 +159,28 @@ public class BrotherPinkView : SingletonMonoBehaviour public void StopPromotion() { - if (animator == null) + if (animator != null) { - isPromotion = false; - ResetMove(); - return; + var stateInfo = animator.GetCurrentAnimatorStateInfo(0); + if (stateInfo.IsName("Brother_pink_promotion")) + { + var length = stateInfo.length; + var time = stateInfo.normalizedTime; + this.CallWaitForSeconds((1 - time % 1) * length - .3f, () => + { + ResetMove(); + isPromotion = false; + }); + return; + } } - var length = animator.GetCurrentAnimatorStateInfo(0).length; - var time = animator.GetCurrentAnimatorStateInfo(0).normalizedTime; - this.CallWaitForSeconds((1 - time % 1) * length - .3f, () => - { - isPromotion = false; - ResetMove(); - }); + ResetMove(); + isPromotion = false; } public void SetWalk() { - if (isLocked) + if (isLocked || isPromotion) { return; } diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs index 7d5f1f49..f104d880 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/Market.cs @@ -39,6 +39,8 @@ public class Market : SingletonMonoBehaviour private readonly ReactiveCollection waitCustomerList = new ReactiveCollection(); private readonly Subject orderSubject = new Subject(); public readonly BoolReactiveProperty IsPause = new BoolReactiveProperty(false); + public IReadOnlyReactiveProperty IsPromotion => isPromotion; + private readonly BoolReactiveProperty isPromotion = new BoolReactiveProperty(); public Subject SellObservable => sellObservable; private readonly Subject sellObservable = new Subject(); @@ -59,6 +61,7 @@ public class Market : SingletonMonoBehaviour requestSubject.AddTo(this); orderSubject.AddTo(this); IsPause.AddTo(this); + isPromotion.AddTo(this); var gameData = GameDataManager.GameData; @@ -99,7 +102,7 @@ public class Market : SingletonMonoBehaviour Debug.Log($"aa order:{count} Request {Time.time} {customer.GetHashCode()}"); if (count >= maxOrder) { - shopState.Value = ShopState.Busy; + // shopState.Value = ShopState.Busy; return; } waitCustomerList.Remove(customer); @@ -149,7 +152,15 @@ public class Market : SingletonMonoBehaviour orders.AddRange(tmpOrders); // コーンの味吹き出しを設定 - controller.SetWantFlavor(displayFlavors[tmpOrders.RandomChoose()]); + try + { + controller.SetWantFlavor(displayFlavors[tmpOrders.RandomChoose()]); + } + catch (Exception e) + { + Debug.LogError($"d:{displayFlavors.Count}, {string.Join("", tmpOrders)}"); + throw; + } } foreach (var customerController in dontBuyCustomerList) { @@ -513,8 +524,12 @@ public class Market : SingletonMonoBehaviour public void AdClickAction() { - BrotherPinkView.Instance.StartPromotion(); - customerFlow.StartAdWalker(() => BrotherPinkView.Instance.StopPromotion()); + isPromotion.Value = true; + customerFlow.StartAdWalker(() => + { + isPromotion.Value = false; + BrotherPinkView.Instance.StopPromotion(); + }); } private void CheckAndFixStock() diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketManager.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketManager.cs index 0fc04d3f..b64d8c2c 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketManager.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/MarketManager.cs @@ -28,20 +28,20 @@ public class MarketManager : MonoBehaviour private void Start() { resetRefreshTimer.AddTo(this); + market = Market.Instance; SoundManager.Instance.PlayBGM("bgm_marketing"); var gameData = GameDataManager.GameData; CoinManager.Instance.ChangeCoin(gameData.Coin); HeartMeter.Instance.Initialize(gameData.ViewedShopLevel, gameData.Heart); GameDataObserver.Instance.ShopLevelUpdate - .Where(x => x) + .Where(x => x && !market.IsPromotion.Value) .Subscribe(x => { LocalCacheManager.Save(ShopLevelUp.DataTag, gameData.ViewedShopLevel + 1); TransitionManager.Instance.LoadSceneAdditive(GameScenes.StoreLevel); }).AddTo(this); - market = Market.Instance; productDataList = SpreadsheetDataManager.Instance.GetBaseDataList(Const.ProductDataSheet); stockView.SetStock(gameData.StorageTanks); var startStocks = market.ShuffledOrder.Select(x => (x, market.DisplayFlavors[x])).ToList(); @@ -82,6 +82,19 @@ public class MarketManager : MonoBehaviour var remaining = (int) DateTime.FromBinary(gameData.increaseCustomerTime).Subtract(DateTime.UtcNow).TotalSeconds; resetRefreshTimer.OnNext(remaining); + + market.IsPromotion.Subscribe(active => + { + if (active) + { + SoundManager.Instance.PlayBGM("bgm_publicity"); + BrotherPinkView.Instance.StartPromotion(); + } + else + { + SoundManager.Instance.PlayBGM("bgm_marketing"); + } + }).AddTo(this); // Customerの各アニメーション設定 @@ -127,7 +140,15 @@ public class MarketManager : MonoBehaviour // 補充したフレーバーのスキンを設定 foreach (var order in x.refillList) { - cartView.Refill(order, market.DisplayFlavors[order]); + try + { + cartView.Refill(order, market.DisplayFlavors[order]); + } + catch (Exception e) + { + Debug.LogError($"order:{order}, displayFlavors:{market.DisplayFlavors.Count}"); + throw; + } } } }).AddTo(this);