/// <summary> /// Find an available slot in a specified inventory /// </summary> /// <returns>Available slot or null</returns> public InventorySlot FindAvailableSlot(InventoryObject inventory) { foreach (var slot in inventory.container.Slots) { if (ItemNotInDB(slot)) { return(slot); } } return(null); }
/// <summary> /// Checks if the inventory specified has the item specified in it and the correct amount of that item, returns that item /// </summary> /// <param name="inventory">Reference to the inventory we should look for</param> /// <param name="itemToFind">Item we are looking for</param> /// <param name="amount">Amount of the item we are looking for</param> /// <returns>Item that was requested in parameter or null</returns> public ItemObject FindItemInInventory(InventoryObject inventory, ItemObject itemToFind, int amount) { for (var i = 0; i < inventory.container.Slots.Length; i++) { if (inventory.container.Slots.ElementAt(i).item.Id.Equals(itemToFind.data.Id) && inventory.container.Slots.ElementAt(i).amount.Equals(amount)) { return(inventory.container.Slots.ElementAt(i).ItemObject); } } return(null); }