public void GiveItem(string itemSlug) { Item item = itemdatabase.GetItem(itemSlug); Debug.Log("Adding " + itemSlug + " -----------------------"); if (!playerItems.Contains(item) && item.ItemCount == 0) { playerItems.Add(item); Debug.Log(playerItems.Count + " items in inventory. Added: " + itemSlug); item.ItemCount++; // UIEventHandler.ItemAddedToInventory(item); // Old Panel Inventory Test UIEventHandler.ItemAddedToInventoryOrCount(item, false, false); // Doesn't count, adds the item container } else { item.ItemCount++; // Debug.Log(playerItems.Count + " items in inventory. Added: " + itemSlug); Debug.Log(item.ObjectSlug + " Count is : " + item.ItemCount); UIEventHandler.ItemAddedToInventoryOrCount(item, true, false); // Counts and update it via the UI } }
public void RemoveItem(string itemSlug) { Item item = itemdatabase.GetItem(itemSlug); if (playerItems.Contains(item)) { Debug.Log("Removing " + itemSlug + " -----------------------"); item.ItemCount--; Debug.Log(item.ObjectSlug + " Count is : " + item.ItemCount); UIEventHandler.ItemAddedToInventoryOrCount(item, true, false); if (item.ItemCount == 0) { playerItems.Remove(item); Debug.Log(playerItems.Count + " items in inventory. Removed: " + itemSlug); UIEventHandler.ItemAddedToInventoryOrCount(item, false, true); } } else { Debug.Log("playerItems does not have " + item.ItemName); } }