本文整理汇总了C#中GameStateManagement.InputState.IsPauseGame方法的典型用法代码示例。如果您正苦于以下问题:C# InputState.IsPauseGame方法的具体用法?C# InputState.IsPauseGame怎么用?C# InputState.IsPauseGame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameStateManagement.InputState
的用法示例。
在下文中一共展示了InputState.IsPauseGame方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleInput
public override void HandleInput(InputState input)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
//Go back to the previous screen if the player presses the back button
if (input.IsPauseGame(null))
{
Exit();
}
// Return to the main menu when a tap gesture is recognized
if (input.Gestures.Count > 0)
{
GestureSample sample = input.Gestures[0];
if (sample.GestureType == GestureType.Tap)
{
Exit();
input.Gestures.Clear();
}
}
}
示例2: HandleInput
/// <summary>
/// Handle user input.
/// </summary>
/// <param name="input">User input information.</param>
public override void HandleInput(InputState input)
{
if (input.IsPauseGame(null))
{
PauseCurrentGame();
}
base.HandleInput(input);
}
示例3: HandleInput
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(null), ControllingPlayer);
}
}
示例4: HandleInput
/// <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
}
}
示例5: HandleInput
public override void HandleInput(InputState input)
{
if (input == null)
throw new ArgumentNullException("input");
if (input.IsPauseGame(null))
{
if (!gameOver)
PauseCurrentGame();
else
FinishCurrentGame();
}
if (IsActive && !startScreen)
{
if (input.Gestures.Count > 0)
{
GestureSample sample = input.Gestures[0];
if (sample.GestureType == GestureType.Tap)
{
if (gameOver)
FinishCurrentGame();
}
}
if (!gameOver)
{
// Rotate the maze according to accelerometer data
Vector3 currentAccelerometerState =
Accelerometer.GetState().Acceleration;
if (Microsoft.Devices.Environment.DeviceType == DeviceType.Device)
{
//Change the velocity according to acceleration reading
maze.Rotation.Z = (float)Math.Round(MathHelper.ToRadians(
currentAccelerometerState.Y * 30), 2);
maze.Rotation.X = -(float)Math.Round(MathHelper.ToRadians(
currentAccelerometerState.X * 30), 2);
}
else if (Microsoft.Devices.Environment.DeviceType ==
DeviceType.Emulator)
{
Vector3 Rotation = Vector3.Zero;
if (currentAccelerometerState.X != 0)
{
if (currentAccelerometerState.X > 0)
Rotation += new Vector3(0, 0, -angularVelocity);
else
Rotation += new Vector3(0, 0, angularVelocity);
}
if (currentAccelerometerState.Y != 0)
{
if (currentAccelerometerState.Y > 0)
Rotation += new Vector3(-angularVelocity, 0, 0);
else
Rotation += new Vector3(angularVelocity, 0, 0);
}
// Limit the rotation of the maze to 30 degrees
maze.Rotation.X =
MathHelper.Clamp(maze.Rotation.X + Rotation.X,
MathHelper.ToRadians(-30), MathHelper.ToRadians(30));
maze.Rotation.Z =
MathHelper.Clamp(maze.Rotation.Z + Rotation.Z,
MathHelper.ToRadians(-30), MathHelper.ToRadians(30));
}
}
}
}
示例6: HandleInput
/// <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");
if (input.IsPauseGame(ControllingPlayer))
{
ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer);
}
else
{
}
}
示例7: HandleInput
/// <summary>
/// Input helper method provided by GameScreen. Packages up the various input
/// values for ease of use.
/// </summary>
/// <param name="input">The state of the gamepads</param>
public void HandleInput(InputState input)
{
if (input == null)
throw new ArgumentNullException("input");
if (gameOver)
{
if (input.IsPauseGame(null))
{
FinishCurrentGame();
}
foreach (GestureSample gestureSample in input.Gestures)
{
if (gestureSample.GestureType == GestureType.Tap)
{
FinishCurrentGame();
}
}
return;
}
if (input.IsPauseGame(null))
{
PauseCurrentGame();
}
else if (!isTwoHumanPlayers && isFirstPlayerTurn &&
(playerOne.Catapult.CurrentState == CatapultState.Idle ||
playerOne.Catapult.CurrentState == CatapultState.Aiming))
{
// Read all available gestures
foreach (GestureSample gestureSample in input.Gestures)
{
if (gestureSample.GestureType == GestureType.FreeDrag)
isDragging = true;
else if (gestureSample.GestureType == GestureType.DragComplete)
isDragging = false;
playerOne.HandleInput(gestureSample);
}
}
else if (!isPaused&&isTwoHumanPlayers && isFirstPlayerTurn && GlobalContext.PlayerIsFirstOnAppWarp &&(GlobalContext.joinedUsers.Length == 2)&&
(playerOne.Catapult.CurrentState == CatapultState.Idle ||
playerOne.Catapult.CurrentState == CatapultState.Aiming))
{
// Read all available gestures
foreach (GestureSample gestureSample in input.Gestures)
{
if (gestureSample.GestureType == GestureType.FreeDrag)
isDragging = true;
else if (gestureSample.GestureType == GestureType.DragComplete)
isDragging = false;
playerOne.HandleInput(gestureSample);
}
}
else if (!isPaused&&isTwoHumanPlayers && !isFirstPlayerTurn && !GlobalContext.PlayerIsFirstOnAppWarp && (GlobalContext.joinedUsers.Length == 2) &&
(playerTwo.Catapult.CurrentState == CatapultState.Idle ||
playerTwo.Catapult.CurrentState == CatapultState.Aiming))
{
// Read all available gestures
foreach (GestureSample gestureSample in input.Gestures)
{
if (gestureSample.GestureType == GestureType.FreeDrag)
isDragging = true;
else if (gestureSample.GestureType == GestureType.DragComplete)
isDragging = false;
(playerTwo as Human).HandleInput(gestureSample);
}
}
}
示例8: HandleInput
/// <summary>
/// Input helper method provided by GameScreen. Packages up the various input
/// values for ease of use.
/// </summary>
/// <param name="input">The state of the gamepads</param>
public override void HandleInput (InputState input)
{
if (input == null)
throw new ArgumentNullException ("input");
if (gameOver) {
if (input.IsPauseGame (null)) {
FinishCurrentGame ();
}
if (input.MouseGesture.HasFlag(MouseGestureType.LeftClick))
FinishCurrentGame();
foreach (GestureSample gestureSample in input.Gestures) {
if (gestureSample.GestureType == GestureType.Tap) {
FinishCurrentGame ();
}
}
return;
}
if (NetworkSession != null) {
if ((isFirstPlayerTurn && !NetworkSession.IsHost)
|| (!isFirstPlayerTurn && NetworkSession.IsHost))
return;
}
if (input.IsPauseGame (null)) {
PauseCurrentGame ();
} else if (isFirstPlayerTurn &&
(playerOne.Catapult.CurrentState == CatapultState.Idle ||
playerOne.Catapult.CurrentState == CatapultState.Aiming)) {
// First we try with mouse input
playerOne.HandleInput (input);
isDragging = playerOne.isDragging;
// Read all available gestures
foreach (GestureSample gestureSample in input.Gestures) {
if (gestureSample.GestureType == GestureType.FreeDrag)
isDragging = true;
else if (gestureSample.GestureType == GestureType.DragComplete)
isDragging = false;
playerOne.HandleInput (gestureSample);
}
} else if (!isFirstPlayerTurn &&
(playerTwo.Catapult.CurrentState == CatapultState.Idle ||
playerTwo.Catapult.CurrentState == CatapultState.Aiming)) {
// First we try with mouse input
playerTwo.HandleInput (input);
isDragging = playerTwo.isDragging;
// Read all available gestures
foreach (GestureSample gestureSample in input.Gestures) {
if (gestureSample.GestureType == GestureType.FreeDrag)
isDragging = true;
else if (gestureSample.GestureType == GestureType.DragComplete)
isDragging = false;
playerTwo.HandleInput (gestureSample);
}
}
}
示例9: HandleInput
public override void HandleInput(InputState input)
{
if (input == null)
throw new ArgumentNullException("input");
if (input.IsPauseGame(null))
{
Exit();
}
// Return to main menu when tap on the phone
if (input.Gestures.Count > 0)
{
GestureSample sample = input.Gestures[0];
if (sample.GestureType == GestureType.Tap)
{
Exit();
input.Gestures.Clear();
}
}
}
示例10: HandleInput
/// <summary>
/// Responds to user input, changing the selected entry and accepting
/// or cancelling the menu.
/// Overriding to allow start,back,esc to unpause game
/// </summary>
public override void HandleInput(InputState input)
{
if (input.IsPauseGame(ControllingPlayer))
{
OnCancel(ControllingPlayer ?? PlayerIndex.One);
return;
}
base.HandleInput(input);
}
示例11: HandleInput
/// <summary>
/// Input helper method provided by GameScreen. Packages up the various /// input values for ease of use.
/// </summary>
/// <param name="input">The state of the gamepads</param>
public override void HandleInput(InputState input)
{
PlayerIndex player;
if (input == null)
throw new ArgumentNullException("input");
if (input.IsNewKeyPress(Keys.F12, out player))
{
if (!Windows.UI.ViewManagement.ApplicationView
.GetForCurrentView().IsFullScreen)
Windows.UI.ViewManagement.ApplicationView
.GetForCurrentView().TryEnterFullScreenMode();
else
Windows.UI.ViewManagement.ApplicationView
.GetForCurrentView().ExitFullScreenMode();
}
if (gameOver)
{
if (input.IsPauseGame())
{
FinishCurrentGame();
}
if (input.IsNewKeyPress(Keys.Space, out player)
|| input.IsNewKeyPress(Keys.Enter, out player))
{
FinishCurrentGame();
}
if (input.IsNewGamePadButtonPress(Buttons.A, out player)
|| input.IsNewGamePadButtonPress(Buttons.Start, out player))
{
FinishCurrentGame();
}
if (input.IsNewMouseButtonPress(MouseButtons.LeftButton,
out player))
{
FinishCurrentGame();
}
foreach (GestureSample gestureSample in input.Gestures)
{
if (gestureSample.GestureType == GestureType.Tap)
{
FinishCurrentGame();
}
}
return;
}
}
示例12: HandleInput
/// <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;
// get the keyboard state
/** TODO - Kelner - Do gamepad shits **/
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("pause"), ControllingPlayer);
}
// let the hero noodle on the input as well
theHero.handleInput(keyboardState, _oldKeyState);
// Kelner - store to know old state
_oldKeyState = keyboardState;
base.HandleInput(input);
}
示例13: HandleInput
/// <summary>
/// Добавим реакцию игры на действия пользователя. В отличии от метода Апдейт,
/// этот метод будет вызван, когда экран Геймплей будет активным.
/// </summary>
public override void HandleInput(InputState input)
{
if (input == null)
throw new ArgumentNullException("input");
///Проверка действий для действий пользователя
int playerIndex = (int)ControllingPlayer.Value;
KeyboardState keyboardState = input.CurrentKeyboardStates[playerIndex];
GamePadState gamePadState = input.CurrentGamePadStates[playerIndex];
//Игра будет в режиме паузы, если пользователь нажал на паузу, или если
/// он отключил активный геймпад. Это требуется для того, чтобы мы следили
/// когда геймпад включен, потому что мы не хотим ставить на паузу игру
/// на ПК, если они играют на клаве и у них нету геймпада!!!!!!!!!!
bool gamePadDisconnected = !gamePadState.IsConnected &&
input.GamePadWasConnected[playerIndex];
if (input.IsPauseGame(ControllingPlayer) || gamePadDisconnected)
{
ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer);
}
else
{
// Иначе передвигаем позицию игрока
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;
}
}
示例14: HandleInput
/// <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 (gameObjectManager.isLevelCompleted())
{
ScreenManager.AddScreen(new LevelCompleteScreen(), ControllingPlayer);
}
else if(gameObjectManager.isGameOver())
{
ScreenManager.AddScreen(new GameOverScreen(), ControllingPlayer);
}
else 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--;
lastMove = 1;
}
if (keyboardState.IsKeyDown(Keys.Right))
{
movement.X++;
lastMove = 3;
}
if (keyboardState.IsKeyDown(Keys.Up))
{
movement.Y--;
lastMove = 0;
}
if (keyboardState.IsKeyDown(Keys.Down))
{
movement.Y++;
lastMove = 2;
}
#region codes
if (keyboardState.IsKeyDown(Keys.D0))
{
if (code.Count == 4)
code.RemoveAt(0);
if(code[code.Count-1] != 0)
code.Add(0);
}
if (keyboardState.IsKeyDown(Keys.D1))
{
if (code.Count == 4)
code.RemoveAt(0);
if (code[code.Count - 1] != 1)
code.Add(1);
}
if (keyboardState.IsKeyDown(Keys.D2))
{
if (code.Count == 4)
code.RemoveAt(0);
if (code[code.Count - 1] != 2)
code.Add(2);
}
if (keyboardState.IsKeyDown(Keys.D3))
{
if (code.Count == 4)
code.RemoveAt(0);
if (code[code.Count - 1] != 3)
code.Add(3);
}
if (keyboardState.IsKeyDown(Keys.D4))
{
if (code.Count == 4)
//.........这里部分代码省略.........
示例15: HandleInput
// END DEBUG
/// <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.
//for(int playerIndex = 0; playerIndex < Math.Min(players.Count, InputState.MaxInputs); ++playerIndex) {
foreach(Player cP in players) {
KeyboardState keyboardState = input.CurrentKeyboardStates[(int)cP.PI];
GamePadState gamePadState = input.CurrentGamePadStates[(int)cP.PI];
// 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[(int)cP.PI];
if (input.IsPauseGame(cP.PI) || gamePadDisconnected)
{
ScreenManager.AddScreen(new PauseMenuScreen(), cP.PI);
}
else if (curGameState == GameState.Placement)
{
HandlePlacementInputButtons(input, cP);
}
else if (curGameState == GameState.Playing)
{
HandleGameplayInputButtons(input, cP);
}
// Otherwise move the player position.
if (true)
{
Vector2 movement = Vector2.Zero;
if (true)//cP.PI == PlayerIndex.One)
{
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();
cP.pos += movement * 10;
//if (cP.pos.X < offset.X)
// cP.pos.X = offset.X;
//if (cP.pos.Y < offset.Y)
// cP.pos.Y = offset.Y;
//if (cP.pos.X > COLS * country.Width + offset.X - 1)
// cP.pos.X = COLS * country.Width + offset.X - 1;
//if (cP.pos.Y > ROWS * country.Height + offset.Y - 1)
// cP.pos.Y = ROWS * country.Height + offset.Y - 1;
if (cP.pos.X < 0)
{
if (OptionsMenuScreen.currentMap == OptionsMenuScreen.Map.World)
cP.pos.X = screenWidth;
else
cP.pos.X = 0;
}
if (cP.pos.Y < 0)
cP.pos.Y = 0;
if (cP.pos.X > screenWidth)
{
if (OptionsMenuScreen.currentMap == OptionsMenuScreen.Map.World)
cP.pos.X = 0;
else
cP.pos.X = screenWidth;
}
if (cP.pos.Y > screenHeight)
cP.pos.Y = screenHeight;
cP.hover = closestCountry(cP.pos);
//.........这里部分代码省略.........