예제 #1
0
        /// <summary>
        /// Sells an inventory item to the currently open shop.
        /// </summary>
        /// <param name="slot">The slot of the item to sell.</param>
        /// <param name="guiManager">The <see cref="IGUIManager"/> to use to create the <see cref="InputBox"/> if it is needed.</param>
        public void SellToShop(InventorySlot slot, IGUIManager guiManager)
        {
            // Check for a valid item
            var item = this[slot];

            if (item == null)
            {
                return;
            }

            // Check the amount
            if (item.Amount > 1)
            {
                // Create an InputBox to ask how much to drop
                const string text    = "Sell item";
                const string message = "How much of the item do you wish to sell?\n(Enter a value from 1 to {0})";

                var inBox = InputBox.CreateNumericInputBox(guiManager, text, string.Format(message, item.Amount));
                inBox.Tag             = slot;
                inBox.OptionSelected += SellToShopInputBox_OptionSelected;
            }
            else
            {
                // Auto-drop if there is just one of the item
                SellToShop(slot, 1);
            }
        }
예제 #2
0
        /// <summary>
        /// Adds an inventory item to the currently open trade.
        /// </summary>
        /// <param name="slot">The slot of the item to add to the trade.</param>
        public void AddToTrade(InventorySlot slot)
        {
            if (UserInfo == null)
            {
                return;
            }

            // Check for a valid item
            var item = UserInfo.Inventory[slot];

            if (item == null)
            {
                return;
            }

            // Check the amount
            if (item.Amount > 1)
            {
                // Create an InputBox to ask how much to drop
                const string text    = "Add item";
                const string message = "How much of the item do you wish to add to the trade?\n(Enter a value from 1 to {0})";

                var inBox = InputBox.CreateNumericInputBox(GUIManager, text, string.Format(message, item.Amount));
                inBox.Tag             = slot;
                inBox.OptionSelected += AddToTradeInputBox_OptionSelected;
            }
            else
            {
                // Auto-drop if there is just one of the item
                AddToTrade(slot, 1);
            }
        }