コード例 #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);
        }
    }
コード例 #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);
        }
    }
コード例 #3
0
    public void SwtichItemFromInventory()
    {
        GameObject inventoryItem = inventoryComponent.GetItemFromInventory();

        if (!inventoryItem)
        {
            return;
        }

        GameObject equippedItem = equipperComponent.GetEquippedItem();

        if (!equippedItem)
        {
            equipperComponent.SetEquippedItem(inventoryItem);
        }
        else
        {
            equippedItem.gameObject.layer = LayerMask.NameToLayer("Item");
            inventoryComponent.AddToInventory(equippedItem);
            equipperComponent.SetEquippedItem(inventoryItem);
        }
    }