Пример #1
0
 public static void AddToInventory(Inventory inventory, ItemAmount itemAmount)
 {
     for (int i = 0; i < inventory.inventoryList.Count; i++)
     {
         if (inventory.inventoryList[i].itemType.typeName == itemAmount.itemType.typeName)
         {
             inventory.inventoryList[i].amount += itemAmount.amount;
             return;
         }
     }
     inventory.inventoryList.Add(itemAmount);
 }
Пример #2
0
        public static bool RemoveFromInventory(Inventory inventory, ItemAmount itemAmount)
        {
            int index = IndexOfItemInInventory(inventory, itemAmount.itemType);

            if (index != 0 && inventory.inventoryList[index].amount >= itemAmount.amount)
            {
                inventory.inventoryList[index].amount -= itemAmount.amount;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
 internal void Add(ItemAmount itemAmount)
 {
     if (Materials == null)
     {
         Materials    = new ItemAmount[1];
         Materials[0] = itemAmount;
     }
     else
     {
         for (int i = 0; i < Materials.Length; i++)
         {
             if (Materials[i].itemType.typeName == itemAmount.itemType.typeName)
             {
                 Materials[i].AddAmount(itemAmount.amount);
             }
         }
     }
 }
Пример #4
0
 public static bool TransferItemsBetweenInventories(Inventory from, Inventory to, ItemAmount items)
 {
     if (RemoveFromInventory(from, items))
     {
         AddToInventory(to, items);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #5
0
        void AddItemsToRecipe(ItemAmount itemAmount, int itemIndex)
        {
            ItemType itemType = allItems[itemIndex];

            itemType.recipe.Add(itemAmount);
        }