void SpawnFood() { int goodFoodIndex = Random.Range(0, dishes.Count); GameObject newFood; int badFoodCount = 0; for (int i = 0; i < dishes.Count; ++i) { if (i == goodFoodIndex) { newFood = Instantiate(foodToMatch); newFood.name = foodToMatch.name; DishBehavior dish = dishes[goodFoodIndex].GetComponent <DishBehavior>(); newFood.GetComponent <Food>().Spawn(dish.top.transform, dish.bottom.transform); dishes[goodFoodIndex].SetFood(foodToMatch.GetComponent <Food>()); } else { newFood = Instantiate(activeBadFoods[badFoodCount]); newFood.name = foodToMatch.name; DishBehavior dish = dishes[i].GetComponent <DishBehavior>(); newFood.GetComponent <Food>().Spawn(dish.top.transform, dish.bottom.transform); dishes[i].SetFood(foodToMatch.GetComponent <Food>()); } } }
IEnumerator RevealDishes() { for (int i = 0; i < dishes.Count; ++i) { DishBehavior d = dishes [i]; Animation animation = d.GetComponent <DishBehavior> ().top.GetComponent <Animation> (); d.GetComponent <DishBehavior> ().top.GetComponent <Animation> ().Play(animation ["DishTopRevealLift"].name); } yield return(new WaitForSeconds(3.0f)); for (int j = 0; j < dishes.Count; ++j) { DishBehavior d = dishes [j]; Animation animation = d.GetComponent <DishBehavior> ().top.GetComponent <Animation> (); d.GetComponent <DishBehavior> ().top.GetComponent <Animation> ().Play(animation ["DishTopRevealClose"].name); } }