From fda7226d6cd6bfeb2b220237941dfede72f7e5a4 Mon Sep 17 00:00:00 2001 From: kimura Date: Wed, 7 Jul 2021 16:32:58 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?UTF-8?q?=E3=82=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- popcorn/Assets/MyGame/Scenes/Cooking/Scripts/Pan.cs | 11 ++++++----- .../MyGame/Scenes/Cooking/Scripts/PanController.cs | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) 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..5c115829 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/PanController.cs +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/PanController.cs @@ -34,6 +34,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 +48,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; } From 7a797f1c07cac7ad72f081bf8f75cf7436651cf1 Mon Sep 17 00:00:00 2001 From: kimura Date: Wed, 7 Jul 2021 16:34:41 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E3=82=B2=E3=83=BC=E3=83=A0=E7=8A=B6?= =?UTF-8?q?=E6=85=8B=E3=81=A7=E3=83=95=E3=83=A9=E3=82=A4=E3=83=91=E3=83=B3?= =?UTF-8?q?=E3=82=92=E6=AD=A2=E3=82=81=E3=82=8B=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0/=E3=83=9D=E3=82=B8=E3=82=B7=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=83=AA=E3=82=BB=E3=83=83=E3=83=88=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyGame/Scenes/Cooking/Scripts/PanController.cs | 13 +++++++++++-- .../MyGame/Scenes/Cooking/Scripts/ThermalControl.cs | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/PanController.cs b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/PanController.cs index 5c115829..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() { @@ -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; } } From 40ac7d03f6152fa7081d59ffc25749380479a807 Mon Sep 17 00:00:00 2001 From: kimura Date: Wed, 7 Jul 2021 17:16:39 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E7=B5=82=E4=BA=86=E5=87=A6=E7=90=86?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- popcorn/Assets/MyGame/Scenes/Cooking/Scripts/CornManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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);