public Ingredient TryCombineIngredients(List <Ingredient> ingredients) { /* Iterate through all possible recipes */ for (int r = 0; r < allRecipes.recipes.Length; r++) { RecipeDescription recipe = allRecipes.recipes[r]; bool allIngredientsMatch = false; /* Check whether ingredients and recipe criteria list match in length */ if (recipe.ingredients.Length == ingredients.Count) { /* Assume all ingredients match to begin */ allIngredientsMatch = true; /* Iterate through all recipe criteria, assuming the criteria is not met */ for (int j = 0; j < recipe.ingredients.Length; j++) { bool criteriaMatched = false; /* Iterate through all input ingredients, testing whether any of them match the criteria */ for (int k = 0; k < ingredients.Count; k++) { if (MatchesCriteria(ingredients[k], recipe.ingredients[j])) { criteriaMatched = true; } } /* If no ingredients match the criteria, the recipe is not met */ if (!criteriaMatched) { allIngredientsMatch = false; } } } /* If a recipe is met, return the combined ingredient */ if (allIngredientsMatch) { return(new Ingredient(recipe.name, recipe.name + "Prefab")); } } /* Return mush if no matching recipe is found */ return(new Ingredient("mush", "mushPrefab")); }
public void bool_timer() { for (int i = 0; i < RecipeContent.transform.childCount; i++) { RecipeDescription Recipe = RecipeContent.transform.GetChild(i).GetComponent <RecipeDescription>(); if (Recipe.Selected) { if (Recipe.eCount1 < Recipe.nCount1 && Recipe.eCount2 < Recipe.nCount2) { Debug.Log("Мало ресурсов"); } else if (Recipe.eCount1 >= Recipe.nCount1 && Recipe.eCount2 >= Recipe.nCount2) { TimerOn = true; } } } }