private IEnumerator StartGame()
    {
        for (; ;) //game loop
        {
            if (EnemiesOnScreen == 0)
            {
                //STUFF THAT INCREASES WITH EACH WAVE
                if (!isStart)//only do this stuff on the next waves, not on the first one
                {
                    //can't give a million bullets. Maxes out at 10
                    if (waveCount < 10)
                    {
                        shootScript.AddBullet();            //add one bullet to the gun to shoot at a time. start with 0 and get one right as you start
                        StartCoroutine(gunUI.StartAlert()); //tell the player that their gun has been upgraded
                    }

                    //this is the stuff that doesn't max out at 10
                    enemySpawnScript.IncreaseSpeed();                          //make em faster
                    numberOfEnemiesInWave++;                                   //add another enemy to the next wave each time
                    healthSpawnScript.SpawnHealthPacks(GenerateRandomPoint()); //put some health on the screen after enemies have spawned
                }

                isStart = false;

                //ALERT FOR NEW WAVE
                yield return(new WaitForSeconds(timeBetweenWaves)); //the calm before the next wave

                StartCoroutine(waveUI.StartAlert());                //give the alert that there will be a new wave
                //audio.PlayOneShot(happyAlert, happyAlertVolume);//play after a short delay so that you see it as soon as the UI is done fading in

                //NEXT WAVE
                waveCount++;
                for (int i = 0; i < numberOfEnemiesInWave; i++)
                {
                    //yield return new WaitForSeconds(ChooseARandomSpawnTime());//waits a random time that it chooses from our min to our max
                    enemySpawnScript.Spawn(GenerateRandomPoint());
                    EnemiesOnScreen++;
                }
            }

            yield return(new WaitForEndOfFrame());//lil pause
        }
    }
Exemplo n.º 2
0
 private void CatchTheBullet()
 {
     Destroy(bullet);
     playerShoot.AddBullet();
 }