From b2dbea36b21f200772135795df6c5248753ab1ee Mon Sep 17 00:00:00 2001 From: kimura Date: Tue, 13 Jul 2021 09:23:40 +0900 Subject: [PATCH] =?UTF-8?q?Corn=E3=82=AF=E3=83=A9=E3=82=B9=E3=81=8B?= =?UTF-8?q?=E3=82=89=E9=A3=9B=E3=81=B3=E5=87=BA=E3=81=97=E6=BC=94=E5=87=BA?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyGame/Scenes/Cooking/Prefabs/corn.prefab | 4 +- .../MyGame/Scenes/Cooking/Scripts/Corn.cs | 41 ++----------------- 2 files changed, 5 insertions(+), 40 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Prefabs/corn.prefab b/popcorn/Assets/MyGame/Scenes/Cooking/Prefabs/corn.prefab index 39e3abd8..f1589d6b 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Prefabs/corn.prefab +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Prefabs/corn.prefab @@ -14,7 +14,7 @@ GameObject: - component: {fileID: 7195010600253370228} - component: {fileID: 8932234855615206969} m_Layer: 0 - m_Name: Corn + m_Name: corn m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -74,8 +74,6 @@ MonoBehaviour: effectBurnt: {fileID: 3984349228049242719, guid: 02298b5aac4434a4c81aec58ad2caa9d, type: 3} animator: {fileID: 5972257590091015193} - spilledCornAnimationPrefab: {fileID: 2449901118440757730, guid: 7e7fbf241bd7f461fb46363ff0c6be3e, - type: 3} --- !u!50 &7195010600253370228 Rigidbody2D: serializedVersion: 4 diff --git a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/Corn.cs b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/Corn.cs index df73e8be..fe1032a0 100644 --- a/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/Corn.cs +++ b/popcorn/Assets/MyGame/Scenes/Cooking/Scripts/Corn.cs @@ -27,8 +27,7 @@ public class Corn : MonoBehaviour [SerializeField] private Sprite cornBurntSprite; [SerializeField] private GameObject effectBurnt; [SerializeField] private Animator animator; - [SerializeField] private GameObject spilledCornAnimationPrefab; - + private Rigidbody2D rigidbody; private float cornPopTime; private float cornBurntTime; @@ -36,8 +35,6 @@ public class Corn : MonoBehaviour private float cornGrowSpeed; private float cornSpillSpeed; private float cornPopSpeed; - - private float worldWidth; public IReadOnlyReactiveProperty Condition => condition; private readonly ReactiveProperty condition = new ReactiveProperty(CornCondition.Seed); @@ -56,8 +53,6 @@ public class Corn : MonoBehaviour spriteTransform = spriteRenderer.transform; rotationResolverTransform = spriteTransform.parent.parent; - var rightTop = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0)); - worldWidth = rightTop.x; animator.SetFloat(HashWaitOffset, Random.value/2); } @@ -142,39 +137,11 @@ public class Corn : MonoBehaviour GetComponent().enabled = false; // フライパンに追従しないようにparent解除 transform.parent = null; - - switch (prevCondition) + this.CallWaitForSeconds(.5f, () => Destroy(gameObject)); + if (prevCondition == CornCondition.Seed) { - case CornCondition.Seed: - VibrationManager.Instance.PlayVibrationOnce(); - Observable.Timer(TimeSpan.FromSeconds(.5f)).Subscribe(_ => - { - Destroy(gameObject); - }).AddTo(this); - break; - case CornCondition.Simple: - case CornCondition.Burnt: - Observable.Timer(TimeSpan.FromSeconds(Random.Range(.3f, .5f))).Subscribe(_ => - { - Destroy(gameObject); - // 画面KO再生(同時飛び出し時ランダム) - var animation = Instantiate(spilledCornAnimationPrefab, new Vector2(Random.value * worldWidth * 2 - worldWidth, Random.value * 2 * 2 - 2), Quaternion.identity); - // KOコーンスキン変更 - animation.GetComponent().ChangeCornSkin(prevCondition); - VibrationManager.Instance.PlayVibrationOnce(); - Observable.Timer(TimeSpan.FromSeconds(1.5f)).Subscribe(__ => - { - Destroy(animation); - }); - }).AddTo(this); - - break; - case CornCondition.Spilled: - break; - default: - throw new ArgumentOutOfRangeException(nameof(prevCondition), prevCondition, null); + VibrationManager.Instance.PlayVibrationOnce(); } - } public void SetCornProperty(float popTime, float burntDuration, float spillSpeed, float popSpeed)