Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (tower == null)
        {
            Game.SetGameover(true);
            Time.timeScale = 0;
        }

        if (Countdown.IsWaveTime())
        {
            if (enemies.IsAllDead())
            {
                portals.RemoveAll();
                Countdown.SetWaveTime(false);
                Game.IncreaseScore(10);
            }
        }
        else
        {
            Countdown.SetTimer(Countdown.GetTimer() + Time.deltaTime);
            if (Countdown.GetTimer() > COUNT_DOWN)
            {
                Countdown.SetWaveTime(true);
                Game.AddWaveNumber();

                // Spawn portals
                // NOTE: Must come before enemy spawn for getposition
                portals.SpawnPortals();

                // Update Enemy types based on waveNumber(static var in Game.cs)
                // Then Spawn enemies
                // enemies.UpdateEnemies();
                enemies.SpawnEnemies(portals.GetPositions());

                // Set back to original time
                Countdown.SetTimer(Countdown.GetTimer() - COUNT_DOWN);
            }
        }

        TechTree.Update();
    }