private bool AddInventoryItem(pickUpItem item) { InventoryItem existing = items.Find(x => x.item.name == item.name); if (existing != null) { if (item.maxCount == 0 || existing.count < item.maxCount) { existing.count++; return(true); } else { return(false); } } else { items.Add(new InventoryItem(item, 1)); return(true); } }
public InventoryItem(pickUpItem i, int c) { item = i; count = c; }