Esempio n. 1
0
 // ends game and opens game over screen
 public void EndGameFunct()
 {
     foreach (EnemyControllerScript e in spawnedEnemyList)
     {
         e.gameObject.SetActive(false);
     }
     wavePhase = EWavePhase.EGameOver;
     uiCtrl.ShowGameOverScreen();
 }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        // behavior based on state
        if (wavePhase == EWavePhase.ECombat)
        {
            // gets enemies from the pool and activates them
            if (spawnedEnemyList.Count <= waveSpawnCount + waveNumber)
            {
                if (lastSpawnTime + spawnDelay < Time.time)
                {
                    SpawnEnemyFromPool();
                    enemySpawnCount += 1;
                    lastSpawnTime    = Time.time;
                }
            }
            // ends wave if there is no active enemies
            if (enemySpawnCount == 0)
            {
                wavePhase = EWavePhase.EEndWave;
            }
            UpdateHUD();

            // ends game if the player health is 0
            if (playerCtrl.playerHealth == 0)
            {
                EndGameFunct();
            }
        }
        else if (wavePhase == EWavePhase.EPreparation)
        {
            //checks if the player has selected turret build plot and activates build menu accordingly
            if (playerCtrl.selectedTurret != null)
            {
                if (playerCtrl.selectedTurret.TurretPhase == TurretScript.ETurretPhase.EPlot)
                {
                    uiCtrl.OpenBuildMenu();
                }
                else
                {
                    uiCtrl.CloseBuildMenu();
                }
            }
            else
            {
                if (uiCtrl.buildMenu.activeInHierarchy)
                {
                    uiCtrl.CloseBuildMenu();
                }
            }
            UpdateHUD();
        }
        else if (wavePhase == EWavePhase.EEndWave)
        {
            // check if the wave count is above 20 and ends game or
            // starts another wave
            if (waveNumber < 20)
            {
                spawnedEnemyList.Clear();
                waveNumber += 1;
                UpdateHUD();
                wavePhase = EWavePhase.EPreparation;
                uiCtrl.PreparationPhase();
            }
            else
            {
                EndGameFunct();
            }
        }
    }