Beispiel #1
0
 // (Optional) Change the last function to accept any object and just make sure it is of type Human before applying damage. Hint you may need to refer back to the Boxing/Unboxing tab!
 public Human Attack(object attackTarget)
 {
     if (attackTarget is Human)
     {
         Human temp = attackTarget as Human;
         temp.health -= 5 * strength;
         temp.displayInfo();
     }
     else
     {
         Console.WriteLine("You can only attack humans!");
     }
     return(this);
 }
Beispiel #2
0
 //deal 20 - 50 damage to target
 public Wizard Fireball(object fireballTarget)
 {
     if (fireballTarget is Human)
     {
         Random rand   = new Random();
         int    damage = rand.Next(20, 51);
         Console.WriteLine("fireball damage: {0}", damage);
         Human temp = (Human)fireballTarget;
         temp.health -= damage;
         temp.displayInfo();
     }
     else
     {
         Console.WriteLine("You can only fireball humans!");
     }
     return(this);
 }