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)