Created
May 25, 2009 12:07
-
-
Save robc/117516 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override void HandleInput() | |
{ | |
if (!IsActive) return; | |
#if XBOX | |
if (!playerInputMapper.IsConnected || playerInputMapper.Pause) | |
#else | |
if (playerInputMapper.Pause) | |
#endif | |
AddExtraScreen(new PauseMenuScreen()); | |
else | |
{ | |
yawInput = -playerInputMapper.Rotation; | |
thrustInput = playerInputMapper.Thrust; | |
firePressed = playerInputMapper.FireWeapon; | |
hyperspacePressed = playerInputMapper.EnterHyperspace; | |
} | |
} | |
private void AddExtraScreen(GameScreen screen) | |
{ | |
player.KillEngine(); | |
playerInputMapper.KillRumble(); | |
ScreenManager.AddScreen(screen); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Microsoft.Xna.Framework; | |
using Microsoft.Xna.Framework.Input; | |
using ThraeX.Input; | |
namespace RockBlaster | |
{ | |
public class MeteorSwarmInputMapper: GameInputMapper | |
{ | |
public MeteorSwarmInputMapper(PlayerIndex playerIndex) : base(playerIndex) | |
{ } | |
public float Rotation | |
{ | |
get | |
{ | |
if (CurrentGamePadState.ThumbSticks.Left.X != 0f) | |
return CurrentGamePadState.ThumbSticks.Left.X; | |
if (CurrentGamePadState.DPad.Left == ButtonState.Pressed) return -1f; | |
if (CurrentGamePadState.DPad.Right == ButtonState.Pressed) return 1f; | |
return IsKeyDownForThumbstick(GetKeyForAction(GameConstants.TURN_LEFT_ACTION), GetKeyForAction(GameConstants.TURN_RIGHT_ACTION)); | |
} | |
} | |
public float Thrust | |
{ | |
get | |
{ | |
if (CurrentGamePadState.Triggers.Right != 0f) return CurrentGamePadState.Triggers.Right; | |
if (CurrentGamePadState.Triggers.Left != 0f) return CurrentGamePadState.Triggers.Left; | |
return this.IsKeyDownForTrigger(GetKeyForAction(GameConstants.THRUST_ACTION)); | |
} | |
} | |
public bool FireWeapon | |
{ | |
get | |
{ | |
return IsButtonReleased(Buttons.A) || IsKeyReleased(GetKeyForAction(GameConstants.FIRE_WEAPON_ACTION)); | |
} | |
} | |
public bool EnterHyperspace | |
{ | |
get | |
{ | |
return IsButtonReleased(Buttons.B) || IsKeyReleased(GetKeyForAction(GameConstants.HYPERSPACE_ACTION)); | |
} | |
} | |
public bool HighScoreScrollUpTap | |
{ | |
get { return MenuUpTap; } | |
} | |
public TimeSpan HighScoreScrollUpTime | |
{ | |
get { return MenuUpTime; } | |
} | |
public bool HighScoreScrollDownTap | |
{ | |
get { return MenuDownTap; } | |
} | |
public TimeSpan HighScoreScrollDownTime | |
{ | |
get { return MenuDownTime; } | |
} | |
public bool HighScoreEnterLetter | |
{ | |
get | |
{ | |
return IsButtonReleased(Buttons.A) | |
|| IsKeyReleased(GetKeyForAction(GameConstants.FIRE_WEAPON_ACTION)); | |
} | |
} | |
public bool HighScoreDeleteLetter | |
{ | |
get | |
{ | |
return IsButtonReleased(Buttons.B) | |
|| IsKeyReleased(GetKeyForAction(GameConstants.HYPERSPACE_ACTION)); | |
} | |
} | |
public bool HighScoreAccept | |
{ | |
get | |
{ | |
return IsButtonReleased(Buttons.Start) | |
|| IsKeyReleased(Keys.Enter); | |
} | |
} | |
public bool ChangeHighScoreTable | |
{ | |
get | |
{ | |
return IsButtonReleased(Buttons.Y) | |
|| IsKeyReleased(Keys.C); | |
} | |
} | |
public void EngineRumble(float thrustAmount) | |
{ | |
if (thrustAmount == 0f) | |
KillRumble(); | |
else | |
{ | |
float transformedThrust = FormulaHelpers.NormaliseThrustAmount(thrustAmount); | |
SetRumble(transformedThrust, transformedThrust); | |
} | |
} | |
public void ExplosionRumble() | |
{ | |
RumbleStrength = 0.4f; | |
RumbleTime = new TimeSpan(0, 0, 3); | |
EnableTimedRumble = true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment