Exemplo n.º 1
0
 public void AddItem(ObtanableItem item, int AmountToAdd)
 {
     while (AmountToAdd > 0)
     {
         if (InventoryList.Exists(listItem => (listItem.Item.ID == item.ID) && (listItem.ItemAmount < item.StackableAmount)))
         {
             InventoryItem invetoryList        = InventoryList.First(listItem => (listItem.Item.ID == item.ID) && (listItem.ItemAmount < item.StackableAmount));
             int           MaxAmountPerStack   = (item.StackableAmount - invetoryList.ItemAmount);
             int           AmountToAddPerStack = Math.Min(AmountToAdd, MaxAmountPerStack);
             invetoryList.AddToAmount(AmountToAddPerStack);
             AmountToAdd -= AmountToAddPerStack;
         }
         else
         {
             if (InventoryList.Count < MaxSlotsInInventory)
             {
                 InventoryList.Add(new InventoryItem(item, 0));
             }
             else
             {
                 throw new Exception("You Are Out Of Inventory Space");
             }
         }
     }
 }
Exemplo n.º 2
0
 public int Count(ObtanableItem item)
 {
     return(InventoryList.Find(x => x.ID == item.ID).ItemAmount);
 }
Exemplo n.º 3
0
 public InventoryItem(ObtanableItem item, int Amount)
 {
     Item       = item;
     ItemAmount = Amount;
 }