public void Reset() { for (var i = 0; i < GetSlots.Length; i++) { GetSlots.ElementAt(i).item.Id = -1; GetSlots.ElementAt(i).item.Name = ""; GetSlots.ElementAt(i).amount = 0; GetSlots.ElementAt(i).item.level = 0; GetSlots.ElementAt(i).item.price = 0; } }
/// <summary> /// Checks and returns if the specified items are in the inventory. /// </summary> /// <param name="itemsToFind">Items we are looking for</param> /// <param name="amount">Their amount</param> /// <returns>If there are enough of each items that we are looking for in the inventory</returns> public bool CheckItemInInventory(ItemObject[] itemsToFind, int amount) { return(itemsToFind.Select((t, i) => GetSlots.ElementAt(i).item.Id.Equals(t.data.Id) && GetSlots.ElementAt(i).amount.Equals(amount)).FirstOrDefault()); }
/// <summary> /// Checks and returns if the specified item and amount are in the inventory. /// </summary> /// <param name="itemToFind">Item that we are looking for</param> /// <param name="amount">Amount of this item</param> /// <returns>If there are enough amount of items we are looking for in the inventory</returns> public bool CheckItemInInventory(ItemObject itemToFind, int amount) { return(GetSlots.Any(t => t.item.Id == itemToFind.data.Id && t.amount == amount)); }
/// <summary> /// Checks and returns if the specified item is in the inventory regardless of the amount. /// </summary> /// <param name="itemToFind">Item that we are looking for</param> /// <returns>If the item is in the inventory</returns> public bool CheckItemInInventory(ItemObject itemToFind) { /*return GetSlots.Where((t, i) => GetSlots.ElementAt(i).item.Id == itemToFind.data.Id).Any();*/ return(GetSlots.Any(t => t.item.Id == itemToFind.data.Id)); }
/// <summary> /// Finds the Item on the InventorySlot /// </summary> /// <param name="item">Item that should be found</param> /// <returns>Item that we are looking for</returns> private InventorySlot FindItemOnInventory(Item item) { return(GetSlots.FirstOrDefault(t => t.item.Id == item.Id)); }
/// <summary> /// Finds the Item on the InventorySlot /// </summary> /// <param name="itemObject">Item that should be found</param> /// <returns>Item that we are looking for</returns> public InventorySlot FindItemOnInventorySlot(ItemObject itemObject) { return(GetSlots.FirstOrDefault(t => t.item.Id == itemObject.data.Id)); }