// process input public override void ProcessInput(float elapsedTime, InputManager input) { if (input == null) { throw new ArgumentNullException("input"); } for (int i = 0; i < 2; i++) { // A button or enter to select menu option if (input.IsButtonPressedA(i) || input.IsButtonPressedStart(i) || input.IsKeyPressed(i, Keys.Enter) || input.IsKeyPressed(i, Keys.Space)) { switch (menuSelection) { case 0: // single player gameManager.GameMode = GameMode.SinglePlayer; screenManager.SetNextScreen(ScreenType.ScreenPlayer); break; case 1: // multi player gameManager.GameMode = GameMode.MultiPlayer; screenManager.SetNextScreen(ScreenType.ScreenPlayer); break; case 2: // help screenManager.SetNextScreen(ScreenType.ScreenHelp); break; case 3: // exit game screenManager.Exit(); break; } gameManager.PlaySound("menu_select"); } // up/down keys change menu sel if (input.IsKeyPressed(i, Keys.Up) || input.IsButtonPressedDPadUp(i) || input.IsButtonPressedLeftStickUp(i)) { menuSelection = (menuSelection == 0 ? NumberMenuItems - 1 : menuSelection - 1); gameManager.PlaySound("menu_change"); } if (input.IsKeyPressed(i, Keys.Down) || input.IsButtonPressedDPadDown(i) || input.IsButtonPressedLeftStickDown(i)) { menuSelection = (menuSelection + 1) % NumberMenuItems; gameManager.PlaySound("menu_change"); } } }
public override void ProcessInput(float elapsedTime, InputManager input) { if (input == null) { throw new ArgumentNullException("input"); } const float rotationVelocity = 3.0f; int i, j = (int)gameManager.GameMode; for (i = 0; i < j; i++) { if (confirmed[i] == false) { // change invert Y selection if (input.IsKeyPressed(i, Keys.Y) || input.IsButtonPressedY(i)) { invertY ^= ((uint)1 << i); gameManager.PlaySound("menu_change"); } // confirm selection if (input.IsKeyPressed(i, Keys.Enter) || input.IsButtonPressedA(i)) { confirmed[i] = true; gameManager.PlaySound("menu_select"); } // cancel and return to intro menu if (input.IsKeyPressed(i, Keys.Escape) || input.IsButtonPressedB(i)) { gameManager.SetShips(null, null, 0); screenManager.SetNextScreen(ScreenType.ScreenIntro); gameManager.PlaySound("menu_cancel"); } // rotate ship float RotX = rotationVelocity * input.LeftStick(i).X *elapsedTime; if (input.IsKeyDown(i, Keys.Left)) { RotX -= rotationVelocity * elapsedTime; } if (input.IsKeyDown(i, Keys.Right)) { RotX += rotationVelocity * elapsedTime; } if (Math.Abs(RotX) < 0.001f) { RotX = -0.5f * elapsedTime; } rotation[i] = rotation[i] * Matrix.CreateRotationY(RotX); // change ship (next) if (input.IsKeyPressed(i, Keys.Up) || input.IsButtonPressedDPadUp(i) || input.IsButtonPressedLeftStickUp(i)) { selection[i] = (selection[i] + 1) % NumberShips; gameManager.PlaySound("menu_change"); } // change ship (previous) if (input.IsKeyPressed(i, Keys.Down) || input.IsButtonPressedDPadDown(i) || input.IsButtonPressedLeftStickDown(i)) { if (selection[i] == 0) { selection[i] = NumberShips - 1; } else { selection[i] = selection[i] - 1; } gameManager.PlaySound("menu_change"); } } else { // cancel selection if (input.IsKeyPressed(i, Keys.Escape) || input.IsButtonPressedB(i)) { confirmed[i] = false; gameManager.PlaySound("menu_cancel"); } } } // if both ships confirmed, go to game screen if (confirmed[0] && confirmed[1]) { if (gameManager.GameMode == GameMode.SinglePlayer) { gameManager.SetShips(ships[selection[0]], null, invertY); } else { gameManager.SetShips(ships[selection[0]], ships[selection[1]], invertY); } screenManager.SetNextScreen(ScreenType.ScreenLevel); } }
public override void ProcessInput(float elapsedTime, InputManager input) { if (input == null) { throw new ArgumentNullException("input"); } const float rotationVelocity = 3.0f; int i, j = (int)gameManager.GameMode; for (i = 0; i < j; i++) if (confirmed[i] == false) { // change invert Y selection if (input.IsKeyPressed(i, Keys.Y) || input.IsButtonPressedY(i)) { invertY ^= ((uint)1 << i); gameManager.PlaySound("menu_change"); } // confirm selection if (input.IsKeyPressed(i, Keys.Enter) || input.IsButtonPressedA(i)) { confirmed[i] = true; gameManager.PlaySound("menu_select"); } // cancel and return to intro menu if (input.IsKeyPressed(i, Keys.Escape) || input.IsButtonPressedB(i)) { gameManager.SetShips(null, null, 0); screenManager.SetNextScreen(ScreenType.ScreenIntro); gameManager.PlaySound("menu_cancel"); } // rotate ship float RotX = rotationVelocity * input.LeftStick(i).X * elapsedTime; if (input.IsKeyDown(i, Keys.Left)) RotX -= rotationVelocity * elapsedTime; if (input.IsKeyDown(i, Keys.Right)) RotX += rotationVelocity * elapsedTime; if (Math.Abs(RotX) < 0.001f) RotX = -0.5f * elapsedTime; rotation[i] = rotation[i] * Matrix.CreateRotationY(RotX); // change ship (next) if (input.IsKeyPressed(i, Keys.Up) || input.IsButtonPressedDPadUp(i) || input.IsButtonPressedLeftStickUp(i)) { selection[i] = (selection[i] + 1) % NumberShips; gameManager.PlaySound("menu_change"); } // change ship (previous) if (input.IsKeyPressed(i, Keys.Down) || input.IsButtonPressedDPadDown(i) || input.IsButtonPressedLeftStickDown(i)) { if (selection[i] == 0) selection[i] = NumberShips - 1; else selection[i] = selection[i] - 1; gameManager.PlaySound("menu_change"); } } else { // cancel selection if (input.IsKeyPressed(i, Keys.Escape) || input.IsButtonPressedB(i)) { confirmed[i] = false; gameManager.PlaySound("menu_cancel"); } } // if both ships confirmed, go to game screen if (confirmed[0] && confirmed[1]) { if (gameManager.GameMode == GameMode.SinglePlayer) gameManager.SetShips(ships[selection[0]], null, invertY); else gameManager.SetShips(ships[selection[0]], ships[selection[1]], invertY); screenManager.SetNextScreen(ScreenType.ScreenLevel); } }
// process input public override void ProcessInput(float elapsedTime, InputManager input) { if (input == null) { throw new ArgumentNullException("input"); } for (int i = 0; i < 2; i++) { // A button or enter to select menu option if (input.IsButtonPressedA(i) || input.IsButtonPressedStart(i) || input.IsKeyPressed(i, Keys.Enter) || input.IsKeyPressed(i, Keys.Space)) { switch (menuSelection) { case 0: // single player gameManager.GameMode = GameMode.SinglePlayer; screenManager.SetNextScreen(ScreenType.ScreenPlayer); break; case 1: // multi player gameManager.GameMode = GameMode.MultiPlayer; screenManager.SetNextScreen(ScreenType.ScreenPlayer); break; case 2: // help screenManager.SetNextScreen(ScreenType.ScreenHelp); break; case 3: // exit game screenManager.Exit(); break; } gameManager.PlaySound("menu_select"); } // up/down keys change menu sel if (input.IsKeyPressed(i,Keys.Up) || input.IsButtonPressedDPadUp(i) || input.IsButtonPressedLeftStickUp(i)) { menuSelection = (menuSelection == 0 ? NumberMenuItems - 1 : menuSelection - 1); gameManager.PlaySound("menu_change"); } if (input.IsKeyPressed(i, Keys.Down) || input.IsButtonPressedDPadDown(i) || input.IsButtonPressedLeftStickDown(i)) { menuSelection = (menuSelection + 1) % NumberMenuItems; gameManager.PlaySound("menu_change"); } } }