Example #1
0
        /// <summary>
        /// Apply Item to Hero
        /// </summary>
        /// <param name="newItem">Item to Apply to Hero</param>
        /// <returns>Item that hero needs to discard.</returns>
        public Item Apply(Item newItem)
        {
            Item retItem = null;

            if (newItem.GetType() == typeof(Potion))
            {
                this.HealMe(newItem.AffectValue);
            }
            else if (newItem.GetType() == typeof(Weapon))
            {
                retItem         = _EquippedWeapon;
                _EquippedWeapon = (Weapon)newItem;
            }
            else if (newItem.GetType() == typeof(DoorKey))
            {
                retItem = _Key;
                _Key    = (DoorKey)newItem;
            }
            else
            {
                retItem = newItem;
            }
            return(retItem);
        }
Example #2
0
 /// <summary>
 /// Applies item to hero
 /// </summary>
 /// <param name="newItemApplied"></param>
 /// <returns>The new weapon or item applied</returns>
 //Citation: https://msdn.microsoft.com/en-us/library/scekt9xw.aspx
 //Citation: https://msdn.microsoft.com/en-us/library/ms173105.aspx
 public Item ApplyItem(Item newItemApplied)
 {
     if (newItemApplied is Potion)
     {
         _CurrentHitPoints = _CurrentHitPoints + newItemApplied.AffectValue;
         if (_CurrentHitPoints > _MaximumHitPoints)
         {
             _CurrentHitPoints = _MaximumHitPoints;
         }
         return(null);
     }
     else if (newItemApplied is Weapon)
     {
         Item tempWeapon = newItemApplied;
         if (_Weapon != null)
         {
             _Weapon = (Weapon)newItemApplied;
             return(tempWeapon);
         }
         else
         {
             _Weapon = (Weapon)newItemApplied;
             return(null);
         }
     }
     else if (newItemApplied is DoorKey)
     {
         Item tempDoorKey = newItemApplied;
         _HasDoorKey = (DoorKey)newItemApplied;
         return(tempDoorKey);
     }
     else
     {
         return(newItemApplied);
     }
 }
Example #3
0
 /// <summary>
 /// Check if a given key matches this door
 /// </summary>
 /// <param name="key">key to check against this door</param>
 /// <returns>true if the key code matches the door code. False otherwise.</returns>
 public bool isMatch(DoorKey key)
 {
     return(key.Code == _Code);
 }