示例#1
0
    private IEnumerator RoundLogic()
    {
        float timeSinceLastLoop = 0.0f;
        float timeElapsed       = 0.0f;

        while (true)
        {
            if (mState == State.Paused)
            {
                timeSinceLastLoop = Time.time;
                yield return(new WaitForEndOfFrame());
            }
            else
            {
                timeElapsed      += Time.time - timeSinceLastLoop;
                timeSinceLastLoop = Time.time;
                ScoreUpdate(10);
                if (timeElapsed > SecondsToSpawnIncrease)
                {
                    currentSpawnAmount += SpawnIncreaseAmount;
                    timeElapsed         = 0.0f;
                }

                for (int i = 0; i < currentSpawnAmount; i++)
                {
                    spawner.Spawn();
                }
                yield return(new WaitForSeconds(TimePerSpawn));
            }
        }
    }
示例#2
0
    private IEnumerator DodgeSpawnRoutine()
    {
        //Continuous loop - no break statements.
        while (true)
        {
            //If the game is paused, wait.
            if (mState == State.Paused)
            {
                yield return(new WaitForEndOfFrame());
            }
            //If the game is not paused...
            else
            {
                //Spawn as many shooting asteroids as the current spawn amount dictates.
                for (int i = 0; i < currentSpawnAmount; i++)
                {
                    shootingAsteroidSpawner.Spawn();
                }

                //Once done, wait for a duration until trying to spawn the next wave.
                yield return(new WaitForSeconds(TimeBetweenSAWaves));
            }
        }
    }