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); } }
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); } }
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); } }