public GameParametersReadyEventArgs(GameParameters gameState) { if (gameState == null) { throw new ArgumentNullException("gameState"); } this.Parameters = gameState; }
/// <summary> /// Class constructor loads necessary elements. /// </summary> /// <param name="content">content manager.</param> public PlayPage(ContentManager content, GraphicsDevice graphicsDevice, GameParameters defaultGameParams) : base(content, graphicsDevice, Menu.AltBackgroundResourceName, new[] { new TextBox(content, "FIRST PLAYER NAME", 0, "PLAYER1", false, 0, 0, new Vector2(-900, 400), 0.2f), new TextBox(content, "SECOND PLAYER NAME", 1, "PLAYER2", false, 0, 0, new Vector2(-900, 200), 0.2f), new TextBox(content, "MAP SIZE", 2, defaultGameParams.MapScale.ToString(), true, 0, 100, new Vector2(-900, 0), 0.2f), new TextBox(content, "MAX HEIGHT", 3, defaultGameParams.MaxMapHeight.ToString(), true, 0, 500, new Vector2(-900, -200), 0.2f), new MenuOption("BACK", 4, new Vector2(-700, -550), 1.1f), new TextBox(content, "THIRD PLAYER NAME", 5, string.Empty, false, 0, 0, new Vector2(100, 400), 0.2f), new TextBox(content, "FOURTH PLAYER NAME", 6, string.Empty, false, 0, 0, new Vector2(100, 200), 0.2f), new TextBox(content, "ROUGHNESS", 7, defaultGameParams.Roughness.ToString(), true, 0, 1000, new Vector2(100, 0), 0.2f), new TextBox(content, "LIGHT CHANGE SPEED", 8, defaultGameParams.LightChangeSpeed.ToString(), true, 0, 1000, new Vector2(100, -200), 0.2f), new MenuOption("NEXT", 9, new Vector2(200, -550), 1.1f) }) { }
private void StartLoading() { if (terrain != null) { terrain.Dispose(); } menu.GameParametersReady += (sender, e) => { GameParameters = e.Parameters; heightMap = new FractalMap( mapSize, GameParameters.Roughness, GameParameters.MaxMapHeight); tankController = new TankController(this); heightMap.Ready += (s, ea) => { camera = new FPPCamera(GraphicsDevice, new Vector3(500, GameParameters.MaxMapHeight * GameParameters.MapScale, 500), 0.3f, 2.0f, projection); this.AddMenuProgress(); tankController.Initialize(); #region Terrain initialization terrain = new QuadTree( this, Vector3.Zero, camera.View, projection); terrain.Ready += this.AddMenuProgress; terrain.Initialize(heightMap); #endregion sky = new Sky(GraphicsDevice, Content, projection, heightMap.Width, GameParameters.MapScale); }; tankController.Ready += TankControllerOnReady; tankController.ShotFired += TankControllerOnShotFired; tankController.MissileExploded += TankControllerOnMissileExploded; heightMap.Initialize(); }; }
/// <summary> /// Resets the game to the first state. /// </summary> public void Reset() { GameParameters = new GameParameters(); this.menu.Reset(); terrain.Dispose(); }