32 lines
444 B
C#
32 lines
444 B
C#
using UnityEngine;
|
|
|
|
public class CombatEntity : Entity
|
|
{
|
|
[Header("Health")]
|
|
public float maxHealth;
|
|
public float health;
|
|
public bool invulnerable;
|
|
|
|
public void TakeDamage(float damage)
|
|
{
|
|
if (!invulnerable)
|
|
{
|
|
health -= damage;
|
|
if (health <= 0)
|
|
{
|
|
OnDeath();
|
|
}
|
|
}
|
|
}
|
|
|
|
protected virtual void OnDeath()
|
|
{
|
|
|
|
}
|
|
|
|
public void Heal(float healing)
|
|
{
|
|
health += healing;
|
|
health = Mathf.Clamp(health, 0, maxHealth);
|
|
}
|
|
}
|