예제 #1
0
        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));
        }
예제 #2
0
 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;
 }
예제 #3
0
 public HealthAgentDeathArgs(IHealthAgent victim, IHealthAgent agressor, int damage)
 {
     Victim   = victim;
     Agressor = agressor;
     Damage   = damage;
 }
예제 #4
0
 /// <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)
 {
 }
예제 #5
0
 public HealthAgentDamageArgs(IHealthAgent victim, IHealthAgent agressor, int amount)
 {
     Victim   = victim;
     Agressor = agressor;
     Amount   = amount;
 }