From b6dec2d6a36a6ff02ce205583074eb9db943e78e Mon Sep 17 00:00:00 2001 From: kimura Date: Thu, 24 Jun 2021 10:01:04 +0900 Subject: [PATCH] =?UTF-8?q?corn=20sprite=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- popcorn/Assets/MyGame/Scenes/Main/Corn.cs | 16 +++++++++------- popcorn/Assets/MyGame/Scenes/Main/corn.prefab | 4 +++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/Main/Corn.cs b/popcorn/Assets/MyGame/Scenes/Main/Corn.cs index a44439c6..d483b5ba 100644 --- a/popcorn/Assets/MyGame/Scenes/Main/Corn.cs +++ b/popcorn/Assets/MyGame/Scenes/Main/Corn.cs @@ -7,8 +7,9 @@ using Random = UnityEngine.Random; [RequireComponent(typeof(Rigidbody2D))] public class Corn : MonoBehaviour { - // [SerializeField] private List cornSprites; + [SerializeField] private Sprite cornSeedSprite; [SerializeField] private Sprite cornSimpleSprite; + [SerializeField] private Sprite cornBurntSprite; // コーン速度 [SerializeField] private float cornVelocity; // コーンがスポーンしてからの時間 @@ -27,27 +28,28 @@ public class Corn : MonoBehaviour void Start() { rigidbody2D = GetComponent(); + // GetComponent().sprite = cornSeedSprite; cornSpawnTime = Time.time; var cornPopBasicTime = 5f; cornPopTime = cornPopBasicTime + Random.Range(0, 5f); + rigidbody2D.position = new Vector2(0f, Random.value); } private void Update() { cornVelocity = rigidbody2D.velocity.magnitude; cornLifeTime = Time.time - cornSpawnTime; - if (!isPop && cornLifeTime >= cornPopTime) - { - CornPop(); - isPop = true; - } + // if (!isPop && cornLifeTime >= cornPopTime) + // { + // CornPop(); + // isPop = true; + // } } private void CornPop() { var popVelocity = 20f; var popDirection = new Vector2(Random.value * 2 - 1, Random.value * 2 - 1); - Debug.Log(popDirection); rigidbody2D.AddForce(popVelocity * popDirection, ForceMode2D.Impulse); GetComponent().sprite = cornSimpleSprite; } diff --git a/popcorn/Assets/MyGame/Scenes/Main/corn.prefab b/popcorn/Assets/MyGame/Scenes/Main/corn.prefab index 8e117850..f9945524 100644 --- a/popcorn/Assets/MyGame/Scenes/Main/corn.prefab +++ b/popcorn/Assets/MyGame/Scenes/Main/corn.prefab @@ -46,7 +46,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 175dce409df2f4d3aa1941a08822e03e, type: 3} m_Name: m_EditorClassIdentifier: - cornSimpleSprite: {fileID: 21300000, guid: 97ac0328246620745b8881e07f709ce7, type: 3} + cornSeedSprite: {fileID: 21300000, guid: 97ac0328246620745b8881e07f709ce7, type: 3} + cornSimpleSprite: {fileID: 21300000, guid: 041ad2539ff56d945ab2da4be6a02f04, type: 3} + cornBurntSprite: {fileID: 21300000, guid: a9d669186411b2b4da1511f59a91b4c9, type: 3} cornVelocity: 0 cornLifeTime: 0 --- !u!212 &1324329073609281163