From a031b7e00b8262a21e773acf122e5c24e45458cf Mon Sep 17 00:00:00 2001 From: kimura Date: Tue, 6 Jul 2021 16:58:41 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF?= =?UTF-8?q?=E3=83=AA=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/Cooking/Scripts/ThermalControl.cs | 18 +++++++++++------- popcorn/Assets/PopcornGameManager.cs | 15 +++++++-------- 2 files changed, 18 insertions(+), 15 deletions(-) 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() { } }