Example #1
0
 internal void Attack(Direction direction, Random random)
 {
     if (equippedWeapon != null)
     {
         if (equippedWeapon is IPotion)
         {
             if (equippedWeapon.Name == "Blue Potion")
             {
                 BluePotion currentWeapon = equippedWeapon as BluePotion;
                 currentWeapon.Attack(direction, random);
                 equippedWeapon = null;
             }
             else
             {
                 RedPotion currentWeapon = equippedWeapon as RedPotion;
                 currentWeapon.Attack(direction, random);
                 equippedWeapon = null;
             }
         }
         else
         {
             equippedWeapon.Attack(direction, random);
         }
     }
 }
Example #2
0
        public void Attack(Direction direction, Random random)
        {
            if (equippedWeapon != null)
            {
                switch (equippedWeapon.Name)
                {
                case "Sword":
                    Sword sword = (Sword)equippedWeapon;
                    sword.Attack(direction, random);
                    break;

                case "Bow":
                    Bow bow = (Bow)equippedWeapon;
                    bow.Attack(direction, random);
                    break;

                case "Mace":
                    Mace mace = (Mace)equippedWeapon;
                    mace.Attack(direction, random);
                    break;

                case "Blue Potion":
                    BluePotion bluePotion = (BluePotion)equippedWeapon;
                    bluePotion.Attack(direction, random);
                    break;

                case "Red Potion":
                    RedPotion redPotion = (RedPotion)equippedWeapon;
                    redPotion.Attack(direction, random);
                    break;
                }
            }
        }