本文整理汇总了C#中GameStateManagement.InputState.IsTankMovingLeft方法的典型用法代码示例。如果您正苦于以下问题:C# InputState.IsTankMovingLeft方法的具体用法?C# InputState.IsTankMovingLeft怎么用?C# InputState.IsTankMovingLeft使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameStateManagement.InputState
的用法示例。
在下文中一共展示了InputState.IsTankMovingLeft方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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 (input.IsPauseGame(ControllingPlayer) || gamePadDisconnected)
{
ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer);
}
else
{
if (input.IsTankFire(ControllingPlayer)) {
if (isPlayer1Turn)
{
double missileAngle = ((player1.shotAngle /** (Math.PI / 180)*/));
Console.WriteLine("The missile angle is: "+missileAngle);
Projectile missile;
if (missileAngle < 0)
{
missile = new Projectile(ScreenManager.Game,
new Vector2(player1.cannonLocation.X - (float)(Math.Cos(missileAngle) * player1.cannonTexture.Height), (float)(Math.Sin(missileAngle) * player1.cannonTexture.Height) + player1.cannonLocation.Y - player1.texture.Height), new Vector2(-player1.force, player1.force));
}
else
{
missile = new Projectile(ScreenManager.Game,
new Vector2(player1.cannonLocation.X + (float)(Math.Cos(missileAngle) * player1.cannonTexture.Height), (float)(Math.Sin(missileAngle) * player1.cannonTexture.Height) + player1.cannonLocation.Y - player1.texture.Height), new Vector2(player1.force, player1.force));
}
player1.fireMissile(missile);
ScreenManager.Game.Components.Add(missile);
}
else
{
double missileAngle = ((player2.shotAngle /** (Math.PI / 180)*/));
Console.WriteLine("The missile angle is: " + missileAngle);
Projectile missile;
if (missileAngle < 0)
{
missile = new Projectile(ScreenManager.Game,
new Vector2(player2.cannonLocation.X - (float)(Math.Cos(missileAngle) * player2.cannonTexture.Height), (float)(Math.Sin(missileAngle) * player2.cannonTexture.Height) + player2.cannonLocation.Y - player2.texture.Height), new Vector2(player2.force, player2.force));
}
else
{
missile = new Projectile(ScreenManager.Game,
new Vector2(player2.cannonLocation.X + (float)(Math.Cos(missileAngle) * player2.cannonTexture.Height), (float)(Math.Sin(missileAngle) * player2.cannonTexture.Height) + player2.cannonLocation.Y - player2.texture.Height), new Vector2(-player2.force, player2.force));
}
player2.fireMissile(missile);
ScreenManager.Game.Components.Add(missile);
}
}
if (input.IsTankMovingLeft(ControllingPlayer))
{
if (isPlayer1Turn)
{
player1.moveTank("Left");
}
else
{
player2.moveTank("Left");
}
}
if (input.IsTankMovingRight(ControllingPlayer))
{
if (isPlayer1Turn)
{
player1.moveTank("Right");
}
else
{
player2.moveTank("Right");
}
}
if (input.IsAimUp(ControllingPlayer))
{
if (isPlayer1Turn)
{
player1.changeAim("Up");
}
else
//.........这里部分代码省略.........