Time for action – spawning enemies
Add the
SpawnEnemy()
method to the EnemyManager class:public void SpawnEnemy(int path) { Enemy thisEnemy = new Enemy( texture, pathWaypoints[path][0], initialFrame, frameCount); for (int x = 0; x < pathWaypoints[path].Count(); x++) { thisEnemy.AddWaypoint(pathWaypoints[path][x]); } Enemies.Add(thisEnemy); }
Add the
SpawnWave()
method to the EnemyManager class:public void SpawnWave(int waveType) { waveSpawns[waveType] += rand.Next(MinShipsPerWave, MaxShipsPerWave + 1); }
Add the
updateWaveSpawns()
method to the EnemyManager class:private void updateWaveSpawns(GameTime gameTime) { shipSpawnTimer += (float)gameTime.ElapsedGameTime.TotalSeconds; if (shipSpawnTimer > shipSpawnWaitTime) { for (int x = waveSpawns.Count - 1; x >= 0; x--) { if (waveSpawns[x] > 0) { waveSpawns[x]--; SpawnEnemy(x); ...