From f7c7dacdd63dd966ff59f2b95548558bb5d69ef0 Mon Sep 17 00:00:00 2001 From: kimura Date: Wed, 7 Jul 2021 15:08:39 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=AF=E3=83=AA=E3=82=A2=E5=BE=8C=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=B3=E5=87=A6=E7=90=86=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/Cooking/Scripts/CornManager.cs | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CornManager.cs b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CornManager.cs index 84c81432..de534a15 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CornManager.cs +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CornManager.cs @@ -26,6 +26,7 @@ public class CornManager : MonoBehaviour private Corn[] cornArray; private bool isHot; + private bool isCompleted; private List> cornConditions = new List>(); private readonly ReactiveProperty cornGrowSpeed = new FloatReactiveProperty(0f); private readonly CompositeDisposable compositeDisposable = new CompositeDisposable(); @@ -43,6 +44,7 @@ public class CornManager : MonoBehaviour public void RespawnCorn() { + isCompleted = false; compositeDisposable.Clear(); cornConditions.Clear(); for (int i = 0; i < cornArray.Length; i++) @@ -60,7 +62,7 @@ public class CornManager : MonoBehaviour cornArray[i] = corn; corn.SetCornProperty(baseCornPopTime, cornBurntDuration); - cornGrowSpeed.Subscribe(x => + cornGrowSpeed.Where(_ => !isCompleted).Subscribe(x => { // コーンが弾けた後はRedの場合のみ焦げ進行する if (corn.Condition.Value == CornCondition.Simple && !isHot) @@ -90,20 +92,22 @@ public class CornManager : MonoBehaviour Observable.CombineLatest(cornConditions) .FirstOrDefault(x => !x.Contains(CornCondition.Seed)) .Subscribe(x => - { - if (x.Count(c => c == CornCondition.Simple) == x.Count) // すべてのコーンがPopped { - result.SetValueAndForceNotify(CornResult.Perfect); - } - else if (x.Count(c => c == CornCondition.Spilled) == x.Count) // すべてのコーンが飛び出した - { - result.SetValueAndForceNotify(CornResult.Failure); - } - else - { - result.SetValueAndForceNotify(CornResult.Good); - } - }).AddTo(compositeDisposable); + isCompleted = true; + cornGrowSpeed.Value = 0f; + if (x.Count(c => c == CornCondition.Simple) == x.Count) // すべてのコーンがPopped + { + result.SetValueAndForceNotify(CornResult.Perfect); + } + else if (x.Count(c => c == CornCondition.Spilled) == x.Count) // すべてのコーンが飛び出した + { + result.SetValueAndForceNotify(CornResult.Failure); + } + else + { + result.SetValueAndForceNotify(CornResult.Good); + } + }).AddTo(compositeDisposable); } public void ChangeGrowSpeed(ThermalCondition condition)