Exemplo n.º 1
0
    public void CraftFromRecipe(int currentRecipeIndex)
    {
        int TempCheck = 0;
        InventoryComponent pInventory = cartComponent.GetComponent <InventoryComponent>();

        List <CollectibleComponent> itemsInInventory = new List <CollectibleComponent>();

        for (int i = 0; i < recipeList[currentRecipeIndex].ingredients.Length; i++)
        {
            if (pInventory.DoesItemExist(recipeList[currentRecipeIndex].ingredients[i].item))
            {
                int inventoryAmount = pInventory.GetItemFromInventory(recipeList[currentRecipeIndex].ingredients[i].item).amountOfItem;

                if (recipeList[currentRecipeIndex].ingredients[i].amount <= inventoryAmount)
                {
                    TempCheck++;
                }
            }
        }

        if (TempCheck >= recipeList[currentRecipeIndex].ingredients.Length)
        {
            for (int i = 0; i < recipeList[currentRecipeIndex].ingredients.Length; i++)
            {
                pInventory.GetItemFromInventory(recipeList[currentRecipeIndex].ingredients[i].item, recipeList[currentRecipeIndex].ingredients[i].amount, true);
            }
            CreateItem(recipeList[currentRecipeIndex].finalItem);
        }
    }
Exemplo n.º 2
0
    public bool CraftGotMaterials(int currentRecipeIndex)
    {
        int TempCheck = 0;
        InventoryComponent pInventory = cartComponent.GetComponent <InventoryComponent>();

        List <CollectibleComponent> itemsInInventory = new List <CollectibleComponent>();

        for (int i = 0; i < recipeList[currentRecipeIndex].ingredients.Length; i++)
        {
            if (pInventory.DoesItemExist(recipeList[currentRecipeIndex].ingredients[i].item))
            {
                int inventoryAmount = pInventory.GetItemFromInventory(recipeList[currentRecipeIndex].ingredients[i].item).amountOfItem;

                if (recipeList[currentRecipeIndex].ingredients[i].amount <= inventoryAmount)
                {
                    TempCheck++;
                }
            }
        }

        if (TempCheck >= recipeList[currentRecipeIndex].ingredients.Length)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }