Exemple #1
0
        public void CheckCraftableAmount(Inventory recipeInv)
        {
            for (int i = 0; i < recipeInv.items.Length; ++i)
            {
                if (recipeInv.items[i] == null)
                {
                    continue;
                }
                ItemRecipe recipe      = recipeInv.items[i].item as ItemRecipe;
                int        craftableCt = 999;

                for (int j = 0; j < recipe.ingredients.Count; ++j)
                {
                    int amount = inventoryManager.mainInventory.GetItemTotalAmount(recipe.ingredients[j].item);

                    if (recipe.ingredients[j].amount < 1)
                    {
                        Debug.LogError("Ingred req less than 1");
                        continue;
                    }
                    int temp = amount / recipe.ingredients[j].amount;
                    if (temp < craftableCt)
                    {
                        craftableCt = temp;
                    }
                }
                recipeInv.RemoveItemAmount(recipeInv.items[i].item, recipeInv.items[i].amount);
                recipeInv.AddItemAmount(recipeInv.items[i].item, craftableCt, false);
            }
        }
Exemple #2
0
        public void CompleteTransaction(int amount)
        {
            ItemSlotHandler from = fromSlot.slotManager;
            ItemSlotHandler to;
            bool            monetary = false;

            if (toSlot)
            {
                to = toSlot.slotManager;
            }
            else if (from == bagSlotManager || from == characterSlotManager)
            {
                to = currTransferSlots;
            }
            else if (from == shopSlotManager && inCharacter)
            {
                to = characterSlotManager;
            }
            else
            {
                to = bagSlotManager;
            }

            if (inShop)
            {
                monetary = true;
            }

            if (inCraft && fromSlot.item.item is ItemRecipe)
            {
                if (craftSlotManager.inventory.totalItemsList.Count > 0)
                {
                    Inventory.Transfer(craftSlotManager.inventory, mainInventory, craftSlotManager.inventory.totalItemsList);
                }

                ItemRecipe recipe = fromSlot.item.item as ItemRecipe;
                for (int i = 0; i < recipe.ingredients.Count; ++i)
                {
                    Inventory.Transfer(bagSlotManager.inventory, craftSlotManager.inventory, recipe.ingredients[i].amount * amount, recipe.ingredients[i].item);
                }
                recipeSlotManager.inventory.RemoveItemAmount(fromSlot.item.item, amount, true);
            }
            else
            {
                Inventory.Transfer(from.inventory, to.inventory, amount, fromSlot.item.item, monetary);
            }
            fromSlot = null;
            toSlot   = null;
        }
Exemple #3
0
        int CheckRecipeCraftable(ItemRecipe recipe)
        {
            int count = 999;

            for (int j = 0; j < recipe.ingredients.Count; ++j)
            {
                // int amount = inventoryManager.mainInventory.GetItemTotalAmount(recipe.ingredients[j].item);
                int amount = currCraftInv.GetItemTotalAmount(recipe.ingredients[j].item);

                if (recipe.ingredients[j].amount < 1)
                {
                    Debug.LogError("Ingred req less than 1");
                    continue;
                }
                int temp = amount / recipe.ingredients[j].amount;
                if (temp < count)
                {
                    count = temp;
                }
            }

            return(count);
        }