diff --git a/Assets/Prefab/Ashman_Enemy3.prefab b/Assets/Prefab/Ashman_Enemy3.prefab index afa134b..5dee153 100644 --- a/Assets/Prefab/Ashman_Enemy3.prefab +++ b/Assets/Prefab/Ashman_Enemy3.prefab @@ -203,6 +203,7 @@ MonoBehaviour: damage: 0 HealthEnemy: 25 healthEnemy: 0 + switchDuration: 0.3 --- !u!50 &4003872555974094568 Rigidbody2D: serializedVersion: 4 diff --git a/Assets/Prefab/BoomEnemy.prefab b/Assets/Prefab/BoomEnemy.prefab index d112b99..25123b5 100644 --- a/Assets/Prefab/BoomEnemy.prefab +++ b/Assets/Prefab/BoomEnemy.prefab @@ -4951,7 +4951,7 @@ CircleCollider2D: m_CallbackLayers: serializedVersion: 2 m_Bits: 4294967295 - m_IsTrigger: 0 + m_IsTrigger: 1 m_UsedByEffector: 0 m_UsedByComposite: 0 m_Offset: {x: 0.0025429726, y: 0} diff --git a/Assets/Prefab/HealthUp.prefab b/Assets/Prefab/HealthUp.prefab index 961d276..698c64d 100644 --- a/Assets/Prefab/HealthUp.prefab +++ b/Assets/Prefab/HealthUp.prefab @@ -117,7 +117,7 @@ BoxCollider2D: m_CallbackLayers: serializedVersion: 2 m_Bits: 4294967295 - m_IsTrigger: 0 + m_IsTrigger: 1 m_UsedByEffector: 0 m_UsedByComposite: 0 m_Offset: {x: -0.00037294626, y: 0.00057081133} diff --git a/Assets/Prefab/SpeedUp.prefab b/Assets/Prefab/SpeedUp.prefab index c3caab7..751f25b 100644 --- a/Assets/Prefab/SpeedUp.prefab +++ b/Assets/Prefab/SpeedUp.prefab @@ -4974,7 +4974,7 @@ BoxCollider2D: m_CallbackLayers: serializedVersion: 2 m_Bits: 4294967295 - m_IsTrigger: 0 + m_IsTrigger: 1 m_UsedByEffector: 0 m_UsedByComposite: 0 m_Offset: {x: -0.0007728264, y: 0.0022977144} diff --git a/Assets/Scripts/AiDamage.cs b/Assets/Scripts/AiDamage.cs index eac2c8b..7dbcd4c 100644 --- a/Assets/Scripts/AiDamage.cs +++ b/Assets/Scripts/AiDamage.cs @@ -10,10 +10,8 @@ public class AiDamage : MonoBehaviour public int HealthEnemy = 25; public int healthEnemy; - public Sprite normalSprite; // Reference to the normal sprite - public Sprite damageSprite; // Reference to the sprite to switch to when taking damage - public float switchDuration = 0.5f; // Duration to switch to damage sprite (in seconds) - public int numberflashes; + float switchDuration = 0.1f; // Duration to switch to damage sprite (in seconds) + int numberflashes = 3; private SpriteRenderer spriteRenderer; // Reference to the SpriteRenderer component @@ -42,8 +40,6 @@ private void OnCollisionEnter2D(Collision2D collision) } public void EDamage(int damage) { - - healthEnemy -= damage; } @@ -53,10 +49,35 @@ private void OnTriggerEnter2D(Collider2D collision) { playerHealth.TakeDamage(damage); - GetComponent().material.color = Color.red; + StartCoroutine(FlashRed()); } + if(collision.gameObject.tag == "PlayerBullet") + { + StartCoroutine(FlashRed()); + } } + IEnumerator FlashRed() + { + + GetComponent().material.color = Color.red; + yield return new WaitForSeconds(switchDuration); + GetComponent().material.color = Color.white; + yield return new WaitForSeconds(switchDuration); + GetComponent().material.color = Color.red; + yield return new WaitForSeconds(switchDuration); + GetComponent().material.color = Color.white; + yield return new WaitForSeconds(switchDuration); + GetComponent().material.color = Color.red; + yield return new WaitForSeconds(switchDuration); + GetComponent().material.color = Color.white; + yield return new WaitForSeconds(switchDuration); + GetComponent().material.color = Color.red; + yield return new WaitForSeconds(switchDuration); + GetComponent().material.color = Color.white; + yield return new WaitForSeconds(switchDuration); + } + }