public void AddItemToInventory(GameItem item)
        {
            Inventory.Add(item);

            //if item is unique, we add it to grouped inventory with quantity of 1
            if (item.IsUnique)
            {
                GroupedInventory.Add(new GroupedInventoryItem(item, 1));
            }
            //if not unique
            else
            {
                //first check to see if it already exists in inventory
                if (!GroupedInventory.Any(gi => gi.Item.ItemTypeID == item.ItemTypeID))
                {
                    //if not, add it as groupedinventory item with quantity of 0, as we will increase quantity anyway always below
                    GroupedInventory.Add(new GroupedInventoryItem(item, 0));
                }

                GroupedInventory.First(gi => gi.Item.ItemTypeID == item.ItemTypeID).Quantity++;
            }

            OnPropertyChanged(nameof(Weapons));
            OnPropertyChanged(nameof(Consumables));
            OnPropertyChanged(nameof(HasConsumable));
        }
Beispiel #2
0
 public void AddItemToInventory(GameItem item)
 {
     Inventory.Add(item);
     if (item.IsUnique)
     {
         GroupedInventory.Add(new GroupedInventoryItem(item, 1));
     }
     else
     {
         if (!GroupedInventory.Any(gi => gi.Item.ItemTypeID == item.ItemTypeID))
         {
             GroupedInventory.Add(new GroupedInventoryItem(item, 0));
         }
         GroupedInventory.First(gi => gi.Item.ItemTypeID == item.ItemTypeID).Quantity++;
     }
     OnPropertyChanged(nameof(Weapons));
 }
Beispiel #3
0
        public void AddItemToInventory(GameItem item)
        {
            Inventory.Add(item);

            if (item.IsUnique)
            {
                // If the game item is unique, it is added in
                GroupedInventory.Add(new GroupedInventoryItem(item, 1));
            }
            else
            {
                if (!GroupedInventory.Any(gi => gi.Item.ItemTypeID == item.ItemTypeID))
                {
                    //if the game item isn't unique, it's added in too with a quantity of 0
                    GroupedInventory.Add(new GroupedInventoryItem(item, 0));
                }

                // non-uniques have their quantity increased by one
                GroupedInventory.First(gi => gi.Item.ItemTypeID == item.ItemTypeID).Quantity++;
            }

            OnPropertyChanged(nameof(Weapons));
        }
Beispiel #4
0
        public void AddItemToInventory(GameItem item)
        {
            Inventory.Add(item);

            //if item is unique, add a new groupedinventory item with quantity 1.
            if (item.IsUnique)
            {
                GroupedInventory.Add(new GroupedInventoryItem(item, 1));
            }
            else
            {
                //Check if this is the first one of this item that the player has
                if (!GroupedInventory.Any(gi => gi.Item.ItemTypeID == item.ItemTypeID))
                {
                    //quantity 0 because next line adds 1 to quantity
                    GroupedInventory.Add(new GroupedInventoryItem(item, 0));
                }

                GroupedInventory.First(gi => gi.Item.ItemTypeID == item.ItemTypeID).Quantity++;
            }

            OnPropertyChanged(nameof(Weapons));
        }