// Update is called once per frame void Update() { if (computeAllergies && inRange) { isAllergic = (gameObject.GetComponent <IngredientDisplay>() && player.GetAllergie() == gameObject.GetComponent <IngredientDisplay>().ingredient.name || gameObject.GetComponent <DishDisplay>() && CheckDishAllergie()); computeAllergies = false; //Debug.Log("is Allergic " + isAllergic); } if (Input.GetKeyDown("space") && inRange) // if the player hit space and the food is in range, destroy the food { isEaten = true; //Debug.Log("Eating"); if (isAllergic) { score.ResetEatStreak(); score.AddScore(-100); player.ChangeHumor("puke"); } else if (gameObject.GetComponent <IngredientDisplay>()) { score.AddEatStreak(); score.AddScore(gameObject.GetComponent <IngredientDisplay>().ingredient.getPoints()); player.ChangeHumor("happy"); player.AddCountFood(gameObject.GetComponent <IngredientDisplay>().ingredient.name); } else if (gameObject.GetComponent <DishDisplay>()) { score.AddEatStreak(); score.AddScore(gameObject.GetComponent <DishDisplay>().dish.getPoints()); player.ChangeHumor("happy"); for (int i = 0; i < gameObject.GetComponent <DishDisplay>().dish.ingredients.Count; i++) { player.AddCountFood(gameObject.GetComponent <DishDisplay>().dish.ingredients[i].name); } } if (score.GetScore() < 0) { player.EndGame(); } Destroy(gameObject); player.ResetFail(); } }