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)