void WaveCompleted()
 {
     state = spawnState.COUNTING;
     round++;
     SetUI();
     waveCountdown = timeBetweenWaves;
 }
        void Update()
        {
            // Debug.Log("COUNT IS:::::::::::::" + spawnPoints.Count);
            if (state == spawnState.WAITING)
            {
                if (EnemyIsAlive())
                {
                    return;
                }
                else
                {
                    WaveCompleted();
                }
            }

            if (waveCountdown <= 0)
            {
                if (state != spawnState.SPAWNING)
                {
                    StartCoroutine(SpawnWave());
                    state = spawnState.WAITING;
                }
            }
            else
            {
                waveCountdown -= Time.deltaTime;
            }
        }
        IEnumerator SpawnWave()
        {
            GameObject enemy = (GameObject)Resources.Load("golem");

            if ((round % 2 == 0) && (round % 5 != 0)) // FAST ZOMBIES SPAWN
            {
                enemy.transform.GetChild(1).GetComponent <Renderer>().sharedMaterial = fast_zombie;
                enemy.GetComponent <NavMeshAgent>().speed        = Fast_Zombie_Speed;
                enemy.GetComponent <Enemy_Attack>().attackDamage = Fast_Zombie_Damage;
                state = spawnState.SPAWNING;

                for (int i = 0; i < AmountOfEnemies; i++)
                {
                    SpawnEnemies(enemy);
                    yield return(new WaitForSeconds(spawnDelay));
                }
                enemy.GetComponent <Enemy_Health>().enemyHealth += increaseEnemyHealth;
                AmountOfEnemies = AmountOfEnemies + IncreaseEnemiesBy;
                state           = spawnState.WAITING;

                yield break;
            }
            if (round % 5 == 0) // Heavy zombies spawn
            {
                enemy.transform.GetChild(1).GetComponent <Renderer>().sharedMaterial = Heavy_zombie;
                enemy.GetComponent <NavMeshAgent>().speed        = Heavy_Zombie_Speed;
                enemy.GetComponent <Enemy_Attack>().attackDamage = Heavy_Zombie_Damage;
                state = spawnState.SPAWNING;

                for (int i = 0; i < AmountOfEnemies; i++)
                {
                    SpawnEnemies(enemy);
                    yield return(new WaitForSeconds(spawnDelay));
                }
                enemy.GetComponent <Enemy_Health>().enemyHealth += increaseEnemyHealth;
                AmountOfEnemies = AmountOfEnemies + IncreaseEnemiesBy;
                state           = spawnState.WAITING;

                yield break;
            }
            else //regular zombies spawn
            {
                enemy.transform.GetChild(1).GetComponent <Renderer>().sharedMaterial = regular_zombie;
                enemy.GetComponent <NavMeshAgent>().speed        = Regular_Zombie_Speed;
                enemy.GetComponent <Enemy_Attack>().attackDamage = Regular_Zombie_Damage;
                state = spawnState.SPAWNING;

                for (int i = 0; i < AmountOfEnemies; i++)
                {
                    SpawnEnemies(enemy);
                    yield return(new WaitForSeconds(spawnDelay));
                }
                enemy.GetComponent <Enemy_Health>().enemyHealth += increaseEnemyHealth;
                AmountOfEnemies = AmountOfEnemies + IncreaseEnemiesBy;
                state           = spawnState.WAITING;

                yield break;
            }
        }
Exemplo n.º 4
0
    IEnumerator Spawn(Wave wave)
    {
        Announcer.alpha = 1;
        Announcer.text  = "They are coming...";
        state           = spawnState.spawning;
        StartCoroutine(AnnouncerFade());

        if (wave.Acount > 0)
        {
            for (int i = 0; i < wave.Acount; i++)
            {
                int       randomSpawnArea = Random.Range(0, 4);
                Vector2   point           = spawnAreas [randomSpawnArea];
                float     randomX         = Random.Range(-5f, 5f);
                float     randomY         = Random.Range(-5f, 5f);
                Vector3   loc             = new Vector3(point.x + randomX, 4, point.y + randomY);
                Transform zombie          = Instantiate(ZombieA, loc, Quaternion.Euler(new Vector3(0, 90, 0)), transform) as Transform;

                yield return(new WaitForSeconds(1f));
            }
        }

        if (wave.Bcount > 0)
        {
            for (int i = 0; i < wave.Bcount; i++)
            {
                int       randomSpawnArea = Random.Range(0, 4);
                Vector2   point           = spawnAreas [randomSpawnArea];
                float     randomX         = Random.Range(-5f, 5f);
                float     randomY         = Random.Range(-5f, 5f);
                Vector3   loc             = new Vector3(point.x + randomX, 4, point.y + randomY);
                Transform zombie          = Instantiate(ZombieB, loc, Quaternion.Euler(new Vector3(0, 90, 0)), transform) as Transform;

                yield return(new WaitForSeconds(1f));
            }
        }

        if (wave.Ccount > 0)
        {
            for (int i = 0; i < wave.Ccount; i++)
            {
                int       randomSpawnArea = Random.Range(0, 4);
                Vector2   point           = spawnAreas [randomSpawnArea];
                float     randomX         = Random.Range(-5f, 5f);
                float     randomY         = Random.Range(-5f, 5f);
                Vector3   loc             = new Vector3(point.x + randomX, 4, point.y + randomY);
                Transform zombie          = Instantiate(ZombieC, loc, Quaternion.Euler(new Vector3(0, 90, 0)), transform) as Transform;

                yield return(new WaitForSeconds(1f));
            }
        }

        state = spawnState.waiting;

        yield break;
    }
