diff --git a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs index f2450356..0df5870e 100644 --- a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs +++ b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs @@ -57,13 +57,14 @@ public class CornField : MonoBehaviour private readonly CompositeDisposable compositeDisposable = new CompositeDisposable(); private readonly Subject resetFertilizerTimer = new Subject(); - private bool isFertilizing; + private readonly BoolReactiveProperty isFertilizing = new BoolReactiveProperty(); // Start is called before the first frame update void Start() { compositeDisposable.AddTo(this); resetFertilizerTimer.AddTo(this); + isFertilizing.AddTo(this); SoundManager.Instance.PlayBGM("bgm_Main"); // データ @@ -88,6 +89,9 @@ public class CornField : MonoBehaviour // ハートゲージがフルかつダイアログが開いていない場合レベルアップ HeartMeter.Instance.FulledHeart + .CombineLatest(isFertilizing, (acc, active) => acc && !active) + .DistinctUntilChanged() + .Where(x => x) .DelaySubscription(TimeSpan.FromSeconds(.4f)) .Subscribe(_ => { @@ -151,13 +155,13 @@ public class CornField : MonoBehaviour { GetRewardDialog.ShowCornFieldDialog(() => { + isFertilizing.Value = true; gameData.fertilizerTime = DateTime.UtcNow.AddSeconds(fertilizerWaitTime + fertilizerDuration).ToBinary(); #if UNITY_EDITOR gameData.fertilizerTime = DateTime.UtcNow.AddSeconds(10 + fertilizerDuration).ToBinary(); #endif GameDataManager.SaveGameData(); - isFertilizing = true; additionView.IsStopDisapper = true; SoundManager.Instance.PlayBGM("bgm_fertilizer"); brotherFertilizerAnimation.StartAnimation(); @@ -196,7 +200,7 @@ public class CornField : MonoBehaviour this.CallWaitForSeconds(fertilizerFinishWaitTime, () => { - isFertilizing = false; + isFertilizing.Value = false; additionView.IsStopDisapper = false; additionView.PlayEffect(); // ボタン表示復活