From ca80f88c558199fec62d7f9fd39e36a56075d2ee Mon Sep 17 00:00:00 2001 From: BOT Alex <44818698+MagicBOTAlex@users.noreply.github.com> Date: Sun, 4 Feb 2024 10:40:05 +0100 Subject: [PATCH] Update HealthComponent.cs --- Assets/Scripts/Player/HealthComponent.cs | 28 +++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Player/HealthComponent.cs b/Assets/Scripts/Player/HealthComponent.cs index 317877d..0dee386 100644 --- a/Assets/Scripts/Player/HealthComponent.cs +++ b/Assets/Scripts/Player/HealthComponent.cs @@ -33,17 +33,17 @@ public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver void Awake() { currentHealth = maxHealth; - OnHealthChange.AddListener((_, _) => showRedTint = 1); + OnHealthChange.AddListener((_, _) => showRedTint = true); StartCoroutine(RedTintLoop()); } - float showRedTint = 0; + bool showRedTint = false; private IEnumerator RedTintLoop() { SpriteRenderer sr = GetComponentInChildren(); while (true) { - if (showRedTint < 0.1f) + if (!showRedTint) { yield return new WaitForSecondsRealtime(0.1f); continue; @@ -53,6 +53,28 @@ public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver yield return new WaitForSecondsRealtime(0.1f); sr.color = Color.white; yield return new WaitForSecondsRealtime(0.1f); + sr.color = Color.red; + yield return new WaitForSecondsRealtime(0.1f); + sr.color = Color.white; + yield return new WaitForSecondsRealtime(0.1f); + sr.color = Color.red; + yield return new WaitForSecondsRealtime(0.1f); + sr.color = Color.white; + yield return new WaitForSecondsRealtime(0.1f); + sr.color = Color.red; + yield return new WaitForSecondsRealtime(0.1f); + sr.color = Color.white; + yield return new WaitForSecondsRealtime(0.1f); + sr.color = Color.red; + yield return new WaitForSecondsRealtime(0.1f); + sr.color = Color.white; + yield return new WaitForSecondsRealtime(0.1f); + sr.color = Color.red; + yield return new WaitForSecondsRealtime(0.1f); + sr.color = Color.white; + yield return new WaitForSecondsRealtime(0.1f); + + showRedTint = false; } }