예제 #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");
             }
         }
     }
 }
예제 #2
0
 public int Count(ObtanableItem item)
 {
     return(InventoryList.Find(x => x.ID == item.ID).ItemAmount);
 }
예제 #3
0
 public InventoryItem(ObtanableItem item, int Amount)
 {
     Item       = item;
     ItemAmount = Amount;
 }