Update HealthComponent.cs
This commit is contained in:
parent
4dbe23fb69
commit
ca80f88c55
|
@ -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<SpriteRenderer>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue