public class Entity:MonoBehaviour
{
public float health;
public virtual void TakeDamage(float dmg)
{
health -= dmg;
if (health <= 0)
{
Die();
}
}
//virtual 可以在子类中覆写该方法
public virtual void Die()
{
Destroy(gameObject);
}
}
{
public float health;
public virtual void TakeDamage(float dmg)
{
health -= dmg;
if (health <= 0)
{
Die();
}
}
//virtual 可以在子类中覆写该方法
public virtual void Die()
{
Destroy(gameObject);
}
}