diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CornManager.cs b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CornManager.cs index de534a15..cb88c7e7 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CornManager.cs +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CornManager.cs @@ -62,7 +62,7 @@ public class CornManager : MonoBehaviour cornArray[i] = corn; corn.SetCornProperty(baseCornPopTime, cornBurntDuration); - cornGrowSpeed.Where(_ => !isCompleted).Subscribe(x => + cornGrowSpeed.TakeWhile(_ => !isCompleted).Subscribe(x => { // コーンが弾けた後はRedの場合のみ焦げ進行する if (corn.Condition.Value == CornCondition.Simple && !isHot) @@ -93,8 +93,8 @@ public class CornManager : MonoBehaviour .FirstOrDefault(x => !x.Contains(CornCondition.Seed)) .Subscribe(x => { - isCompleted = true; cornGrowSpeed.Value = 0f; + isCompleted = true; if (x.Count(c => c == CornCondition.Simple) == x.Count) // すべてのコーンがPopped { result.SetValueAndForceNotify(CornResult.Perfect); diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/Pan.cs b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/Pan.cs index 7aa5848b..add09484 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/Pan.cs +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/Pan.cs @@ -5,14 +5,15 @@ public class Pan : MonoBehaviour { [SerializeField] private PanController controller; [SerializeField] private float thrust; + private static readonly float deadZone = 0.1f; private void OnTriggerStay2D(Collider2D other) { - // Debug.Log(controller.Direction); // 移動量が少ないときは動かない - // if (controller.Delta.magnitude >= 1f) Debug.Log(controller.Delta.magnitude); - var direct = 1f; - direct = controller.Delta.magnitude < 0.1f ? 0 : 1; - other.attachedRigidbody.AddForce(controller.Delta * thrust * direct, ForceMode2D.Impulse); + if (controller.Delta.magnitude < deadZone) + { + return; + } + other.attachedRigidbody.AddForce(controller.Delta * thrust, ForceMode2D.Impulse); } } \ No newline at end of file diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/PanController.cs b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/PanController.cs index 470a0428..746a4b61 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/PanController.cs +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/PanController.cs @@ -18,13 +18,17 @@ public class PanController : MonoBehaviour, IDragHandler, IBeginDragHandler private Vector2 delta; public Vector2 Delta => delta; - // Start is called before the first frame update - void Start() + void Awake() { firstPos = target.position; prevPos = firstPos; } + private void OnDisable() + { + delta = Vector2.zero; + } + // Update is called once per frame void Update() { @@ -34,6 +38,9 @@ public class PanController : MonoBehaviour, IDragHandler, IBeginDragHandler delta = Vector2.zero; } prevPos = target.position; +#if UNITY_EDITOR + deltaString = $"delta: {delta.normalized} {delta.magnitude:F3}"; +#endif } @@ -45,9 +52,6 @@ public class PanController : MonoBehaviour, IDragHandler, IBeginDragHandler // 移動範囲を制限 pos = targetBorder.bounds.ClosestPoint(pos); delta = pos - targetPos; -#if UNITY_EDITOR - deltaString = $"delta: {delta.normalized} {delta.magnitude:F3}"; -#endif target.position = pos; } @@ -58,4 +62,9 @@ public class PanController : MonoBehaviour, IDragHandler, IBeginDragHandler offset = targetPos - Camera.main.ScreenToWorldPoint(new Vector3(eventData.position.x, eventData.position.y, targetPos.z)); } + + public void ResetTargetPosition() + { + target.position = firstPos; + } } diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermalControl.cs b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermalControl.cs index 031e5812..d2d779fa 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermalControl.cs +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/ThermalControl.cs @@ -93,15 +93,18 @@ public class ThermalControl : MonoBehaviour temperature = 0f; temperatureSpeed = 0f; thermoMeter.SetScale(coldValue, hotValue); + panController.ResetTargetPosition(); } public void StartMeter() { isMove = true; + panController.enabled = true; } public void StopMeter() { isMove = false; + panController.enabled = false; } }