示例#1
0
 /// <summary>
 /// Determine whether the door key matches the door
 /// </summary>
 /// <param name="key">the door key that may match the door</param>
 /// <returns>whether the door key and door have the same code</returns>
 public bool DoesDoorKeyMatch(DoorKey key)
 {
     if (key.Code == Code)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#2
0
 /// <summary>
 /// A hero applies an item
 /// </summary>
 /// <param name="item">an item the hero obtained</param>
 /// <returns>an item or no item</returns>
 public Item HeroAppliesItem(Item item)
 {
     // If a potion, the hero is healed and an item is not returned.
     if (item.GetType() == typeof(Potion))
     {
         this.Healed(item.AffectValue);
         return(null);
     } // if a weapon, equip the hero with the weapon and drop the previous weapon
     else if (item.GetType() == typeof(Weapon))
     {
         Weapon temp = EquippedWeapon;
         EquippedWeapon = (Weapon)item;
         if (temp == null)
         {
             return(null);
         }
         else
         {
             return(temp);
         }
     } // if a door key, equip the hero with a door key and dorm the previous key
     else if (item.GetType() == typeof(DoorKey))
     {
         DoorKey temp = EquippedDoorKey;
         EquippedDoorKey = (DoorKey)item;
         if (temp == null)
         {
             return(null);
         }
         else
         {
             return(temp);
         }
     } // if any other type, return the item
     else
     {
         return(item);
     }
 }