diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermalControl.cs b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermalControl.cs index d07b9430..4ba95727 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermalControl.cs +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermalControl.cs @@ -33,15 +33,12 @@ public class ThermalControl : MonoBehaviour private float duration = 0.3f; + private readonly ReactiveProperty condition = new ReactiveProperty(ThermalCondition.Cold); public IReadOnlyReactiveProperty Condition => condition; - private ReactiveProperty condition; - public void Initialize() + private void Start() { - temperature = 0f; - condition = new ReactiveProperty(ThermalCondition.Cold); - thermoMeter.SetScale(coldValue, hotValue); - + condition.AddTo(this); condition.DistinctUntilChanged().Subscribe(x => { Debug.Log($"cond :{x} temp: {temperature}"); @@ -71,7 +68,7 @@ public class ThermalControl : MonoBehaviour condition.Value = GetCondition(); } - public ThermalCondition GetCondition() + private ThermalCondition GetCondition() { if (temperature <= coldValue) { @@ -83,4 +80,11 @@ public class ThermalControl : MonoBehaviour } return ThermalCondition.Yellow; } + + public void ResetMeter() + { + temperature = 0f; + temperatureSpeed = 0f; + thermoMeter.SetScale(coldValue, hotValue); + } } diff --git a/popcorn/Assets/PopcornGameManager.cs b/popcorn/Assets/PopcornGameManager.cs index 96e6314f..9fec24c6 100644 --- a/popcorn/Assets/PopcornGameManager.cs +++ b/popcorn/Assets/PopcornGameManager.cs @@ -25,30 +25,29 @@ public class PopcornGameManager : MonoBehaviour gameResultText.text = ""; // startingGuide.SetActive(true); isProgress = false; - cornManager.Initialize(); - thermalControl.Initialize(); - thermalControl.Condition.DistinctUntilChanged().Subscribe(x => + thermalControl.Condition.Subscribe(x => { cornManager.ChangeGrowSpeed(x); }).AddTo(this); - GameReset(); + ResetGame(); // タップ後スタート - GameStart(); + StartGame(); } private void Update() { } - private void GameReset() + private void ResetGame() { - cornManager.GenerateCorn(); + thermalControl.ResetMeter(); + cornManager.RespawnCorn(); } - private void GameStart() + private void StartGame() { } }