Example #1
0
        /// <summary>
        /// Pick up an item if there is one in this square
        /// </summary>
        /// <returns></returns>
        private bool PickUpItem()
        {
            Dungeon dungeon = Game.Dungeon;
            Player  player  = dungeon.Player;

            Item itemToPickUp = dungeon.ItemAtSpace(player.LocationLevel, player.LocationMap);

            if (itemToPickUp == null)
            {
                return(false);
            }

            //Add item to PC inventory
            player.Inventory.AddItem(itemToPickUp);

            //Message
            Game.MessageQueue.AddMessage(itemToPickUp.SingleItemDescription + " picked up.");

            return(true);
        }
Example #2
0
        /// <summary>
        /// Drop an item from inventory
        /// </summary>
        /// <returns></returns>
        private bool DropItem()
        {
            //User selects which item to use
            int chosenIndex = PlayerChooseFromInventory();

            //Player exited
            if (chosenIndex == -1)
            {
                return(false);
            }

            Dungeon dungeon = Game.Dungeon;
            Player  player  = dungeon.Player;

            Inventory playerInventory = player.Inventory;

            InventoryListing selectedGroup = playerInventory.InventoryListing[chosenIndex];
            Item             selectedItem  = playerInventory.Items[selectedGroup.ItemIndex[0]];

            //Check there is no item here already
            if (dungeon.ItemAtSpace(player.LocationLevel, player.LocationMap) != null)
            {
                Game.MessageQueue.AddMessage("Can't drop - already an item here!");
                return(false);
            }

            //Remove from player inventory
            playerInventory.RemoveItem(selectedItem);

            //Drop the item here
            selectedItem.InInventory   = false;
            selectedItem.LocationLevel = player.LocationLevel;
            selectedItem.LocationMap   = player.LocationMap;

            Game.MessageQueue.AddMessage(selectedItem.SingleItemDescription + " dropped.");

            return(true);
        }