Update HealthComponent.cs
This commit is contained in:
parent
4dbe23fb69
commit
ca80f88c55
|
@ -33,17 +33,17 @@ public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
currentHealth = maxHealth;
|
currentHealth = maxHealth;
|
||||||
OnHealthChange.AddListener((_, _) => showRedTint = 1);
|
OnHealthChange.AddListener((_, _) => showRedTint = true);
|
||||||
StartCoroutine(RedTintLoop());
|
StartCoroutine(RedTintLoop());
|
||||||
}
|
}
|
||||||
|
|
||||||
float showRedTint = 0;
|
bool showRedTint = false;
|
||||||
private IEnumerator RedTintLoop()
|
private IEnumerator RedTintLoop()
|
||||||
{
|
{
|
||||||
SpriteRenderer sr = GetComponentInChildren<SpriteRenderer>();
|
SpriteRenderer sr = GetComponentInChildren<SpriteRenderer>();
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (showRedTint < 0.1f)
|
if (!showRedTint)
|
||||||
{
|
{
|
||||||
yield return new WaitForSecondsRealtime(0.1f);
|
yield return new WaitForSecondsRealtime(0.1f);
|
||||||
continue;
|
continue;
|
||||||
|
@ -53,6 +53,28 @@ public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver
|
||||||
yield return new WaitForSecondsRealtime(0.1f);
|
yield return new WaitForSecondsRealtime(0.1f);
|
||||||
sr.color = Color.white;
|
sr.color = Color.white;
|
||||||
yield return new WaitForSecondsRealtime(0.1f);
|
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