示例#1
0
    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);
        }
    }
示例#2
0
 public InventoryItem(pickUpItem i, int c)
 {
     item  = i;
     count = c;
 }