Beispiel #1
0
        public void NewWave()
        {
            if (Waves.Count > 0)
            {
                currentEnemyInWave = 0;
                CurrentWaveNumber++;

                CurrentWave   = Waves.Dequeue();
                QueuedEnemies = CurrentWave.Enemies;

                FlashingLabel warningLabel = new FlashingLabel("Enemies Detected!", new Vector2(ScreenManager.ScreenCentre.X, ScreenManager.ScreenCentre.Y * 0.25f), Color.Red, null, 4.8f);
                UnderSiegeGameplayScreen.HUD.AddUIObject(warningLabel, "New Wave Label");

                int spawnCounter = 0;
                foreach (Vector2 spawnPoint in CurrentWave.WaveData.SpawnPoints)
                {
                    UnderSiegeGameplayScreen.HUD.AddUIObject(new Marker(new Vector2(-CurrentWave.WaveData.SpawnPoints.Count * 0.5f * 32 + spawnCounter * 32, 32), Camera.GameToScreenCoords(spawnPoint), "Sprites\\UI\\Markers\\DirectionMarker", warningLabel), spawnPoint.ToString() + "Marker");
                    spawnCounter++;
                }

                currentTimeBetweenWaves       = 0;
                currentTimeBetweenEnemySpawns = CurrentWave.WaveData.TimeBetweenEnemySpawns;

                // If our time between enemy spawns is zero, add them all at once
                if (CurrentWave.WaveData.TimeBetweenEnemySpawns == 0)
                {
                    while (QueuedEnemies.Count > 0)
                    {
                        currentEnemyInWave++;
                        GameplayScreen.AddEnemyShip(QueuedEnemies.Dequeue(), "Wave " + CurrentWaveNumber + " Enemy " + currentEnemyInWave);
                    }
                }
            }
            else
            {
                CurrentWave = null;
            }

            if (Continuous)
            {
                if (Waves.Count == 1)
                {
                    //Waves.Enqueue(Waves.Peek().Clone());
                    Wave <T> wave = new Wave <T>(GameplayScreen.GameplayScreenData.WaveNames[GameplayScreen.GameplayScreenData.WaveNames.Count - 1]);
                    wave.LoadContent();
                    wave.Initialize();
                    Waves.Enqueue(wave);
                }
            }
        }