public void ApplyDamage(int damage) { HP -= damage; if (HP < 0) { isDead = true; } HPChanged?.Invoke(this, new TowerHPChangeEventArgs(HP)); }
public void Heal(int heal) { HP += heal; if (HP > Max_HP) { HP = Max_HP; } HPChanged?.Invoke(this, new TowerHPChangeEventArgs(HP)); }
public virtual void TakeDamage(int damage) { hp = Mathf.Clamp(hp - damage, 0, MaxHP); if (hp > 0) { HPChanged?.Invoke(hp); } else { Die?.Invoke(); } }
public void TakeDamage(float damageAmount) { if (useMultiplier) { damageAmount *= 1.25f; } damageTaken += damageAmount; damageTaken = damageTaken > maxHp ? maxHp : damageTaken; onHPChanged.Invoke(1f - damageTaken / maxHp); if (damageTaken >= maxHp) { damageTaken = 0; // reset to 0 on death onDeath.Invoke( ); } }
public void ChangeHP(float hP) { HPChanged?.Invoke(hP); }