public void itemCollected(string itemName) { if (ingredientsDict.ContainsKey(itemName)) { ingredientsDict[itemName] = true; //display ingredients & state string ing = IngredientsToText(); recipeController = uiRecipe.GetComponent <UIRecipeController>(); GetComponent <AudioSource>().Play(); recipeController.ChangeText(ing); //check if all ingredients are collected bool collectedAllFlag = true; foreach (KeyValuePair <string, bool> entry in ingredientsDict) { if (entry.Value == false) { collectedAllFlag = false; } } if (collectedAllFlag) { allIngredientsCollected = true; showEndLevelMessage(); } } }
void Awake() { recipeController = uiRecipe.GetComponent <UIRecipeController>(); }