public void AddIngredient(Ingredient.EnglishName ingredient) { if (!coreComplete) { GetComponent <AudioSource>().clip = addingIngredientClip; GetComponent <AudioSource>().Play(); for (int i = 0; i < recipesRemaining.Count; i++) { Recipe recipe = recipesRemaining[i]; if (!recipe.ContainsIngredient(ingredient)) { Debug.LogFormat("Recipe {0} did not contain {1}!", recipe.name, ingredient.ToString()); recipesRemaining.Remove(recipe); i--; } else { Debug.LogFormat("Recipe {0} contained ingredient {1}!", recipe.name, ingredient.ToString()); } } if (recipesRemaining.Count <= 0) { GameObject.Instantiate(RecipeController.instance.trashPrefab); DestroyActiveIngredients(); recipesRemaining.Clear(); recipesRemaining = new List <Recipe>(RecipeController.instance.recipes); Debug.LogFormat("No recipes remaining, producing trash."); return; } if (!addedIngredients.Contains(ingredient)) { addedIngredients.Add(ingredient); } CheckRemainingRecipes(); } else { // First, we have to check to make sure this ingredient is an additional ingredient foreach (Ingredient additionalIngredient in RecipeController.instance.allIngredients) { if (additionalIngredient.name == ingredient && additionalIngredient.isAdditionalIngredient) { additionalIngredients.Add(additionalIngredient); } } } }
public Object GetIngredientPrefab(Ingredient.EnglishName ingredientToGet) { foreach (Ingredient ingredient in allIngredients) { if (ingredient.name == ingredientToGet) { return(ingredient.prefab); } } return(null); }
public bool ContainsIngredient(Ingredient.EnglishName ingredientToCheck) { foreach (Ingredient.EnglishName ingredient in coreIngredients) { if (ingredientToCheck == ingredient) { return(true); } } return(false); }