public bool Damage(int amount = 1, CharacterHealth causer = null) {
if (amount <= 0) {
Debug.LogWarning("amount <= 0 ??");
}
if (IsInvulnerable()) {
Debug.Log(this.name + " is invulnerable, ignore damage");
if (onDamage != null) {
onDamage();
}
if (onImmunity != null) {
onImmunity();
}
return false;
}
health -= amount;
// do not set invulnerable a dead Character
if (health > 0) {
SetInvulnerable(invulnerabilityTimeAfterDamage);
}
if (onDamage != null) {
onDamage();
}
if (onInjured != null) {
onInjured(null, causer);
}
if (health <= 0) {
Die();
}
return true;
}
/// <summary>