Exemplo n.º 1
0
        //takes item out of inventory

        /*public void Drop(string itemName)
         * {
         *  IItem item = Take(itemName);
         *  if (item != null)
         *  {
         *      CurrentRoom.Drop(item);
         *      OutputMessage("\n" + itemName + " has been dropped");
         *  }
         *  else
         *  {
         *      OutputMessage("\nThe item named " + itemName + " is not in your inventory.");
         *  }
         * }*/

        //adds item to inventory
        public void PickUp(string itemName)
        {
            IItem item = CurrentRoom.Pickup(itemName);

            if (item != null)
            {
                //checks if the items weight is over the bag capacity
                if ((item.Weight + Bag.WeightInBag()) >= Bag.Capacity)
                {
                    OutputMessage("This is to heavy to pick up");
                    CurrentRoom.Drop(item);
                }
                else
                {
                    //checks if the item is too large to be picked up
                    if (item.Volume > Bag.VolumeCapacity)
                    {
                        OutputMessage("This item is to big to carry");
                        CurrentRoom.Drop(item);
                    }
                    else
                    {
                        Give(item);
                        OutputMessage("\n" + itemName + " has been picked up");
                        Notification notification = new Notification("FoundKey", this);
                        NotificationCenter.Instance.PostNotification(notification);
                    }
                }
            }
            else
            {
                CurrentRoom.Drop(item);
                OutputMessage("\nThe item named " + itemName + " is not in the room.");
            }
        }
Exemplo n.º 2
0
        public void Inspect(string itemName)
        {
            IItem item = CurrentRoom.Pickup(itemName);

            if (item != null)
            {
                OutputMessage("\nCurrent item:  " + item.Description);
                CurrentRoom.Drop(item);
            }
            else
            {
                OutputMessage("\nThe item '" + itemName + "' is not in the room.");
            }
        }