public void StartNewGame() { // create the walls CreateWalls(); // clear out the actors list actors.Clear(); // add the world actor WorldActor worldActor = new WorldActor(this); actors.Add(worldActor); // add the players to the actor list - they won't be removed for (int i = 0; i < ships.Length; i++) { actors.Add(ships[i]); } // spawn asteroids switch (WorldRules.AsteroidDensity) { case AsteroidDensity.None: break; case AsteroidDensity.Low: SpawnAsteroids(4, 3, 0); break; case AsteroidDensity.Medium: SpawnAsteroids(6, 4, 1); break; case AsteroidDensity.High: SpawnAsteroids(8, 6, 2); break; } // set up the power-up timer for the initial delay powerUpTimer = initialPowerUpDelay; // set up the starfield starfield.SetTargetPosition(dimensions * 0.5f); }
/// <summary> /// Loads graphics content for this screen. The background texture is quite /// big, so we use our own local ContentManager to load it. This allows us /// to unload before going from the menus into the game itself, wheras if we /// used the shared ContentManager provided by the ScreenManager, the content /// would remain loaded forever. /// </summary> public override void LoadContent() { lineBatch = new LineBatch(ScreenManager.GraphicsDevice); titleTexture = ScreenManager.Game.Content.Load<Texture2D>("Textures/title"); int viewportWidth = ScreenManager.GraphicsDevice.Viewport.Width; int viewportHeight = ScreenManager.GraphicsDevice.Viewport.Height; // update the projection in the line-batch lineBatch.SetProjection(Matrix.CreateOrthographicOffCenter(0.0f, viewportWidth, viewportHeight, 0.0f, 0.0f, 1.0f)); // recreate the particle systems particleSystems.Clear(); for (int i = 0; i < 4; i++) { particleSystems.Add(new ParticleSystem( new Vector2(random.Next(viewportWidth), random.Next(viewportHeight)), Vector2.Zero, 64, 256, 128, 1f + 2f * (float)random.NextDouble(), 0.05f, explosionColors)); } base.LoadContent(); }