예제 #1
0
        /// <summary>
        /// Applies an item to the hero.
        /// </summary>
        /// <param name="item">Item to apply.</param>
        /// <returns>Null if potion or there was no previously equipped item. The previously equipped item is returned if not null.</returns>
        public Item ApplyItem(Item item)
        {
            Item previouslyEquippedItem;

            if (item.GetType() == typeof(Potion))
            {
                this.GainHitPoints(item.Value);
                return(null);
            }
            else if (item.GetType() == typeof(Weapon))
            {
                previouslyEquippedItem = _EquippedWeapon;
                _EquippedWeapon        = (Weapon)item;
                return(previouslyEquippedItem);
            }
            else if (item.GetType() == typeof(DoorKey))
            {
                previouslyEquippedItem = _DoorKey;
                _DoorKey = (DoorKey)item;
                return(previouslyEquippedItem);
            }
            else
            {
                return(item);
            }
        }
예제 #2
0
 /// <summary>
 /// Checks if the doorkey passed in matches the door.
 /// </summary>
 /// <param name="doorKey">Door key to be checked against the door.</param>
 /// <returns>Bool indicating if the door and door key code match.</returns>
 public bool CheckDoorKey(DoorKey doorKey)
 {
     if (this.Code == doorKey.Code)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }