Example #1
0
 /// <summary>
 /// Performs a basic damage calculation
 /// </summary>
 /// <param name="damage"></param>
 /// <returns></returns>
 public float TakeDamage(int damage)
 {
     // Calculates % of damage that will still go through, and reduces current health by that amount
     currentHealth -= damage;
     // If this object has health less than or equal to zero, mark it as dead
     if (currentHealth <= 0)
     {
         active = false;
         // trigger the on-death event
         Random random = new Random();
         bank.Deposit(random.Next(5, 10));
     }
     return(currentHealth - damage);
 }
Example #2
0
 public void RepairOrDestroy(MouseState mouse, bool repair)
 {
     if (repair && (mouse.LeftButton == ButtonState.Pressed) && rectangle.Contains(mouse.Position))
     {
         if (bank.Purchase(25))
         {
             currentHealth = maxHealth;
             active        = true;
         }
     }
     if (!repair && (mouse.LeftButton == ButtonState.Pressed) && rectangle.Contains(mouse.Position))
     {
         map.removeTurret(row, col);
         bank.Deposit(50);
     }
 }