public void TakeDamage(IHealthAgent source, int amount) { if (amount < 0) { throw new ArgumentException("Damage can not be < 0"); } _health = Mathf.Max(0, _health - amount); OnDamaged(new HealthAgentDamageArgs(_delegator, source, amount)); }
public HealthAgent(IHealthAgent delegator, int maxHealth, int currentHealth) { if (delegator == null) { throw new ArgumentException("HealthAgent is intended for delegation, plz provide a valid delegator"); } _delegator = delegator; MaxHealth = maxHealth; _health = currentHealth; }
public HealthAgentDeathArgs(IHealthAgent victim, IHealthAgent agressor, int damage) { Victim = victim; Agressor = agressor; Damage = damage; }
/// <summary> /// care this class is intended for delegation /// </summary> /// <param name="delegator">delegator</param> /// <param name="maxHealth"></param> public HealthAgent(IHealthAgent delegator, int maxHealth) : this(delegator, maxHealth, maxHealth) { }
public HealthAgentDamageArgs(IHealthAgent victim, IHealthAgent agressor, int amount) { Victim = victim; Agressor = agressor; Amount = amount; }