public override void Update(out State state, MainMenuScreen mainMenuScreen, ResolutionScreen resolutionScreen) { base.Update(out state, mainMenuScreen, resolutionScreen); for (int i = 0; i < menuItems.Count; i++) { if (mouseState.LeftButton == ButtonState.Pressed && prevMouseState.LeftButton == ButtonState.Released && mouseState.X > Window.ClientBounds.Width / 2 - 150 * scaleIndex && mouseState.X < Window.ClientBounds.Width / 2 + 150 * scaleIndex && mouseState.Y > Window.ClientBounds.Height / 2 - menuItems.Count * (50 * scaleIndex + menuSpace) / 2 + i * (50 * scaleIndex + menuSpace) && mouseState.Y < Window.ClientBounds.Height / 2 - menuItems.Count * (50 * scaleIndex + menuSpace) / 2 + i * (50 * scaleIndex + menuSpace) + 50 * scaleIndex) { switch (i) { case 0: this.state = State.gameScreen; gameScreen.Initialize(); gameScreen.LoadContent(); break; case 1: this.state = State.resolutionScreen; resolutionScreen.initialize(mouseState); break; case 2: this.state = State.exit; break; } } } prevMouseState = mouseState; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { state = State.mainMenuScreen; flashScreen = new FlashScreen(Content, GraphicsDevice, Window); mainMenuScreen = new MainMenuScreen(Content, GraphicsDevice, Window, graphics); resolutionScreen = new ResolutionScreen(Content, GraphicsDevice, Window, graphics); gameScreen = new GameScreen(Content, GraphicsDevice, Window); flashScreen.Initialize(); mainMenuScreen.Initialize(); resolutionScreen.Initialize(); mainMenuScreen.getGameScreen(gameScreen); base.Initialize(); }
public virtual void Update(out State state, MainMenuScreen mainMenuScreen, ResolutionScreen resolutionScreen) { mouseState = Mouse.GetState(); magnifyIndex = -1; for (int i = 0; i < menuItems.Count; i++) { if (mouseState.X > Window.ClientBounds.Width / 2 - (float)(150 * scaleIndex) && mouseState.X < Window.ClientBounds.Width / 2 + 150 * scaleIndex && mouseState.Y > Window.ClientBounds.Height / 2 - menuItems.Count * (50 * scaleIndex + menuSpace) / 2 + i * (50 * scaleIndex + menuSpace) && mouseState.Y < Window.ClientBounds.Height / 2 - menuItems.Count * (50 * scaleIndex + menuSpace) / 2 + i * (50 * scaleIndex + menuSpace) + 50 * scaleIndex) { magnifyIndex = i; } } state = this.state; cursor.Update(); }
public override void Update(out State state, MainMenuScreen mainMenuScreen, ResolutionScreen resolutionScreen) { base.Update(out state, mainMenuScreen, resolutionScreen); for (int i = 0; i < menuItems.Count; i++) { if (mouseState.LeftButton == ButtonState.Pressed && prevMouseState.LeftButton == ButtonState.Released && mouseState.X > Window.ClientBounds.Width / 2 - 150 * scaleIndex && mouseState.X < Window.ClientBounds.Width / 2 + 150 * scaleIndex && mouseState.Y > Window.ClientBounds.Height / 2 - menuItems.Count * (50 * scaleIndex + menuSpace) / 2 + i * (50 * scaleIndex + menuSpace) && mouseState.Y < Window.ClientBounds.Height / 2 - menuItems.Count * (50 * scaleIndex + menuSpace) / 2 + i * (50 * scaleIndex + menuSpace) + 50 * scaleIndex) { switch (i) { case 0: graphics.PreferredBackBufferWidth = 800; graphics.PreferredBackBufferHeight = 600; break; case 1: graphics.PreferredBackBufferWidth = 1024; graphics.PreferredBackBufferHeight = 768; break; case 2: graphics.PreferredBackBufferWidth = 1152; graphics.PreferredBackBufferHeight = 864; break; case 3: graphics.PreferredBackBufferWidth = 1280; graphics.PreferredBackBufferHeight = 720; break; case 4: graphics.PreferredBackBufferWidth = 1280; graphics.PreferredBackBufferHeight = 768; break; case 5: graphics.PreferredBackBufferWidth = 1280; graphics.PreferredBackBufferHeight = 800; break; case 6: graphics.PreferredBackBufferWidth = 1280; graphics.PreferredBackBufferHeight = 1024; break; case 7: graphics.PreferredBackBufferWidth = 1360; graphics.PreferredBackBufferHeight = 768; break; case 8: graphics.PreferredBackBufferWidth = 1366; graphics.PreferredBackBufferHeight = 768; break; case 9: graphics.PreferredBackBufferWidth = 1440; graphics.PreferredBackBufferHeight = 900; break; case 10: graphics.PreferredBackBufferWidth = 1600; graphics.PreferredBackBufferHeight = 1200; break; case 11: graphics.IsFullScreen = true; graphics.ApplyChanges(); graphics.PreferredBackBufferWidth = Window.ClientBounds.Width; graphics.PreferredBackBufferHeight = Window.ClientBounds.Height; graphics.ApplyChanges(); break; case 12: graphics.IsFullScreen = false; break; case 13: state = State.mainMenuScreen; mainMenuScreen.initialize(mouseState); break; } if (i >= 0 && i < 13 && i != 11) { graphics.IsFullScreen = true; graphics.ApplyChanges(); int width = Window.ClientBounds.Width; int height = Window.ClientBounds.Height; graphics.IsFullScreen = false; graphics.ApplyChanges(); Window.Position = new Point(width / 2 - Window.ClientBounds.Width / 2, height / 2 - Window.ClientBounds.Height / 2); } } } prevMouseState = mouseState; }