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


C# InputState.IsPauseGame方法代码示例

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


在下文中一共展示了InputState.IsPauseGame方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
            }
        }
开发者ID:PhoenixWright,项目名称:Mystery,代码行数:27,代码来源:ConversationScreen.cs

示例2: 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)
            {
                return;
            }

            // Look up inputs for the active player profile.
            if (ControllingPlayer == null)
            {
                Debug.WriteLine("ControllingPlayer is null...");
                return;
            }
            var playerIndex = (int)ControllingPlayer.Value;

            var keyboardState = input.CurrentKeyboardStates[playerIndex];
            var 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!
            var gamePadDisconnected = !gamePadState.IsConnected &&
                                      input.GamePadWasConnected[playerIndex];

            if (input.IsPauseGame(ControllingPlayer) || gamePadDisconnected)
            {
                const string message = "Pause. Do you really want to exit game?";
                var confirmExit = new DecisionScreen(message);
                confirmExit.Accepted += ConfirmExitGameAccepted;
                ScreenManager.AddScreen(confirmExit, ControllingPlayer);
            }
        }
开发者ID:CTU-FEE-Y39PHA-43-2010,项目名称:BombermanAdventure,代码行数:37,代码来源:PlayingScreen.cs

示例3: HandleInput

        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when this 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.
            if (ControllingPlayer != null)
            {
                var playerIndex = (int)ControllingPlayer.Value;

                var 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!
                var gamePadDisconnected = !gamePadState.IsConnected &&
                                          input.GamePadWasConnected[playerIndex];

                if (!input.IsPauseGame(ControllingPlayer) && !gamePadDisconnected) return;
            }

            ScreenManager.AddScreen(new PauseMenuScreen(_eventManager), ControllingPlayer);
            //  Otherwise send our game events corresponding to input received.

        }
开发者ID:jo215,项目名称:Iso,代码行数:30,代码来源:LobbyScreen.cs

示例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");

            // Look up inputs for the active player profile.
            int playerIndex = (int)ControllingPlayer.Value;

            KeyboardState keyboardState = input.CurrentKeyboardStates[playerIndex];
            GamePadState gamePadState = input.CurrentGamePadStates[playerIndex];

            PlayerIndex player;
            if (input.IsPauseGame(ControllingPlayer))
            {
                PauseBackgroundScreen pauseBG = new PauseBackgroundScreen();
                ScreenManager.AddScreen(pauseBG, ControllingPlayer);
                ScreenManager.AddScreen(new PauseMenuScreen(pauseBG), ControllingPlayer);

            }

            if(IsActive)
            {
                if (input.MouseDragging)
                {
                    gameCamera.Target -= input.MouseDelta;
                    //gameCamera.cl
                }

                if (input.DragGesture.HasValue)
                {
                    gameCamera.Target -= input.DragGesture.Value.Delta;
                }

                if (input.IsNewKeyPress(Keys.Space, null, out player)) gameHero.Position = gameHero.SpawnPoint;

                if (!gameButtonManager.HandleInput(input))
                {
                    if (input.TapPosition.HasValue)
                    {
                        Vector2 tapPos = input.TapPosition.Value;

                        tapPos += gameCamera.Position;

                        Point tilePos = new Point((int)tapPos.X / 64, (int)tapPos.Y / 64);

                        var t = gameMap.Layers.Where(l => l.Name == "FG").First();
                        TileLayer tileLayer = t as TileLayer;

                        bool found = false;

                        int type = gameButtonManager.SelectedButton;

                        if (gameButtonManager.Buttons[gameButtonManager.SelectedButton].CurrentCoolDown <= 0)
                        {

                            if (type != 4)
                            {
                                if (tilePos.X >= tileLayer.Tiles.GetLowerBound(0) || tilePos.X <= tileLayer.Tiles.GetUpperBound(0) &&
                                    tilePos.Y >= tileLayer.Tiles.GetLowerBound(1) || tilePos.Y <= tileLayer.Tiles.GetUpperBound(1))
                                {
                                    if (tileLayer.Tiles[tilePos.X, tilePos.Y] != null)
                                    {
                                        while (!found)
                                        {
                                            if (tilePos.X >= tileLayer.Tiles.GetLowerBound(0) || tilePos.X <= tileLayer.Tiles.GetUpperBound(0) &&
                                                tilePos.Y >= tileLayer.Tiles.GetLowerBound(1) || tilePos.Y <= tileLayer.Tiles.GetUpperBound(1))
                                            {
                                                if (tileLayer.Tiles[tilePos.X, tilePos.Y] != null)
                                                {
                                                    if (tilePos.Y - 1 >= tileLayer.Tiles.GetLowerBound(1))
                                                    {
                                                        if (tileLayer.Tiles[tilePos.X, tilePos.Y - 1] == null)
                                                        {
                                                            gameMinionManager.Add(new Vector2((tilePos.X * 64) + 32, (tilePos.Y * 64) - 32), type);
                                                            gameButtonManager.Buttons[gameButtonManager.SelectedButton].CurrentCoolDown = gameButtonManager.Buttons[gameButtonManager.SelectedButton].CoolDown;
                                                            found = true;
                                                        }
                                                        else tilePos.Y -= 1;
                                                    }
                                                    else found = true;
                                                }
                                                else found = true;

                                            }
                                            else found = true;
                                        }
                                    }
                                    else
                                    {
                                        while (!found)
                                        {
                                            if (tilePos.X >= tileLayer.Tiles.GetLowerBound(0) || tilePos.X <= tileLayer.Tiles.GetUpperBound(0) &&
                                                tilePos.Y >= tileLayer.Tiles.GetLowerBound(1) || tilePos.Y <= tileLayer.Tiles.GetUpperBound(1))
                                            {
                                                if (tileLayer.Tiles[tilePos.X, tilePos.Y] == null)
                                                {
//.........这里部分代码省略.........
开发者ID:GarethIW,项目名称:HeroBash,代码行数:101,代码来源:GameplayScreen.cs

示例5: 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 currentKeyboardState = 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 (levelEndCounter < 0)
            {
                LoadingScreen.Load(ScreenManager, true, 0,
                               new Level2(score));
            }

            if (gameOverCounter == 100)
            {
                ScreenManager.AddScreen(new EnterNameScreen(score), ControllingPlayer);
            }

            if (input.IsPauseGame(ControllingPlayer))
            {
                ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer);
            }
            else if (currentKeyboardState.IsKeyDown(Keys.F1))
            {
                   ScreenManager.AddScreen(new HelpScreen(), ControllingPlayer);
            }
            else
            {
                
                // add my keyboard stuff here 
                if (currentKeyboardState.IsKeyDown(Keys.Left))
                {
                    player.Direction = Direction.Left;
                    player.Action = PlayerActions.Walking;
                    distanceToTravel++;
                    

                }
                else if (currentKeyboardState.IsKeyDown(Keys.Right))
                {
                    player.Direction = Direction.Right;
                    player.Action = PlayerActions.Walking;
                    distanceToTravel--;
                }
                else
                {
                    player.Action = PlayerActions.Standing;
                }

                if (currentKeyboardState.IsKeyDown(Keys.Space))
                {
                    player.JumpInMotion = true;
                }

                if (currentKeyboardState.IsKeyDown(Keys.LeftControl))
                {
                    player.Action = PlayerActions.Striking;
                }
                else if (currentKeyboardState.IsKeyDown(Keys.LeftAlt))
                {
                    player.Action = PlayerActions.SpellCasting;
                }
                previousKeyBoardState = currentKeyboardState; 
            }
        }
开发者ID:borgidiom,项目名称:OdinsRevenge,代码行数:78,代码来源:OdinLevels.cs

示例6: HandleInput

        public override void HandleInput(InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            if (input.IsPauseGame(null))
            {
                Exit();
            }

             // look for any taps that occurred and select any entries that were tapped
            foreach (GestureSample gesture in input.Gestures)
            {
                if (gesture.GestureType == GestureType.Tap)
                {
                    // convert the position to a Point that we can test against a Rectangle
                    Point tapLocation = new Point((int)gesture.Position.X, (int)gesture.Position.Y);

                    // select the entry. since gestures are only available on Windows Phone,
                    // we can safely pass PlayerIndex.One to all entries since there is only
                    // one player on Windows Phone.
                        if (GetMenuEntryHitBounds(gameModeMenuEntry).Contains(tapLocation))
                        {
                            gameModeMenuEntry.OnSelectEntry(PlayerIndex.One);
                        }
                        if (GetMenuEntryHitBounds(gameDifficultyMenuEntry).Contains(tapLocation))
                        {
                            gameDifficultyMenuEntry.OnSelectEntry(PlayerIndex.One);
                        }
                    }
                }
            /*
            // 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();
                }
            }*/
        }
开发者ID:kanavarora,项目名称:Bouncy-Ball-WPS-game,代码行数:44,代码来源:HighScoreScreen.cs


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