Exemplo n.º 5
0
 IEnumerator spawnwave(wave _wave)
 {
     state = spawnState.spawning;
     for (int i = 0; i < _wave.count; i++)
     {
         spawnenemy(_wave.enemy);
         yield return(new WaitForSeconds(1f / _wave.rate));
     }
     state = spawnState.waiting;
     yield break;
 }
    IEnumerator SpawnWave()
    {
        state = spawnState.SPAWNING;
        for (int i = 0; i < enemyCount; i++)
        {
            SpawnEnemy();
            yield return(new WaitForSeconds(1f / rate));
        }

        state = spawnState.WAITING;
        yield break;
    }
Exemplo n.º 7
0
 void waveDone()
 {
     state         = spawnState.counting;
     waveCountDown = timeBetweenWaves;
     if (nextWave + 1 > waves.Length - 1)
     {
         won = true;
     }
     else
     {
         nextWave++;
     }
 }
Exemplo n.º 8
0
    IEnumerator spawnWave(Wave _w)
    {
        state = spawnState.spawning;
        for (int i = 0; i < _w.count; i++)
        {
            spawnEnemy(_w.enemy);
            yield return(new WaitForSeconds(1f / _w.rate));
        }


        state = spawnState.wait;

        yield break;
    }
 void WaveCompleted()
 {
     state         = spawnState.Counting;
     waveCountdown = timeBetweenWaves;
     if (nextWave + 1 > waves.Length - 1)
     {
         nextWave = 0;
         //all waves completed
     }
     else
     {
         nextWave++;
     }
 }
Exemplo n.º 10
0
    void WaveCompleted()
    {
        state         = spawnState.COUNTING;
        waveCountdown = timeBetweenWaves;

        if (nextWave + 1 > waves.Length - 1)
        {
            nextWave = 0;
            Debug.Log("All Waves Complete. Looping.");
            return;
        }

        nextWave++;
    }
Exemplo n.º 11
0
    IEnumerator SpawnWave(Wave _wave)
    {
        state = spawnState.SPAWNING;

        //spawning
        for (int i = 0; i < _wave.amountEnemy; i++)
        {
            SpawnEnemy(_wave.enemy);
            yield return(new WaitForSeconds(1f / _wave.spawnRate));
        }

        state = spawnState.WAITING;
        yield break;
    }
Exemplo n.º 12
0
    IEnumerator SpawnWave(Wave _wave)
    {
        state = spawnState.SPAWNING;

        for (int i = 0; i < _wave.count; i++)
        {
            StartCoroutine(SpawnEnemy(_wave.enemy));
            yield return(new WaitForSeconds(1f / _wave.rate));
        }

        state = spawnState.WAITING;

        yield break;
    }
Exemplo n.º 13
0
    void newWave()
    {
        state = spawnState.counting;

        waveCountdown = timeBetweenWaves;

        if (nextWave + 1 > waves.Length - 1)
        {
            nextWave = 0;
        }
        else
        {
            nextWave++;
        }
    }
Exemplo n.º 14
0
    void waveCompleted()
    {
        state         = spawnState.counting;
        waveCountDown = timeBetween;

        if (nextWave + 1 > waves.Length - 1)
        {
            nextWave = 0;
            StartCoroutine(newscene());
        }
        else
        {
            nextWave++;
        }
    }
Exemplo n.º 15
0
 void WaveCompleted()
 {
     state           = spawnState.counting;
     Announcer.alpha = 1;
     waveCountdown   = timeBetweenWaves;
     Announcer.text  = "Wave Complete";
     if (nextWave + 1 > waves.Length - 1)
     {
         nextWave = 0;
         Debug.Log("ROUNDCOMPLETE");
     }
     else
     {
         nextWave++;
     }
 }
Exemplo n.º 16
0
    void WaveCompleted()
    {
        state         = spawnState.COUNTING;
        waveCountdown = waveWait;

        if (nextWave + 1 > waves.Length - 1)
        {
            nextWave = 0;
        }
        else
        {
            nextWave++;
        }
        waveCount++;
        UpdateWave();
    }
Exemplo n.º 17
0
    void SpawnNextWave()
    {
        state         = spawnState.Couting;
        waveCountdown = timeBetweenWaves;

        if (nextWave + 1 > waves.Length - 1)
        {
            // "win" sequence
            //nextWave = 0; caso queira resetar
            Debug.Log("Cabou-se, looping");
            WinSequence.Play();
            this.enabled = false;
        }
        else
        {
            nextWave++;
        }
    }
Exemplo n.º 18
0
    IEnumerator SpawnWave(Wave wave)
    {
        state = spawnState.Spawning;

        for (int i = 0; i < wave.count; i++)
        {
            SpawnEnemy(wave.enemy);
            yield return(new WaitForSeconds(1 / wave.rate));
        }

        for (int i = 0; i < wave.countType2; i++)
        {
            SpawnTurret(wave.enemyType2);
            yield return(new WaitForSeconds(1 / wave.rate));
        }

        state = spawnState.Waiting;

        yield break;
    }