SpawnWave() private method

private SpawnWave ( Wave, _wave ) : IEnumerator
_wave Wave,
return IEnumerator
Exemplo n.º 1
0
    public IEnumerator RespawnPlayer_WatchedAd()
    {
        // hide gameover UI
        anim.SetTrigger("hideGameOver");
        // add 20 health to new player TO:DO extract health to zero add 20
        PlayerHealth.playerWatchedAD_extraChance = true;
        // move player position
        currentPlayer.transform.position = respawnPosition.position;
        currentPlayer.transform.rotation = respawnPosition.rotation;
        // show effect of respawn --> shoot&choose asset
        GameObject go = spawnEffect_FX;

        go.transform.localScale = new Vector3(3, 3, 3);
        Instantiate(go, respawnPosition.position, respawnPosition.rotation);
        Destroy(go, 4f);

        //restart current reached wave
        yield return(new WaitForSeconds(3f));

        currentPlayer.GetComponent <myThirdPersonController>().enabled = true;
        currentPlayer.GetComponent <Animator>().SetTrigger("backToLive");

        Debug.Log(lastWaveNumber() + " Last wave number");
        StartCoroutine(waveSpawner.SpawnWave(waveSpawner.waves[lastWaveNumber()]));
        //StartCoroutine(WaitAndSetAnimeBackToNormal());

        yield break;
    }
Exemplo n.º 2
0
    void NewWave()
    {
        waveSpawner.Clear();
        flash.DoFlash();

        waveSpawner.SpawnWave();
        Invoke("ClearWave", waveDuration);
        Invoke("NewWave", waveDuration + wavePause);
    }
Exemplo n.º 3
0
    void SpawnWave()
    {
        if (WaveNum >= _creepWavesCollection.CreepWaves.Count)
        {
            WaveNum = 0;
        }

        var currentWave = _creepWavesCollection.CreepWaves[WaveNum];

        _waveSpawner.SpawnWave(currentWave);
    }
Exemplo n.º 4
0
    private void Update()
    {
        var timeUntilThisWave = waveCount * timeBetweenWaves - (Time.time - startTime);

        if (timeUntilThisWave < displayInAdvance)
        {
            var wave        = waveSpawner.GetWave(waveCount);
            var waveDisplay = new Wave(monsterAssets[wave.Enemies.First().monsterType], wave.Enemies.First().Count, timeUntilThisWave);
            var display     = waveDisplayCtrl.AddWaveEntry(waveDisplay);
            display.SpawnWave += () => StartCoroutine(waveSpawner.SpawnWave(wave));
            ++waveCount;
        }
    }
Exemplo n.º 5
0
 // Advance to the next wave
 void NextWave()
 {
     if (wave != null)
     {
         Debug.Log("Advancing to the next wave");
         StartCoroutine(wave.SpawnWave());
         GetComponent <Canvas>().enabled = false;
     }
     else
     {
         Debug.Log("Could not open pane; null reference \'paneToOpen\'");
     }
 }
    void Update()
    {
        if (waveIndex < lastwave)
        {
            if (countdown <= 0f)
            {
                waveIndex++;
                UIController.SetWaveCounterText(waveIndex);
                StartCoroutine(WaveSpawner.SpawnWave(waveIndex));
                countdown = timeBetweenWaves;
            }

            countdown -= Time.deltaTime;
            UIController.SetwaveCountdownText(Mathf.Round(countdown));
        }
        else
        {
            GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
            if (enemies == null || enemies.Length == 0)
            {
                SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 2);
            }
        }
    }
    /// <summary>
    /// Within every frame the game manager checks the state of the game
    /// and delegates the actions to the other controllers.
    /// </summary>
    /// <exception cref="ArgumentOutOfRangeException">Thrown when the gamestate is not a value from the enum</exception>
    private void Update()
    {
        switch (gameState)
        {
        case GameState.Init:
            break;

        case GameState.Running:
            _uiController.HideTowerPanel();
            _uiController.HideGameOverUi();
            _uiController.HideTowerPanel();
            UpdateUI();

            if (enemiesAlive <= 0)
            {
                if (_countdownWave <= 0f)
                {
                    // Call subprocess
                    Wave wave = waves[_waveIndex];
                    StartCoroutine(_waveSpawner.SpawnWave(wave, gameMode));

                    _waveIndex++;
                    _countdownWave = timeBetweenWaves;
                }
                else if (_waveIndex >= waves.Length)
                {
                    gameState = GameState.Finished;
                    break;
                }

                _waveRunning    = false;
                _countdownWave -= Time.deltaTime;
            }
            else
            {
                _waveRunning = true;
            }

            break;

        case GameState.GameOver:
            _uiController.ShowGameOverUi(_waveIndex);

            enabled        = false;
            Time.timeScale = 0.25f;
            break;

        case GameState.Finished:
            _uiController.ShowGameOverUi(_waveIndex);

            _uiController.gameOverText.text     = "Finished";
            _uiController.gameOverText.enabled  = true;
            _uiController.lifeCountText.enabled = false;

            enabled        = false;
            Time.timeScale = 0.25f;
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }