当前位置: 首页>>代码示例>>C#>>正文


C# InputState.IsTankMovingRight方法代码示例

本文整理汇总了C#中GameStateManagement.InputState.IsTankMovingRight方法的典型用法代码示例。如果您正苦于以下问题:C# InputState.IsTankMovingRight方法的具体用法?C# InputState.IsTankMovingRight怎么用?C# InputState.IsTankMovingRight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameStateManagement.InputState的用法示例。


在下文中一共展示了InputState.IsTankMovingRight方法的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
//.........这里部分代码省略.........
开发者ID:ProjPossibility,项目名称:USC-AccessibleKinect,代码行数:101,代码来源:GameplayScreen.cs


注:本文中的GameStateManagement.InputState.IsTankMovingRight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。