public void AddItemToInventory(GameItem item) { Inventory.Add(item); OnPropertyChanged(nameof(Weapons)); if (Weapons != null) { foreach (Weapon weapon in Weapons) { Console.WriteLine($"The weapon {weapon.Name} is available"); } } else { Console.WriteLine("No weapons in Weapons"); } }
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)); }
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)); }
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)); }
public void AddItemToInventory(GameItem item) { Inventory.Add(item); OnPropertyChanged(nameof(Weapons)); }