//--------------------------------------------------------------------------------------------------------------------------------------------------- // // Copyright (C)2007 DarkWynter Studios. All rights reserved. // //--------------------------------------------------------------------------------------------------------------------------------------------------- // {License Information: Creative Commons} //--------------------------------------------------------------------------------------------------------------------------------------------------- //don't allow selecting fire //#define DISABLE_FIRE_ELEMENT namespace ElementalGame { #region Using Statements using System; using System.Diagnostics; using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Storage; #endregion // Game Controller can have either a Mouse/Keyboard or XBox controller or both. // It handles calling the controller interfaces of the system to ease portability between XBOX and PC // and to provide an abstract movement and action interface usable by human players, bots, and network players. public class GameController { #if !XBOX360 MouseState mouseState; const float MOUSE_ROTATION_SCALE = 0.005f; float lastMouseX, lastMouseY; int windowHeight, windowWidth; // Game window Height and Width for resetting the Mouse position int lastMouseWheelPos = 0; // Position of mouse wheel on element list #endif KeyboardState keyboardState; GamePadState gamePadState; const float GAMEPAD_ROTATION_SCALE_Y = 0.03f; const float GAMEPAD_ROTATION_SCALE_X = 0.03f; const float MENU_ANALOG_THRESHOLD = 0.4f; public enum ControllerType { PC_ONLY, XBOX_ONLY, PC_AND_XBOX, NONE } public ControllerType playerControllerType = ControllerType.NONE; public PlayerIndex playerControllerIndex; // Controller Number // These variables are used to make sure the button or key is released before we consider it as an input again. I would use a static local // for each of these inside its respective function but they aren't allowed in C#. -P // Addendum : nor would they be allowed in Java or C++ in nonstatic method. H private bool modeSwitchInputReleased = true; private bool attackSwitchInputReleased = true; private bool jumpKeyInputReleased = true; private bool fpsKeyInputReleased = true; private bool movementTypeInputReleased = true; private bool menuUpInputReleased = true; private bool menuDownInputReleased = true; private bool menuLeftInputReleased = true; private bool menuRightInputReleased = true; private bool menuStartInputReleased = true; private bool menuBackInputReleased = true; private bool startInputReleased = true; private bool backInputReleased = true; //-----------------------------Hack to enable Zoom------------------------------- private bool zoomInputReleased = true; private bool skipInputReleased = true; private bool blockStartBackInput = false; private Stopwatch dpadVerticalDelayTimer = new Stopwatch(); private Stopwatch dpadHorizontalDelayTimer = new Stopwatch(); public enum ElementalMode { FIRE_MODE, WATER_MODE, EARTH_MODE, WIND_MODE, TERRAIN_MODE, NONE }; public enum AttackMode { ATTACK, TERRAIN_MOD, NONE }; //private AttackMode lastAttackMode = AttackMode.NONE; public GameController() { modeSwitchInputReleased = true; attackSwitchInputReleased = true; movementTypeInputReleased = true; jumpKeyInputReleased = true; menuUpInputReleased = true; menuDownInputReleased = true; menuLeftInputReleased = true; menuRightInputReleased = true; menuStartInputReleased = true; menuBackInputReleased = true; startInputReleased = true; backInputReleased = true; blockStartBackInput = false; dpadHorizontalDelayTimer = new Stopwatch(); dpadVerticalDelayTimer = new Stopwatch(); } public GameController(ControllerType controllerType, PlayerIndex playerIndex, int gameWindowHeight, int gameWindowWidth) { #if !XBOX360 if (controllerType == ControllerType.PC_ONLY || controllerType == ControllerType.PC_AND_XBOX) { mouseState = new MouseState(); mouseState = Mouse.GetState(); lastMouseX = mouseState.X; lastMouseY = mouseState.Y; lastMouseWheelPos = 0; keyboardState = new KeyboardState(); playerControllerType = controllerType; } windowHeight = gameWindowHeight; windowWidth = gameWindowWidth; #endif if (controllerType == ControllerType.XBOX_ONLY || controllerType == ControllerType.PC_AND_XBOX) { gamePadState = new GamePadState(); playerControllerIndex = playerIndex; playerControllerType = controllerType; } modeSwitchInputReleased = true; attackSwitchInputReleased = true; movementTypeInputReleased = true; jumpKeyInputReleased = true; menuUpInputReleased = true; menuDownInputReleased = true; menuLeftInputReleased = true; menuRightInputReleased = true; menuStartInputReleased = true; menuBackInputReleased = true; startInputReleased = true; backInputReleased = true; blockStartBackInput = false; dpadHorizontalDelayTimer = Stopwatch.StartNew(); dpadVerticalDelayTimer = Stopwatch.StartNew(); } //Get FPS toggle button public bool GetFPSToggleButton() { if (fpsKeyInputReleased == true) { if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (keyboardState.IsKeyDown(Keys.F12)) { fpsKeyInputReleased = false; return true; } } if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (gamePadState.Buttons.LeftStick == ButtonState.Pressed) { fpsKeyInputReleased = false; return true; } } } else if (keyboardState.IsKeyUp(Keys.F12) && gamePadState.Buttons.LeftStick == ButtonState.Released) { fpsKeyInputReleased = true; } return false; } public void JustUnPaused() { //set the mouse cursor to the middle again and set last position #if !XBOX360 Mouse.SetPosition(windowWidth / 2, windowHeight / 2); lastMouseX = windowWidth / 2; lastMouseY = windowHeight / 2; #endif } public bool GetSkipButton() { if (skipInputReleased == true) { if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (keyboardState.IsKeyDown(Keys.X)) { skipInputReleased = false; return true; } } if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (gamePadState.Buttons.RightStick == ButtonState.Pressed) { skipInputReleased = false; return true; } } } else if (keyboardState.IsKeyUp(Keys.X) && gamePadState.Buttons.RightStick == ButtonState.Released) { skipInputReleased = true; } return false; } // Get key inputs for object rotation public Vector2 GetObjectRotation() { Vector2 mouseRotation = new Vector2(0.0f, 0.0f); Vector2 stickRotation = new Vector2(0.0f, 0.0f); #if !XBOX360 if (ElementalGame.WINDOW_IN_FOCUS) { if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (ElementalGame.gameState != ElementalGame.GameState.GAME_PAUSE) { if (mouseState.X > 0 && mouseState.X < windowWidth - 1 && mouseState.Y > 0 && mouseState.Y < windowHeight - 1) { if (lastMouseX != mouseState.X || lastMouseY != mouseState.Y) { float diffX = mouseState.X - lastMouseX; float diffY = mouseState.Y - lastMouseY; int xSign = (int)(diffX / Math.Abs(diffX)); int ySign = (int)(diffY / Math.Abs(diffY)); mouseRotation = new Vector2(MOUSE_ROTATION_SCALE * diffX, -MOUSE_ROTATION_SCALE * diffY); } } Mouse.SetPosition(windowWidth / 2, windowHeight / 2); lastMouseX = windowWidth / 2; lastMouseY = windowHeight / 2; } else { lastMouseX = mouseState.X; lastMouseY = mouseState.Y; } } } if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) #endif { int xSign = (int)(gamePadState.ThumbSticks.Right.X / Math.Abs(gamePadState.ThumbSticks.Right.X)); int ySign = (int)(gamePadState.ThumbSticks.Right.Y / Math.Abs(gamePadState.ThumbSticks.Right.Y)); stickRotation = new Vector2(GAMEPAD_ROTATION_SCALE_X * (gamePadState.ThumbSticks.Right.X * gamePadState.ThumbSticks.Right.X) * xSign, GAMEPAD_ROTATION_SCALE_Y * (gamePadState.ThumbSticks.Right.Y * gamePadState.ThumbSticks.Right.Y) * ySign); } // Window out of focus return mouseRotation + stickRotation; } // Get key inputs for object motion public Vector2 GetObjectMotion() { Vector2 motionVector = new Vector2(0.0f, 0.0f); if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (keyboardState.IsKeyDown(Keys.A)) { motionVector.X = -1.0f; } else if (keyboardState.IsKeyDown(Keys.D)) { motionVector.X = 1.0f; } //Moving if (keyboardState.IsKeyDown(Keys.W)) { motionVector.Y = 1.0f; } else if (keyboardState.IsKeyDown(Keys.S)) { motionVector.Y = -1.0f; } if (playerControllerType == ControllerType.PC_ONLY) { return motionVector; } } if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { int xSign = (int)(gamePadState.ThumbSticks.Left.X / Math.Abs(gamePadState.ThumbSticks.Left.X)); int ySign = (int)(gamePadState.ThumbSticks.Left.Y / Math.Abs(gamePadState.ThumbSticks.Left.Y)); motionVector += new Vector2((gamePadState.ThumbSticks.Left.X * gamePadState.ThumbSticks.Left.X) * xSign, (gamePadState.ThumbSticks.Left.Y * gamePadState.ThumbSticks.Left.Y) * ySign); if (playerControllerType == ControllerType.XBOX_ONLY) { return motionVector; } } return motionVector; } // Get key input for movement type (hover or walk) public bool GetMovementTypeToggle() { if (movementTypeInputReleased == true) { if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (keyboardState.IsKeyDown(Keys.LeftShift)) { movementTypeInputReleased = false; return true; } } if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (gamePadState.Buttons.LeftStick == ButtonState.Pressed) { movementTypeInputReleased = false; return true; } } } else if (gamePadState.Buttons.LeftStick == ButtonState.Released && keyboardState.IsKeyUp(Keys.LeftShift)) { movementTypeInputReleased = true; } return false; } // Get key inputs for Attack abilities public float GetAttackAmount() { if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { #if !XBOX360 if (mouseState.LeftButton == ButtonState.Pressed) { return 0.5f; } #endif } if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (gamePadState.Triggers.Right > 0.0f) { return gamePadState.Triggers.Right; } } return 0.0f; } // Get key inputs for Defense mode public float GetDefendAmount() { if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { #if !XBOX360 if (mouseState.RightButton == ButtonState.Pressed) { return 0.5f; } #endif } if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (gamePadState.Triggers.Left > 0.0f) { return gamePadState.Triggers.Left; } } return 0.0f; } //replace or modify this section to support the new elemental selection mode. // Get key inputs for Element Mode switching public ElementalMode GetElementModeSwitching(ElementalMode current) { ElementalMode elementSwitching = ElementalMode.NONE; int amount = 0; if (modeSwitchInputReleased == true && dpadHorizontalDelayTimer.ElapsedMilliseconds >= 100) { if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { #if !XBOX360 // Use the mousewheel to switch if (Math.Abs(mouseState.ScrollWheelValue - lastMouseWheelPos) >= 200) { amount = (int)((mouseState.ScrollWheelValue - lastMouseWheelPos) / 100.0f); lastMouseWheelPos = mouseState.ScrollWheelValue; dpadHorizontalDelayTimer = Stopwatch.StartNew(); } #endif if (keyboardState.IsKeyDown(Keys.F1) || amount < 0) { if (current == ElementalMode.FIRE_MODE) { elementSwitching = ElementalMode.EARTH_MODE; } else if(current == ElementalMode.WATER_MODE) { elementSwitching = ElementalMode.FIRE_MODE; } else if (current == ElementalMode.EARTH_MODE) { elementSwitching = ElementalMode.TERRAIN_MODE; } else if (current == ElementalMode.WIND_MODE) { elementSwitching = ElementalMode.WATER_MODE; } else if (current == ElementalMode.TERRAIN_MODE) { elementSwitching = ElementalMode.WIND_MODE; } else { elementSwitching = ElementalMode.EARTH_MODE; } modeSwitchInputReleased = false; } else if (keyboardState.IsKeyDown(Keys.F2) || amount > 0) { if (current == ElementalMode.FIRE_MODE) { elementSwitching = ElementalMode.WATER_MODE; } else if (current == ElementalMode.WATER_MODE) { elementSwitching = ElementalMode.WIND_MODE; } else if (current == ElementalMode.EARTH_MODE) { elementSwitching = ElementalMode.FIRE_MODE; } else if (current == ElementalMode.WIND_MODE) { elementSwitching = ElementalMode.TERRAIN_MODE; } else if (current == ElementalMode.TERRAIN_MODE) { elementSwitching = ElementalMode.EARTH_MODE; } else { elementSwitching = ElementalMode.EARTH_MODE; } modeSwitchInputReleased = false; } } //if we haven't already pressed something in keyboard and gamepad is enabled if (modeSwitchInputReleased == true && (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX)) { //begin cutting here if (gamePadState.Buttons.A == ButtonState.Pressed || gamePadState.Buttons.X == ButtonState.Pressed) { if (current == ElementalMode.FIRE_MODE) { elementSwitching = ElementalMode.EARTH_MODE; } else if (current == ElementalMode.WATER_MODE) { elementSwitching = ElementalMode.FIRE_MODE; } else if (current == ElementalMode.EARTH_MODE) { elementSwitching = ElementalMode.TERRAIN_MODE; } else if (current == ElementalMode.WIND_MODE) { elementSwitching = ElementalMode.WATER_MODE; } else if (current == ElementalMode.TERRAIN_MODE) { elementSwitching = ElementalMode.WIND_MODE; } else { elementSwitching = ElementalMode.EARTH_MODE; } modeSwitchInputReleased = false; } else if (gamePadState.Buttons.B == ButtonState.Pressed || gamePadState.Buttons.Y == ButtonState.Pressed) { if (current == ElementalMode.FIRE_MODE) { elementSwitching = ElementalMode.WATER_MODE; } else if (current == ElementalMode.WATER_MODE) { elementSwitching = ElementalMode.WIND_MODE; } else if (current == ElementalMode.EARTH_MODE) { elementSwitching = ElementalMode.FIRE_MODE; } else if (current == ElementalMode.WIND_MODE) { elementSwitching = ElementalMode.TERRAIN_MODE; } else if (current == ElementalMode.TERRAIN_MODE) { elementSwitching = ElementalMode.EARTH_MODE; } else { elementSwitching = ElementalMode.EARTH_MODE; } modeSwitchInputReleased = false; } } } else { if (gamePadState.Buttons.A == ButtonState.Released && gamePadState.Buttons.B == ButtonState.Released && gamePadState.Buttons.X == ButtonState.Released && gamePadState.Buttons.Y == ButtonState.Released && keyboardState.IsKeyUp(Keys.F1) && keyboardState.IsKeyUp(Keys.F2) && keyboardState.IsKeyUp(Keys.F4) && keyboardState.IsKeyUp(Keys.F3)) { modeSwitchInputReleased = true; } } return elementSwitching; } // Get key inputs for mass size change public int GetMassChangeDelta() { int amount = 0; if (dpadHorizontalDelayTimer.ElapsedMilliseconds >= 100) { if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { // 3 or R: Up if (keyboardState.IsKeyDown(Keys.D3) || keyboardState.IsKeyDown(Keys.R) || keyboardState.IsKeyDown(Keys.Up)) { amount += 5; dpadHorizontalDelayTimer = Stopwatch.StartNew(); } // 4 or F: Down else if (keyboardState.IsKeyDown(Keys.D4) || keyboardState.IsKeyDown(Keys.F) || keyboardState.IsKeyDown(Keys.Down)) { amount -= 5; dpadHorizontalDelayTimer = Stopwatch.StartNew(); } } // If gamepad is enabled if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { // Up if (gamePadState.DPad.Up == ButtonState.Pressed) { amount += 5; dpadHorizontalDelayTimer = Stopwatch.StartNew(); } // Down else if (gamePadState.DPad.Down == ButtonState.Pressed) { amount -= 5; dpadHorizontalDelayTimer = Stopwatch.StartNew(); } } } return amount; } // Get key inputs for temperature change public int GetThermalChangeDelta() { int amount = 0; if (dpadVerticalDelayTimer.ElapsedMilliseconds >= 100) { if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { // 1 or Q: Left if (keyboardState.IsKeyDown(Keys.D1) || keyboardState.IsKeyDown(Keys.Q) || keyboardState.IsKeyDown(Keys.Left)) { amount -= 5; dpadVerticalDelayTimer = Stopwatch.StartNew(); } // 2 or E: Right else if (keyboardState.IsKeyDown(Keys.D2) || keyboardState.IsKeyDown(Keys.E) || keyboardState.IsKeyDown(Keys.Right)) { amount += 5; dpadVerticalDelayTimer = Stopwatch.StartNew(); } } // If gamepad is enabled if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { // Left if (gamePadState.DPad.Left == ButtonState.Pressed) { amount -= 5; dpadVerticalDelayTimer = Stopwatch.StartNew(); } // Right else if (gamePadState.DPad.Right == ButtonState.Pressed) { amount += 5; dpadVerticalDelayTimer = Stopwatch.StartNew(); } } } return amount; } // Get key inputs for jumping public bool GetJumpKey() { if (jumpKeyInputReleased == true) { if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (keyboardState.IsKeyDown(Keys.Space)) { jumpKeyInputReleased = false; return true; } } if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (gamePadState.Buttons.LeftShoulder == ButtonState.Pressed) { jumpKeyInputReleased = false; return true; } } } else if (keyboardState.IsKeyUp(Keys.Space) && gamePadState.Buttons.LeftShoulder == ButtonState.Released) { jumpKeyInputReleased = true; } return false; } public void SetJumpReleased(bool b) { jumpKeyInputReleased = b; } public bool GetMenuLeft() { if (menuLeftInputReleased == true) { if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (keyboardState.IsKeyDown(Keys.Left)) { menuLeftInputReleased = false; return true; } } if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (gamePadState.DPad.Left == ButtonState.Pressed || gamePadState.ThumbSticks.Left.X < -MENU_ANALOG_THRESHOLD) { menuLeftInputReleased = false; return true; } } } else if (gamePadState.DPad.Left == ButtonState.Released && gamePadState.ThumbSticks.Left.X == 0 && keyboardState.IsKeyUp(Keys.Left)) { menuLeftInputReleased = true; } return false; } public bool GetMenuRight() { if (menuRightInputReleased == true) { if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (keyboardState.IsKeyDown(Keys.Right)) { menuRightInputReleased = false; return true; } } if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (gamePadState.DPad.Right == ButtonState.Pressed || gamePadState.ThumbSticks.Left.X > MENU_ANALOG_THRESHOLD) { menuRightInputReleased = false; return true; } } } else if (gamePadState.DPad.Right == ButtonState.Released && gamePadState.ThumbSticks.Left.X == 0 && keyboardState.IsKeyUp(Keys.Right)) { menuRightInputReleased = true; } return false; } public bool GetMenuUp() { if (menuUpInputReleased == true) { if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (keyboardState.IsKeyDown(Keys.Up)) { menuUpInputReleased = false; return true; } } if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (gamePadState.DPad.Up == ButtonState.Pressed || gamePadState.ThumbSticks.Left.Y > MENU_ANALOG_THRESHOLD) { menuUpInputReleased = false; return true; } } } else if (gamePadState.DPad.Up == ButtonState.Released && gamePadState.ThumbSticks.Left.Y == 0 && keyboardState.IsKeyUp(Keys.Up)) { menuUpInputReleased = true; } return false; } public bool GetMenuDown() { if (menuDownInputReleased == true) { if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (keyboardState.IsKeyDown(Keys.Down)) { menuDownInputReleased = false; return true; } } if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (gamePadState.DPad.Down == ButtonState.Pressed || gamePadState.ThumbSticks.Left.Y < -MENU_ANALOG_THRESHOLD) { menuDownInputReleased = false; return true; } } } else if (gamePadState.DPad.Down == ButtonState.Released && gamePadState.ThumbSticks.Left.Y == 0 && keyboardState.IsKeyUp(Keys.Down)) { menuDownInputReleased = true; } return false; } public void SetBlockStartBackInput(bool block) { blockStartBackInput = block; } public bool IsStartBackInputBlocked() { return blockStartBackInput; } public bool GetStartPressed() { if (startInputReleased == true && blockStartBackInput == false) { if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (keyboardState.IsKeyDown(Keys.Enter)) { startInputReleased = false; return true; } } if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (gamePadState.Buttons.Start == ButtonState.Pressed) { startInputReleased = false; return true; } } } else if (keyboardState.IsKeyUp(Keys.Enter) && gamePadState.Buttons.Start == ButtonState.Released) { startInputReleased = true; } return false; } public bool GetBackPressed() { if (backInputReleased == true && blockStartBackInput == false) { if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (keyboardState.IsKeyDown(Keys.Escape)) { backInputReleased = false; return true; } } if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (gamePadState.Buttons.Back == ButtonState.Pressed) { backInputReleased = false; return true; } } } else if (keyboardState.IsKeyUp(Keys.Escape) && gamePadState.Buttons.Back == ButtonState.Released) { backInputReleased = true; } return false; } public bool GetMenuStartPressed() { if (menuStartInputReleased == true && blockStartBackInput == false) { if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (keyboardState.IsKeyDown(Keys.Enter)) { menuStartInputReleased = false; return true; } } if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (gamePadState.Buttons.Start == ButtonState.Pressed || gamePadState.Buttons.A == ButtonState.Pressed) { menuStartInputReleased = false; return true; } } } else if (keyboardState.IsKeyUp(Keys.Enter) && gamePadState.Buttons.Start == ButtonState.Released && gamePadState.Buttons.A == ButtonState.Released) { menuStartInputReleased = true; } return false; } public bool GetMenuBackPressed() { if (menuBackInputReleased == true && blockStartBackInput == false) { if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (keyboardState.IsKeyDown(Keys.Escape)) { menuBackInputReleased = false; return true; } } if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { if (gamePadState.Buttons.Back == ButtonState.Pressed || gamePadState.Buttons.B == ButtonState.Pressed) { menuBackInputReleased = false; return true; } } } else if (keyboardState.IsKeyUp(Keys.Escape) && gamePadState.Buttons.Back == ButtonState.Released && gamePadState.Buttons.B == ButtonState.Released) { menuBackInputReleased = true; } return false; } public bool GetAllStartReleased() { if (keyboardState.IsKeyUp(Keys.Enter) && gamePadState.Buttons.Start == ButtonState.Released && gamePadState.Buttons.A == ButtonState.Released) { return true; } return false; } public bool GetAllBackReleased() { if (keyboardState.IsKeyUp(Keys.Escape) && gamePadState.Buttons.Back == ButtonState.Released && gamePadState.Buttons.B == ButtonState.Released) { return true; } return false; } public bool GetMenuStartBackReleased() { return (GetAllBackReleased() && GetAllStartReleased()); } public void AnyButtonPressed() { if ((modeSwitchInputReleased && attackSwitchInputReleased && jumpKeyInputReleased && zoomInputReleased && fpsKeyInputReleased && menuUpInputReleased && menuDownInputReleased && menuLeftInputReleased && menuRightInputReleased && startInputReleased && backInputReleased) == false) { ElementalGame.jiggler.Reset(); ElementalGame.jiggler.Start(); } } // Gets current key inputs from controllers public void UpdateControllers() { #if !XBOX360 if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { //We don't want to give mouse/keyboard controls when the window is not in focus if (ElementalGame.WINDOW_IN_FOCUS) { mouseState = Mouse.GetState(); keyboardState = Keyboard.GetState(); } } #endif if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX) { gamePadState = GamePad.GetState(playerControllerIndex); } } } }