private void TakeDamage(int damage) { if (this.character.Status.IsDead) { return; } this.character.Status.HitPoint -= damage; if (this.character.Status.IsDead) { Broker.Global.Publish(Died.Get(this.character)); } }
/// <summary> /// ダメージを受ける /// </summary> public void TakeDamage(DamageResult damageResult) { // すでに死亡していたら何もしない if (this.status.HitPoint.Value <= 0) { return; } this.status.HitPoint.Value -= damageResult.Damage; this.owner.Broker.Publish(TakedDamage.Get(damageResult)); // 与えた側にも通知する damageResult.Attacker?.Broker.Publish(GivedDamage.Get(damageResult)); // 死亡したら通知する if (this.status.HitPoint.Value <= 0) { this.owner.Broker.Publish(Died.Get(damageResult.Attacker)); } }