Exemple #1
0
    IEnumerator Start()
    {
        foreach(Round round in rounds)
        {
            countdownTimer.SetActive(false);
            yield return new WaitForSeconds(1.0f);

            countdownTimer.SetActive(true);
            StartCoroutine(Countdown(round.timeLimit));

            foreach (Dish dish in round.dishes)
            {
                Dish dishInstance = SpawnDish(dish);

                monstersRequired = dish.monsterSpawns.Length;
                monstersRemaining = monstersRequired;
                monsters = new List<Monster>();

                GameObject go = (GameObject)GameObject.Instantiate(dishInstance.dishPrefab.gameObject, foodSpawn.position, foodSpawn.rotation);
                currentDish = go.GetComponent<DishProgress>();

                foreach (MonsterSpawn monsterSpawn in dish.monsterSpawns)
                {
                    Monster monsterInstance = SpawnMonster(monsterSpawn);
                    monsters.Add(monsterInstance);
                    yield return new WaitForSeconds(0.05f);
                }

                while (true)
                {
                    if (currentDish != null)
                    {
                        float val = (((float)monstersRequired - monstersRemaining) / monstersRequired);
                        if (val > 0)
                            Debug.Log("Dish is "+val*100+"% complete", this);
                        currentDish.SetProgress(val);
                    }

                    if (monstersRemaining == 0)
                        break;

                    yield return new WaitForEndOfFrame();
                }

                //finishedDish.SetActive(true);

                yield return new WaitForSeconds(completeDelay);

                //finishedDish.SetActive(false);

                Destroy(dishInstance.gameObject);
                Destroy(currentDish.gameObject);
            }
        }

        GameOver();
    }
Exemple #2
0
    IEnumerator Start()
    {
        foreach (Round round in rounds)
        {
            countdownTimer.SetActive(false);
            yield return(new WaitForSeconds(1.0f));

            countdownTimer.SetActive(true);
            StartCoroutine(Countdown(round.timeLimit));

            foreach (Dish dish in round.dishes)
            {
                Dish dishInstance = SpawnDish(dish);

                monstersRequired  = dish.monsterSpawns.Length;
                monstersRemaining = monstersRequired;
                monsters          = new List <Monster>();

                GameObject go = (GameObject)GameObject.Instantiate(dishInstance.dishPrefab.gameObject, foodSpawn.position, foodSpawn.rotation);
                currentDish = go.GetComponent <DishProgress>();

                foreach (MonsterSpawn monsterSpawn in dish.monsterSpawns)
                {
                    Monster monsterInstance = SpawnMonster(monsterSpawn);
                    monsters.Add(monsterInstance);
                    yield return(new WaitForSeconds(0.05f));
                }

                while (true)
                {
                    if (currentDish != null)
                    {
                        float val = (((float)monstersRequired - monstersRemaining) / monstersRequired);
                        if (val > 0)
                        {
                            Debug.Log("Dish is " + val * 100 + "% complete", this);
                        }
                        currentDish.SetProgress(val);
                    }

                    if (monstersRemaining == 0)
                    {
                        break;
                    }

                    yield return(new WaitForEndOfFrame());
                }

                //finishedDish.SetActive(true);

                yield return(new WaitForSeconds(completeDelay));

                //finishedDish.SetActive(false);

                Destroy(dishInstance.gameObject);
                Destroy(currentDish.gameObject);
            }
        }

        GameOver();
    }