Example #1
0
 /// <summary>
 /// Damages and applies any registered buffs to the unit paramater.
 /// </summary>
 override internal void ApplyTo(LiveUnit u)
 {
     if (DoesAffect(u))
     {
         int insdamage = damage;
         base.ApplyTo(u);
         Random Crit = new Random();
         if (Crit.Next(100) <= Managers.UnitManager.Manager.activeUnit.critChance)
         {
             insdamage = (int)((damage * Managers.UnitManager.Manager.activeUnit.critDamage) / 100);
         }
         u.ApplyDamage(insdamage);
     }
 }
Example #2
0
 /// <summary>
 /// Apply damage to a unit's health.  If the position is null, nothing happens.  Throws IndexOutOfRangeException when the target location is OOB
 /// </summary>
 /// <param name="x">X position of the unit to damage</param>
 /// <param name="y">Y position of the unit to damage</param>
 /// <param name="damage">How much damage to deal to the target unit's health</param>
 public void DamageUnit(int x, int y, int damage)
 {
     if (Utils.InRange(0, this.width - 1, x) && Utils.InRange(0, this.height - 1, y))
     {
         LiveUnit thisUnit = this.Get(x, y);
         if (thisUnit != null)
         {
             thisUnit.ApplyDamage(damage);
         }
     }
     else
     {
         throw new IndexOutOfRangeException("Target position out of bounds");
     }
 }