public void RemoveItemFromInventory(GameItem item) { Inventory.Remove(item); GroupedInventoryItem groupedInventoryItemToRemove = item.IsUnique ? GroupedInventory.FirstOrDefault(gi => gi.Item == item) : GroupedInventory.FirstOrDefault(gi => gi.Item.ItemTypeID == item.ItemTypeID); if (groupedInventoryItemToRemove != null) { if (groupedInventoryItemToRemove.Quantity == 1) { GroupedInventory.Remove(groupedInventoryItemToRemove); } else { groupedInventoryItemToRemove.Quantity--; } } OnPropertyChanged(nameof(Weapons)); OnPropertyChanged(nameof(Potions)); }
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 GroupedInventoryItem(GameItem item, int quantity) { Item = item; Quantity = quantity; }
public void RemoveItemFromInventory(GameItem item) { Inventory.Remove(item); OnPropertyChanged(nameof(Weapons)); }
public void AddItemToInventory(GameItem item) { Inventory.Add(item); OnPropertyChanged(nameof(Weapons)); }
public void RemoveItemFromInventory(GameItem item) { Inventory.Remove(item); }
public void AddItemToInventory(GameItem item) { Inventory.Add(item); }
public GroupedInventoryItem(GameItem groupItem, int groupQuantity) { item = groupItem; quantity = groupQuantity; }
public Monster(int id, string name, string imageName, int dexterity, int maximumHitPoints, GameItem currentWeapon, int rewardExperiencePoints, int gold) : base(name, dexterity, maximumHitPoints, maximumHitPoints, gold) { ID = id; ImageName = imageName; CurrentWeapon = currentWeapon; RewardExperiencePoints = rewardExperiencePoints; }
public void RemoveItem(GameItem item) { _quickChoiceItems.Remove(item); item.IsInQuickChoose = false; }
List <GameItem> _quickChoiceItems = new List <GameItem>(); //LIFO public void InsertItem(GameItem item) { _quickChoiceItems.Add(item); item.IsInQuickChoose = true; }