/// <summary> /// The main game constructor. /// </summary> public GameStateManagementGame() { instance = this; Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); //graphics.PreferredBackBufferWidth = 853; //graphics.PreferredBackBufferHeight = 480; graphics.PreferredBackBufferWidth = 640; graphics.PreferredBackBufferHeight = 480; //graphics.IsFullScreen = true; // Create the screen manager component. screenManager = new ScreenManager(this); contentManager = new ContentManager(screenManager.Game.Services, "Content"); SoundManager.contentManager = content; SoundManager.LoadContent(); Components.Add(screenManager); // Activate the first screens. screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); }
public CatapultGame () { graphics = new GraphicsDeviceManager (this); //graphics.SynchronizeWithVerticalRetrace = false; Content.RootDirectory = "Content"; // Frame rate is 30 fps by default for Windows Phone. TargetElapsedTime = TimeSpan.FromTicks (333333); //Create a new instance of the Screen Manager screenManager = new ScreenManager (this); Components.Add (screenManager); Components.Add (new MessageDisplayComponent (this)); Components.Add (new GamerServicesComponent (this)); //Add two new screens screenManager.AddScreen (new BackgroundScreen (), null); screenManager.AddScreen (new MainMenuScreen (), null); // Listen for invite notification events. NetworkSession.InviteAccepted += (sender, e) => NetworkSessionComponent.InviteAccepted (screenManager, e); IsMouseVisible = true; #if !WINDOWS && !XBOX && !MONOMAC && !LINUX //Switch to full screen for best game experience graphics.IsFullScreen = true; #else graphics.PreferredBackBufferHeight = 480; graphics.PreferredBackBufferWidth = 800; #endif AudioManager.Initialize (this); }
public CatapultGame() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; // Frame rate is 30 fps by default for Windows Phone. TargetElapsedTime = TimeSpan.FromTicks(333333); //Create a new instance of the Screen Manager screenManager = new ScreenManager(this); Components.Add(screenManager); //Switch to full screen for best game experience graphics.IsFullScreen = true; //Add two new screens screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); //Create Chooser and Launcher InitializeChooserAndLauncher(); AudioManager.Initialize(this); InitializePhoneServices(); }
/// <summary> /// The main game constructor. /// </summary> public GameStateManagementGame() { Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); graphics.IsFullScreen = true; TargetElapsedTime = TimeSpan.FromTicks(333333); // you can choose whether you want a landscape or portait // game by using one of the two helper functions. //InitializePortraitGraphics(); InitializeLandscapeGraphics(); // Create the screen manager component. screenManager = new ScreenManager(this); Components.Add(screenManager); // attempt to deserialize the screen manager from disk. if that // fails, we add our default screens. if (!screenManager.DeserializeState()) { // Activate the first screens. screenManager.AddScreen(new MenuBackgroundScreen("mainMenubackground"), null); screenManager.AddScreen(new MainMenuScreen(), null); } }
/// <summary> /// Initializes a new instance of the game. /// </summary> public BlackjackGame() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; screenManager = new ScreenManager(this); screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); Components.Add(screenManager); #if WINDOWS IsMouseVisible = true; #elif WINDOWS_PHONE // Frame rate is 30 fps by default for Windows Phone. TargetElapsedTime = TimeSpan.FromTicks(333333); graphics.IsFullScreen = true; #else Components.Add(new GamerServicesComponent(this)); #endif // Initialize sound system AudioManager.Initialize(this); #if XBOX graphics.PreferredBackBufferHeight = graphics.GraphicsDevice.DisplayMode.Height; graphics.PreferredBackBufferWidth = graphics.GraphicsDevice.DisplayMode.Width; #elif WINDOWS graphics.PreferredBackBufferHeight = 480; graphics.PreferredBackBufferWidth = 800; #endif }
/// <summary> /// The main game constructor. /// </summary> public GameStateManagementGame() { Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); graphics.IsFullScreen = true; TargetElapsedTime = TimeSpan.FromTicks(333333); // you can choose whether you want a landscape or portait // game by using one of the two helper functions. // This game only supports Landscape view, both left and right //InitializePortraitGraphics(); InitializeLandscapeGraphics(); graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight; // Create the screen manager component. screenManager = new ScreenManager(this); // Note make sure to render in correct order Components.Add(screenManager); // attempt to deserialize the screen manager from disk. if that // fails, we add our default screens. if (!screenManager.DeserializeState()) { // Activate the first screens. screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); } }
/// <summary> /// The main game constructor. /// </summary> public GameStateManagementGame() { Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = 1024; graphics.PreferredBackBufferHeight = 768; // Create the screen manager component. screenManager = new ScreenManager(this); Components.Add(screenManager); // Activate the first screens. screenManager.AddScreen(new BackgroundScreen()); screenManager.AddScreen(new MainMenuScreen()); m_kInfoBox = new Utils.InfoBox(this, new Vector2(Window.ClientBounds.Width, Window.ClientBounds.Height - 10)); //Components.Add(m_kInfoBox); IsFixedTimeStep = true; graphics.SynchronizeWithVerticalRetrace = true; // For testing purposes, let's disable fixed time step and vsync. //IsFixedTimeStep = false; //graphics.SynchronizeWithVerticalRetrace = false; }
/// <summary> /// Initializes a new instance of the game. /// </summary> public BlackjackGame() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; screenManager = new ScreenManager(this); screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); Components.Add(screenManager); #if WINDOWS || MACOS || LINUX IsMouseVisible = true; #elif WINDOWS_PHONE || IOS || ANDROID // Frame rate is 30 fps by default for Windows Phone. TargetElapsedTime = TimeSpan.FromTicks(333333); graphics.IsFullScreen = true; #else Components.Add(new GamerServicesComponent(this)); #endif // Initialize sound system AudioManager.Initialize(this); }
/// <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() { /// FIXME /// - You actually want to load the menu first, and the menu will instantiate /// GameplayScreen with an attached and loaded Scenario object. ScreenManager screenManager = new ScreenManager(this); Components.Add(screenManager); screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); base.Initialize(); }
protected override void LoadContent() { Managers.Content = this.Content; Managers.Graphics = this.graphics; spriteBatch = new SpriteBatch(GraphicsDevice); arial = Content.Load<SpriteFont>("Fonts/Arial"); comicSans = Content.Load<SpriteFont>("Fonts/ComicSansMS"); screenManager = new ScreenManager(this); screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); }
/// <summary> /// The main game constructor. /// </summary> public GameStateManagementGame() { Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = 853; graphics.PreferredBackBufferHeight = 480; // Create the screen manager component. screenManager = new ScreenManager(this); // Activate the first screens. screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); }
/// <summary> /// The main game constructor. /// </summary> public GameStateManagementGame() { Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = 853; // uncomment for non-fullscreenmode graphics.PreferredBackBufferHeight = 480; //uncomment for non-fullscreen mode graphics.IsFullScreen = true; // uncoment this to switch to full screen mode when user testing! // Create the screen manager component. screenManager = new ScreenManager(this); Components.Add(screenManager); // Activate the first screens. screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new SlideMenuScreen(), null); }
public static void Load(ScreenManager screenManager, bool loadingIsSlow, params GameScreen[] screensToLoad) { foreach (GameScreen screen in screenManager.GetScreens()) screen.ExitScreen(); LoadingScreen loadingScreen = new LoadingScreen(screenManager, loadingIsSlow, screensToLoad); screenManager.AddScreen(loadingScreen); }
public SaturnsTurn2Game() { _graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; Window.Title = "Saturn's Turn 2"; // add screens etc screenManager = new ScreenManager(this); Components.Add(screenManager); //AudioManager.Initialize(this); // Activate the first screens. screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); }
public SpaceSurvivalGame() { Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); // Create the screen factory and add it to the Services screenFactory = new ScreenFactory(); Services.AddService(typeof(IScreenFactory), screenFactory); // Create the screen manager component. screenManager = new ScreenManager(this); Components.Add(screenManager); screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); }
/// <summary> /// Основной конструктор игры /// </summary> public GameStateManagementGame() { Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = BufferWidth; graphics.PreferredBackBufferHeight = BufferHeight; // Создаётся screen manager component. screenManager = new ScreenManager(this); Components.Add(screenManager); // Активируются начальные экраны. screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); }
/// <summary> /// The main game constructor. /// </summary> public GameStateManagementGame() { Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = 1260; graphics.PreferredBackBufferHeight = 860; // Create the screen manager component. screenManager = new ScreenManager(this); Components.Add(screenManager); speakToMe = new Vocal(this); mySkeleton = new Mover(this); // Activate the first screens. screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); }
/// <summary> /// The main game constructor. /// </summary> public GameStateManagementGame() { Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = 800; graphics.PreferredBackBufferHeight = 480; graphics.SynchronizeWithVerticalRetrace = false; // Create the screen manager component. screenManager = new ScreenManager(this); Components.Add(screenManager); // Activate the first screens. screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); }
public towersmash() { players = new bool[maxnumplayers]; for (int i = 0; i < maxnumplayers; i++) { players[i] = false; } Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); screenmanager = new ScreenManager(this); graphics.PreferredBackBufferWidth = (int)screen_width; graphics.PreferredBackBufferHeight = (int)screen_height; Components.Add(screenmanager); screenmanager.AddScreen(new BackgroundScreen(), null); screenmanager.AddScreen(new MainMenuScreen(), null); this.IsMouseVisible = true; characters = new playertype[4]; }
/// <summary> /// The main game constructor. /// </summary> public GameStateManagementGame() { Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = 1280; graphics.PreferredBackBufferHeight = 800; Window.AllowUserResizing = true; // Create the screen manager component. screenManager = new ScreenManager(this, graphics, Content); Components.Add(screenManager); // Activate the first screens. screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); }
/// <summary> /// The main game constructor. /// </summary> public Game1() { Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = 1024; graphics.PreferredBackBufferHeight = 768; // Create the screen manager component. screenManager = new ScreenManager(this); Components.Add(screenManager); // Activate the first screens. screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); this.IsMouseVisible = true; }
public static void Load(ScreenManager screenManager, bool loadingIsSlow, PlayerIndex? controllingPlayer, params MainMenuScreen[] screensToLoad) { foreach (GameScreen screen in screenManager.GetScreens()) screen.ExitScreen(); SplashScreenLoading splashScreenLoading = new SplashScreenLoading(screenManager, loadingIsSlow, screensToLoad); screenManager.AddScreen(splashScreenLoading, controllingPlayer); }
/// <summary> /// The main game constructor. /// </summary> public GameStateManagementGame() { Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = BufferWidth; graphics.PreferredBackBufferHeight = BufferHeight; // Create the screen manager component. screenManager = new ScreenManager(this); Components.Add(screenManager); // Activate the first screens. ConvertUnits.SetDisplayUnitToSimUnitRatio(10f); // screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; //set game to fullscreen graphics.IsFullScreen = true; //set resolution to current screen resolution graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; //load screen manager screenManager = new ScreenManager(this); Components.Add(screenManager); //set initial screens screenManager.AddScreen(new MenuBackground()); screenManager.AddScreen(new MainMenu()); }
/// <summary> /// The main game constructor. /// </summary> public GameStateManagementGame() { Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = 1200; graphics.PreferredBackBufferHeight = 675; this.IsMouseVisible = true; // Create the screen manager component. screenManager = new ScreenManager(this); Components.Add(screenManager); // Activate the first screens. screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); this.Window.Title = "DoodleDefenders"; }
public VampsGame() { Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); //graphics.PreferredBackBufferWidth = 853; // graphics.PreferredBackBufferHeight = 480; graphics.IsFullScreen = false; Window.Title = "Vamp's"; // Create the screen manager component. screenManager = new ScreenManager(this); Components.Add(screenManager); AudioManager.Initialize(this); // Activate the first screens. screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); }
/// <summary> /// Activates the loading screen. /// </summary> public static void Load(ScreenManager screenManager, bool loadingIsSlow, params GameScreen[] screensToLoad) { // Tell all the current screens to transition off. foreach (GameScreen screen in screenManager.GetScreens()) screen.ExitScreen(); // Create and activate the loading screen. LoadingScreen loadingScreen = new LoadingScreen(screenManager, loadingIsSlow, screensToLoad); screenManager.AddScreen(loadingScreen); }
/// <summary> /// The main game constructor. /// </summary> public GameStateManagementGame() { Content.RootDirectory = "Content"; graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = 1280; graphics.PreferredBackBufferHeight = 720; // Create the screen manager component. screenManager = new ScreenManager(this); Components.Add(screenManager); Components.Add(new FrameRateMonitor(this)); // Activate the first screens. screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); //Add Frame Rate //Components.Add(new FrameRateMonitor(this)); Components.Add(new FrameRateMonitor(this, true)); }
public CurveGame() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; // Create the screen manager component. screenManager = new ScreenManager(this); screenManager.TraceEnabled = true; Components.Add(screenManager); // Activate the first screen. screenManager.AddScreen(new ZGamesScreen()); }
public MarbleMazeGame() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; // Frame rate is 30 fps by default for Windows Phone. TargetElapsedTime = TimeSpan.FromTicks(333333); //Create a new instance of the Screen Manager screenManager = new ScreenManager(this); Components.Add(screenManager); // Switch to full screen for best game experience graphics.IsFullScreen = true; graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft; // Add two new screens screenManager.AddScreen(new BackgroundScreen(), null); screenManager.AddScreen(new MainMenuScreen(), null); // Initialize sound system AudioManager.Initialize(this); }
void MenuEntry3Selected(object sender, PlayerIndexEventArgs e) { Global.currentAnswerPos = 3; ScreenManager.AddScreen(new ArtistAnswerModeScreen(), e.PlayerIndex); }
/// <summary> /// Event handler for when the Options menu entry is selected /// </summary> void OptionsMenuEntrySelected(object sender, EventArgs e) { // Set the current menu to options ScreenManager.AddScreen(new OptionsMenuScreen()); }
/// <summary> /// Event handler for when the About Game menu entry is selected. /// </summary> private void AboutGameMenuEntrySelected(object sender, PlayerIndexEventArgs e) { ScreenManager.AddScreen(new AboutGameScreen(), e.PlayerIndex); }
private void MedalsMenuEntrySelected(object sender, PlayerIndexEventArgs e) { ScreenManager.AddScreen(new MedalsMenuScreen(0, MedalsMenuScreen.TRANSITION_ON_TIME), ActivePlayer.PlayerIndex); }
private void SettingsGameMenuEntrySelected(object sender, PlayerIndexEventArgs e) { // Add options screen ScreenManager.AddScreen(new OptionsMenuScreen(), ActivePlayer.PlayerIndex); }
/// <summary> /// Lets the game respond to player input. Unlike the Update method, /// this will only be called when the gameplay screen is active. /// </summary> public override void HandleInput(InputState input) { if (input == null) { throw new ArgumentNullException("input"); } // Mouse handle var curMouseState = Mouse.GetState(); if (curMouseState.LeftButton == ButtonState.Pressed) { _mousePoint = _chessBoard.GetMatrixPosition(new Point(curMouseState.X, curMouseState.Y), 30); } // Look up inputs for the active player profile. if (ControllingPlayer != null) { var playerIndex = (int)ControllingPlayer.Value; var keyboardState = input.CurrentKeyboardStates[playerIndex]; // The game pauses either if the user presses the pause button, or if // they unplug the active gamepad. This requires us to keep track of // whether a gamepad was ever plugged in, because we don't want to pause // on PC if they are playing with a keyboard and have no gamepad at all! if (input.IsPauseGame(ControllingPlayer)) { ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer); } else { // Otherwise move the player position. var movement = Vector2.Zero; if (keyboardState.IsKeyDown(Keys.Left)) { movement.X--; } if (keyboardState.IsKeyDown(Keys.Right)) { movement.X++; } if (keyboardState.IsKeyDown(Keys.Up)) { movement.Y--; } if (keyboardState.IsKeyDown(Keys.Down)) { movement.Y++; } if (movement.Length() > 1) { movement.Normalize(); } _playerPosition += movement * 2; } // Mouse } }
/// <summary> /// Event handler for when the Options menu entry is selected. /// </summary> void OptionsMenuEntrySelected(object sender, EventArgs e) { ScreenManager.AddScreen(new OptionsMenuScreen()); }
/// <summary> /// Lets the game respond to player input. Unlike the Update method, /// this will only be called when the gameplay screen is active. /// </summary> public override void HandleInput(InputState input) { if (input == null) { throw new ArgumentNullException("input"); } // Look up inputs for the active player profile. int playerIndex = (int)ControllingPlayer.Value; KeyboardState keyboardState = input.CurrentKeyboardStates[playerIndex]; GamePadState gamePadState = input.CurrentGamePadStates[playerIndex]; KeyboardState lastKeyboardState = input.LastKeyboardStates[playerIndex]; GamePadState lastGamePadState = input.LastGamePadStates[playerIndex]; // The game pauses either if the user presses the pause button, or if // they unplug the active gamepad. This requires us to keep track of // whether a gamepad was ever plugged in, because we don't want to pause // on PC if they are playing with a keyboard and have no gamepad at all! bool gamePadDisconnected = !gamePadState.IsConnected && input.GamePadWasConnected[playerIndex]; if (input.IsPauseGame(ControllingPlayer) || gamePadDisconnected) { ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer); } else { Vector2 movement = Vector2.Zero; //windows 8 gestures monogame while (TouchPanel.IsGestureAvailable) { GestureSample gesture = TouchPanel.ReadGesture(); if (gesture.GestureType == GestureType.FreeDrag) { player.Position3 += gesture.Delta; } } //mouse Vector2 mousePosition = new Vector2(currentMouseState.X, currentMouseState.Y); if (currentMouseState.RightButton == ButtonState.Pressed) { Vector2 posDelta = mousePosition - player.Position3; posDelta.Normalize(); posDelta = posDelta * playerMoveSpeed; player.Position3 = player.Position3 + posDelta; } // Otherwise move the player position. if (keyboardState.IsKeyDown(Keys.F)) { } if (keyboardState.IsKeyDown(Keys.A) || keyboardState.IsKeyDown(Keys.Left)) { movement.X--; //add for scroll background newBackground.BackgroundOffset -= 1; newBackground.ParallaxOffset -= 2; } if (keyboardState.IsKeyDown(Keys.D) || keyboardState.IsKeyDown(Keys.Right)) { movement.X++; //add for scroll backgorund newBackground.BackgroundOffset += 1; newBackground.ParallaxOffset += 2; } if (keyboardState.IsKeyDown(Keys.W) || keyboardState.IsKeyDown(Keys.Up)) { movement.Y--; } if (keyboardState.IsKeyDown(Keys.S) || keyboardState.IsKeyDown(Keys.Down)) { movement.Y++; } Vector2 thumbstick = gamePadState.ThumbSticks.Left; movement.X += thumbstick.X; movement.Y -= thumbstick.Y; // Make sure that the player does not go out of bounds player.Position3.X = MathHelper.Clamp(player.Position3.X, 0, ScreenManager.GraphicsDevice.Viewport.Width - (player.PlayerAnimation.FrameWidth * player.Scale)); player.Position3.Y = MathHelper.Clamp(player.Position3.Y, 0, ScreenManager.GraphicsDevice.Viewport.Height - (player.PlayerAnimation.FrameHeight * player.Scale)); //fire weapon normal if (currentMouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton == ButtonState.Released || keyboardState.IsKeyDown(Keys.Space) && lastKeyboardState.IsKeyUp(Keys.Space)) { AddProjectile(player.Position3 + new Vector2(player.Width / 2, player.Height / 2)); //todo //weaon fire not hitting bottom AudioManager.PlaySound("laserSound"); } if (movement.Length() > 1) { movement.Normalize(); } //new player move player.Position3 += movement * playerMoveSpeed; } }
/// <summary> /// Lets the game respond to player input. Unlike the Update method, /// this will only be called when the gameplay screen is active. /// </summary> public override void HandleInput(InputState input) { if (input == null) { throw new ArgumentNullException("input"); } // Look up inputs for the active player profile. int playerIndex = (int)ControllingPlayer.Value; KeyboardState keyboardState = input.CurrentKeyboardStates[playerIndex]; GamePadState gamePadState = input.CurrentGamePadStates[playerIndex]; // The game pauses either if the user presses the pause button, or if // they unplug the active gamepad. This requires us to keep track of // whether a gamepad was ever plugged in, because we don't want to pause // on PC if they are playing with a keyboard and have no gamepad at all! bool gamePadDisconnected = !gamePadState.IsConnected && input.GamePadWasConnected[playerIndex]; if (input.IsPauseGame(ControllingPlayer) || gamePadDisconnected) { ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer); } else { // Otherwise move the player position. Vector2 movement = Vector2.Zero; if (keyboardState.IsKeyDown(Keys.Left)) { movement.X--; } if (keyboardState.IsKeyDown(Keys.Right)) { movement.X++; } if (keyboardState.IsKeyDown(Keys.Up)) { movement.Y--; } if (keyboardState.IsKeyDown(Keys.Down)) { movement.Y++; } Vector2 thumbstick = gamePadState.ThumbSticks.Left; movement.X += thumbstick.X; movement.Y -= thumbstick.Y; if (movement.Length() > 1) { movement.Normalize(); } playerPosition += movement * 2; } }
/// <summary> /// Event handler for when the Play Game menu entry is selected. /// </summary> void PlayGameMenuEntrySelected(object sender, PlayerIndexEventArgs e) { ScreenManager.AddScreen(new DifficultyMenuScreen(), e.PlayerIndex); }
/// <summary> /// Event handler for when the Options menu entry is selected. /// </summary> void OptionsMenuEntrySelected(object sender, PlayerIndexEventArgs e) { ScreenManager.AddScreen(new OptionsMenuScreen(), e.PlayerIndex); }
/// <summary> /// Lets the game respond to player input. Unlike the Update method, /// this will only be called when the gameplay screen is active. /// </summary> public override void HandleInput(InputState input) { // Check if the user's input is null and throw an exception if it is if (input == null) { throw new ArgumentNullException("input"); } // Look up inputs for the active player profile KeyboardState keyboardState = input.CurrentKeyboardStates; // Checks to see if the user hit the pause button (esc) if (input.IsPauseGame()) { // Add a new screen on top of our current screen to display the pause menu ScreenManager.AddScreen(new PauseMenuScreen()); } // Check to see if our menu selection key was hit (Z) if (input.IsMenuSelect()) { // Check to see if the player already has the move they are on in the selection screen equipped if (PlayerInfo.Moves.Contains(selectedMove)) { // Get the index of this move and remove it from the player's currently equipped moves int index = Array.IndexOf(PlayerInfo.Moves, selectedMove); PlayerInfo.Moves[index] = -1; } // Otherwise, if there is an open slot for equipping a new move else if (PlayerInfo.Moves.Contains(-1)) { // Get the index of the open slot and fill it with the new selected index int index = Array.IndexOf(PlayerInfo.Moves, -1); PlayerInfo.Moves[index] = selectedMove; } } // Check to see if the start button (enter) was pressed and if the player has any moves equipped (I.E anything with an index greater than -1) if (input.IsStartButton() && Array.Exists(PlayerInfo.Moves, selectedMove => selectedMove > -1)) { // Load the next match LoadingScreen.Load(ScreenManager, false, new MatchupInfoScreen()); } // Check to see if the up arrow key was hit if (input.IsMenuUp()) { // Decrement the selected move selectedMove--; // Wrap the selected move around if the user goes beyond the minimum moves if (selectedMove < 0) { selectedMove = maxMoves - 1; } } // Check to see if the down arrow key was hit if (input.IsMenuDown()) { // Increment the selected move selectedMove++; // Wrap back around if the player goes beyond the maximum amount of moves if (selectedMove >= maxMoves) { selectedMove = 0; } } }
/// <summary> /// Event handler for when the Highscore menu entry is selected. /// </summary> void HighscoreMenuEntrySelected(object sender, PlayerIndexEventArgs e) { ScreenManager.AddScreen(new HighscoreMenuScreen(), e.PlayerIndex); }