示例#1
0
        public void RemoveItemFromInventory(Gameitem item)
        {
            Inventory.Remove(item);

            GroupedInventory itemToRemove =
                GroupedInventory.FirstOrDefault(gi => gi.Item == item);

            if (itemToRemove != null)
            {
                if (itemToRemove.Quantity == 1)
                {
                    GroupedInventory.Remove(itemToRemove);
                }
                else
                {
                    itemToRemove.Quantity--;
                }
            }
        }
示例#2
0
        public void RemoveItemFromInventory(Item item)
        {
            Inventory.Remove(item);
            InventoryItem inventoryItemToRemove = GroupedInventory.FirstOrDefault(gi => gi.GameItem == item);

            if (inventoryItemToRemove != null)
            {
                if (inventoryItemToRemove.Quantity == 1)
                {
                    GroupedInventory.Remove(inventoryItemToRemove);
                }
                else
                {
                    inventoryItemToRemove.Quantity--;
                }
            }
            OnPropertyChanged(nameof(Weapons));
            OnPropertyChanged(nameof(Armors));
            OnPropertyChanged(nameof(Gloves));
            OnPropertyChanged(nameof(Boots));
        }
示例#3
0
文件: Entity.cs 项目: dpnull/ConBox
        public void RemoveItemFromInventory(Item item)
        {
            Inventory.Remove(item);

            // Check if item is unique
            // If unique, return the exact matching item
            // If not unique, return first or default grouped item with same item id in it
            GroupedInventoryItem stackedItemToRemove = item.IsUnique ?
                                                       GroupedInventory.FirstOrDefault(gi => gi.Item == item) :
                                                       GroupedInventory.FirstOrDefault(gi => gi.Item.ID == item.ID);

            if (stackedItemToRemove != null)
            {
                if (stackedItemToRemove.Quantity == 1)
                {
                    GroupedInventory.Remove(stackedItemToRemove);
                }
                else
                {
                    stackedItemToRemove.Quantity--;
                }
            }
        }