diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Cooking.unity b/popcorn/Assets/MyGame/Scenes/Cooking/Cooking.unity index ac6e29dc..11e663d7 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Cooking.unity +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Cooking.unity @@ -456,9 +456,9 @@ RectTransform: m_Father: {fileID: 1110039801} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -48.9, y: 0} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 0, y: 0.5} + m_AnchoredPosition: {x: 44.1, y: 0} m_SizeDelta: {x: 62, y: 66} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &404298885 @@ -1273,9 +1273,9 @@ RectTransform: m_Father: {fileID: 1488490346} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 46.3, y: 0} + m_AnchorMin: {x: 1, y: 0.5} + m_AnchorMax: {x: 1, y: 0.5} + m_AnchoredPosition: {x: -46.699997, y: 0} m_SizeDelta: {x: 62, y: 66} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &934697757 @@ -1579,13 +1579,13 @@ RectTransform: m_Children: - {fileID: 404298884} m_Father: {fileID: 1693325335} - m_RootOrder: 0 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 0, y: 0.5} - m_AnchoredPosition: {x: -140, y: 0} + m_AnchoredPosition: {x: -233, y: 0} m_SizeDelta: {x: 186, y: 74} - m_Pivot: {x: 0.5, y: 0.5} + m_Pivot: {x: 0, y: 0.5} --- !u!114 &1110039802 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2519,9 +2519,9 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 1, y: 0.5} m_AnchorMax: {x: 1, y: 0.5} - m_AnchoredPosition: {x: 142, y: 0} - m_SizeDelta: {x: 186, y: 74} - m_Pivot: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 235.00748, y: 0} + m_SizeDelta: {x: 196.1, y: 74} + m_Pivot: {x: 1, y: 0.5} --- !u!114 &1488490347 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2999,8 +2999,8 @@ RectTransform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - - {fileID: 1110039801} - {fileID: 1759816008} + - {fileID: 1110039801} - {fileID: 1488490346} m_Father: {fileID: 649269357} m_RootOrder: 1 @@ -3040,12 +3040,12 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 1693325335} - m_RootOrder: 1 + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 1, y: 0} - m_SizeDelta: {x: 198, y: 74} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 500.98572, y: 74} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1759816009 MonoBehaviour: @@ -3154,6 +3154,8 @@ MonoBehaviour: deadZone: 0.08 baseIncreaseSpeed: 0.06 maxDecreaseSpeed: 0.09 + coldValue: 0.32 + hotValue: 0.67 --- !u!114 &1870432536 MonoBehaviour: m_ObjectHideFlags: 0 @@ -3220,6 +3222,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: slider: {fileID: 649269358} + coldCondition: {fileID: 1110039801} + hotCondition: {fileID: 1488490346} --- !u!1 &1932605390 GameObject: m_ObjectHideFlags: 0 diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermalControl.cs b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermalControl.cs index 23a61215..ff8cb731 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermalControl.cs +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermalControl.cs @@ -1,6 +1,14 @@ using System; +using Unity.Mathematics; using UnityEngine; +public enum ThermalCondition +{ + Cold, + Yellow, + Hot +} + public class ThermalControl : MonoBehaviour { [SerializeField] private PanController panController; @@ -15,11 +23,18 @@ public class ThermalControl : MonoBehaviour [Header("熱くなるスピード/冷えるスピードの最大値")] [SerializeField] private float baseIncreaseSpeed = .03f; [SerializeField] private float maxDecreaseSpeed = .03f; + [Space] + [Header("ゲージ調整")] + [SerializeField] private float coldValue = 0.32f; + [SerializeField] private float hotValue = 0.67f; private void Start() { + thermoMeter.SetScale(coldValue, hotValue); } + private ThermalCondition prevCond; + private void Update() { panSpeed = panController.Delta.magnitude * panFactor; @@ -33,5 +48,25 @@ public class ThermalControl : MonoBehaviour } temperature = Mathf.Clamp01(temperature); thermoMeter.SetValue(temperature); + + var cond = GetCondition(); + if (cond != prevCond) + { + Debug.Log($"cond :{cond} temp: {temperature}"); + prevCond = cond; + } + } + + private ThermalCondition GetCondition() + { + if (temperature <= coldValue) + { + return ThermalCondition.Cold; + } + if (temperature >= hotValue) + { + return ThermalCondition.Hot; + } + return ThermalCondition.Yellow; } } diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermoMeter.cs b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermoMeter.cs index d99caa72..b826bb9d 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermoMeter.cs +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermoMeter.cs @@ -5,6 +5,8 @@ using UnityEngine.UI; public class ThermoMeter : MonoBehaviour { [SerializeField] private Slider slider; + [SerializeField] private RectTransform coldCondition; + [SerializeField] private RectTransform hotCondition; private void Start() { @@ -12,9 +14,15 @@ public class ThermoMeter : MonoBehaviour } // 温度の目盛りの幅を設定 - private void SetScale((float blue, float yellow, float red) scale) + public void SetScale(float coldValue, float hotValue) { - + var width = (slider.transform as RectTransform).sizeDelta.x; + var coldSize = coldCondition.sizeDelta; + coldSize.x = Mathf.Lerp(0, width, coldValue); + coldCondition.sizeDelta = coldSize; + var hotSize = hotCondition.sizeDelta; + hotSize.x = Mathf.Lerp(0, width, 1 - hotValue); + hotCondition.sizeDelta = hotSize; } public void SetValue(float value)