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


C# InputState.IsNewKeyPress方法代码示例

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


在下文中一共展示了InputState.IsNewKeyPress方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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;
            }
        }
开发者ID:VoronFX,项目名称:SummerPractice,代码行数:58,代码来源:GameplayScreenBattle.cs

示例2: HandleInput

        public override void HandleInput(InputState input)
        {
            //base.HandleInput(input);
            PlayerIndex junk;
            for (int i = 0; i < 4; i++)
            {
                //If the player hit A to join
                if (input.IsNewButtonPress(Buttons.A, (PlayerIndex)i, out junk) && !towersmash.players[i])
                {
                    towersmash.players[i] = true;
                }
                    //else if the player hit B to leave
                else if (input.IsNewButtonPress(Buttons.B, (PlayerIndex)i, out junk) && towersmash.players[i])
                {
                    towersmash.players[i] = false;
                }
                //If the player moves up the list
                if (towersmash.players[i] && input.IsNewButtonPress(Buttons.RightShoulder, (PlayerIndex)i, out junk))
                {
                    player_selection[i]++;
                    if (player_selection[i] > character_number)
                        player_selection[i] = 0;
                }
                //If the player moves down the list
                if (towersmash.players[i] && input.IsNewButtonPress(Buttons.LeftShoulder, (PlayerIndex)i, out junk))
                {
                    player_selection[i]--;
                    if (player_selection[i] < 0)
                        player_selection[i] = character_number;
                }
            }
            //If anyone wants to start the game
            if(input.IsNewButtonPress(Buttons.Start, null, out junk))
            {
                towersmash.updatenumberofplayers();
                if (towersmash.numberofplayers > 1)
                {
                    base.OnCancel(junk);
                    LoadingScreen.Load(ScreenManager, true, junk, new pvp(ScreenManager));
                }
                else
                {
                    MessageBoxScreen messagebox = new MessageBoxScreen("Must have at least 2 players ready for battle!");
                    ScreenManager.AddScreen(messagebox, null);
                }
            }
            //If anyone wants to go back to the main menu
            if (input.IsNewButtonPress(Buttons.Back, null, out junk))
            {
                base.OnCancel(junk);
            }

            //Quick hack for me on the keyboard
            if (input.IsNewKeyPress(Keys.Enter, null, out junk))
            {
                towersmash.numberofplayers = 2;
                towersmash.players[0] = true;
                towersmash.players[1] = true;
                towersmash.players[2] = false;
                towersmash.players[3] = false;
                towersmash.characters[0] = playertype.bashy;
                towersmash.characters[1] = playertype.shifty;
                base.OnCancel(junk);
                LoadingScreen.Load(ScreenManager, true, junk, new pvp(ScreenManager));
            }
        }
开发者ID:danielselnick,项目名称:Sentry-Smash,代码行数:66,代码来源:playerselect.cs

示例3: HandleInput

        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            // we cancel the current menu screen if the user presses the back button
            PlayerIndex player;
            if (input.IsNewButtonPress(Buttons.Back, ControllingPlayer, out player))
            {
                OnCancel(player);
            }
#if WINDOWS
            // Take care of Keyboard input
            if (input.IsMenuUp(ControllingPlayer))
            {
                selectedEntry--;

                if (selectedEntry < 0)
                    selectedEntry = menuEntries.Count - 1;
            }
            else if (input.IsMenuDown(ControllingPlayer))
            {
                selectedEntry++;

                if (selectedEntry >= menuEntries.Count)
                    selectedEntry = 0;
            }
            else if (input.IsNewKeyPress(Keys.Enter, ControllingPlayer, out player) ||
                input.IsNewKeyPress(Keys.Space, ControllingPlayer, out player))
            {
                OnSelectEntry(selectedEntry, player);
            }


            MouseState state = Mouse.GetState();
            if (state.LeftButton == ButtonState.Released)
            {
                if (isMouseDown)
                {
                    isMouseDown = false;
                    // convert the position to a Point that we can test against a Rectangle
                    Point clickLocation = new Point(state.X, state.Y);

                    // iterate the entries to see if any were tapped
                    for (int i = 0; i < menuEntries.Count; i++)
                    {
                        MenuEntry menuEntry = menuEntries[i];

                        if (menuEntry.Destination.Contains(clickLocation))
                        {
                            // 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.
                            OnSelectEntry(i, PlayerIndex.One);
                        }
                    }
                }
            }
            else if (state.LeftButton == ButtonState.Pressed)
            {
                isMouseDown = true;

                // convert the position to a Point that we can test against a Rectangle
                Point clickLocation = new Point(state.X, state.Y);

                // iterate the entries to see if any were tapped
                for (int i = 0; i < menuEntries.Count; i++)
                {
                    MenuEntry menuEntry = menuEntries[i];

                    if (menuEntry.Destination.Contains(clickLocation))
                        selectedEntry = i;
                }
            }
#elif XBOX
            // Take care of Gamepad input
            if (input.IsMenuUp(ControllingPlayer))
            {
                selectedEntry--;

                if (selectedEntry < 0)
                    selectedEntry = menuEntries.Count - 1;
            }
            else if (input.IsMenuDown(ControllingPlayer))
            {
                selectedEntry++;

                if (selectedEntry >= menuEntries.Count)
                    selectedEntry = 0;
            }
            else if (input.IsNewButtonPress(Buttons.A, ControllingPlayer, out player))
                OnSelectEntry(selectedEntry, player);

#elif WINDOWS_PHONE
            // look for any taps that occurred and select any entries that were tapped
            foreach (GestureSample gesture in input.Gestures)
            {
                if (gesture.GestureType == GestureType.Tap)
//.........这里部分代码省略.........
开发者ID:liwq-net,项目名称:SilverSprite,代码行数:101,代码来源:MenuScreen.cs

示例4: HandleInput

		public override void HandleInput (InputState input)
		{
			if (isLoading == true) {
				base.HandleInput (input);
				return;
			}
			PlayerIndex player;
			if (input.IsNewKeyPress (Microsoft.Xna.Framework.Input.Keys.Space, ControllingPlayer, out player) ||
			    input.IsNewKeyPress (Microsoft.Xna.Framework.Input.Keys.Enter, ControllingPlayer, out player) ||
			    input.MouseGesture.HasFlag(MouseGestureType.LeftClick)||
			    input.IsNewButtonPress (Microsoft.Xna.Framework.Input.Buttons.Start, ControllingPlayer, out player)) {
				// Create a new instance of the gameplay screen
				gameplayScreen = new GameplayScreen ();
				gameplayScreen.ScreenManager = ScreenManager;

				// Start loading the resources in additional thread
#if MACOS
				// create a new thread using BackgroundWorkerThread as method to execute
				thread = new Thread (LoadAssetsWorkerThread as ThreadStart);
#else
				thread = new System.Threading.Thread (new System.Threading.ThreadStart (gameplayScreen.LoadAssets));
#endif
				isLoading = true;
				// start it
				thread.Start ();

			}

			foreach (var gesture in input.Gestures) {
				if (gesture.GestureType == GestureType.Tap) {
					// Create a new instance of the gameplay screen
					gameplayScreen = new GameplayScreen ();
					gameplayScreen.ScreenManager = ScreenManager;

					// Start loading the resources in additional thread
					thread = new System.Threading.Thread (new System.Threading.ThreadStart (gameplayScreen.LoadAssets));
					isLoading = true;
					thread.Start ();
				}
			}

			base.HandleInput (input);
		}
开发者ID:tyschacht,项目名称:MonoGame-Samples,代码行数:43,代码来源:InstructionsScreen.cs

示例5: HandleInput

        public void HandleInput(InputState input)
        {
            int oldSelected = selected;
            int oldLibrary = libraryIndex;

            if (input.IsMenuDown(screen.ControllingPlayer))
            {
                if (selected < library.Count - 1)
                {
                    ++selected;
                    if (selected == numEntries + index)
                    {
                        ++index;
                    }
                    loadAroundIndex(selected);
                }
            }
            if (input.IsMenuUp(screen.ControllingPlayer))
            {
                if (selected > 0)
                {
                    --selected;
                    if (selected == index - 1)
                    {
                        --index;
                    }
                    loadAroundIndex(selected);
                }
            }

            PlayerIndex player;

            if (input.IsNewButtonPress(Buttons.X, screen.ControllingPlayer, out player))
            {
                MediaPlayer.Play(library[selected]);
            }

            if (input.IsNewButtonPress(Buttons.LeftShoulder, screen.ControllingPlayer, out player) ||
                input.IsNewKeyPress(Keys.Left, screen.ControllingPlayer, out player))
            {
                if (libraryIndex > 0)
                {
                    --libraryIndex;
                    mediaSourceName = MediaSource.GetAvailableMediaSources()[libraryIndex].Name;
                    library = new MediaLibrary(MediaSource.GetAvailableMediaSources()[libraryIndex]).Songs;
                    index = 0;
                    selected = 0;
                    initializeSongDataArray();
                }
            }
            if (input.IsNewButtonPress(Buttons.RightShoulder, screen.ControllingPlayer, out player) ||
                input.IsNewKeyPress(Keys.Right, screen.ControllingPlayer, out player))
            {
                if (libraryIndex < MediaSource.GetAvailableMediaSources().Count - 1)
                {
                    ++libraryIndex;
                    mediaSourceName = MediaSource.GetAvailableMediaSources()[libraryIndex].Name;
                    library = new MediaLibrary(MediaSource.GetAvailableMediaSources()[libraryIndex]).Songs;
                    index = 0;
                    selected = 0;
                    initializeSongDataArray();
                }
            }

            if (input.IsNewButtonPress(Buttons.RightTrigger, screen.ControllingPlayer, out player))
            {
                if (library.Count > 0)
                {
                    char c = '0';
                    // Skip ahead artist letter

                    if (SongDataArray[selected].Artist.Length > 0)
                    {
                        c = SongDataArray[selected].Artist.ToLower()[0];
                    }
                    int newIndex;
                    for (newIndex = selected; newIndex < library.Count; ++newIndex)
                    {
                        loadAroundIndex(newIndex);
                        if (SongDataArray[newIndex].Artist.Length == 0)
                            continue;
                        if (SongDataArray[newIndex].Artist.ToLower()[0] != c)
                            break;
                    }
                    selected = Math.Min(newIndex, library.Count - 1);
                    index = selected;
                }
            }

            if (input.IsNewButtonPress(Buttons.LeftTrigger, screen.ControllingPlayer, out player))
            {
                if (library.Count > 0)
                {
                    char c = 'z';
                    // Skip back artist letter
                    if (SongDataArray[selected].Artist.Length > 0)
                    {
                        c = SongDataArray[selected].Artist.ToLower()[0];
                    }
                    int newIndex;
//.........这里部分代码省略.........
开发者ID:kmatzen,项目名称:EECS-494-Final-Project,代码行数:101,代码来源:SongSelectionBox.cs

示例6: HandleCamera

        private void HandleCamera(InputState input, GameTime gameTime)
        {
            Vector2 camMove = Vector2.Zero;

            if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Up))
            {
                camMove.Y -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Down))
            {
                camMove.Y += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Left))
            {
                camMove.X -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Right))
            {
                camMove.X += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
            }
            if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.PageUp))
            {
                Camera.Zoom += 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
            }
            if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.PageDown))
            {
                Camera.Zoom -= 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
            }
            if (camMove != Vector2.Zero)
            {
                Camera.MoveCamera(camMove);
            }
            PlayerIndex i;
            if (input.IsNewKeyPress(Keys.Home, PlayerIndex.One, out i))
            {
                Camera.ResetCamera();
            }
        }
开发者ID:nadams810,项目名称:axiosengine,代码行数:38,代码来源:PhysicsGameScreen.cs

示例7: HandleInput

        public override void HandleInput(GameTime gameTime, InputState input)
        {
            #if DEBUG
            // Control debug view
            PlayerIndex player;
            if (input.IsNewButtonPress(Buttons.Start, ControllingPlayer.Value, out player))
            {
                EnableOrDisableFlag(DebugViewFlags.Shape);
                EnableOrDisableFlag(DebugViewFlags.DebugPanel);
                EnableOrDisableFlag(DebugViewFlags.PerformanceGraph);
                EnableOrDisableFlag(DebugViewFlags.Joint);
                EnableOrDisableFlag(DebugViewFlags.ContactPoints);
                EnableOrDisableFlag(DebugViewFlags.ContactNormals);
                EnableOrDisableFlag(DebugViewFlags.Controllers);
            }

            if (input.IsNewKeyPress(Keys.F1, ControllingPlayer.Value, out player))
            {
                EnableOrDisableFlag(DebugViewFlags.Shape);
            }
            if (input.IsNewKeyPress(Keys.F2, ControllingPlayer.Value, out player))
            {
                EnableOrDisableFlag(DebugViewFlags.DebugPanel);
                EnableOrDisableFlag(DebugViewFlags.PerformanceGraph);
            }
            if (input.IsNewKeyPress(Keys.F3, ControllingPlayer.Value, out player))
            {
                EnableOrDisableFlag(DebugViewFlags.Joint);
            }
            if (input.IsNewKeyPress(Keys.F4, ControllingPlayer.Value, out player))
            {
                EnableOrDisableFlag(DebugViewFlags.ContactPoints);
                EnableOrDisableFlag(DebugViewFlags.ContactNormals);
            }
            if (input.IsNewKeyPress(Keys.F5, ControllingPlayer.Value, out player))
            {
                EnableOrDisableFlag(DebugViewFlags.PolygonPoints);
            }
            if (input.IsNewKeyPress(Keys.F6, ControllingPlayer.Value, out player))
            {
                EnableOrDisableFlag(DebugViewFlags.Controllers);
            }
            if (input.IsNewKeyPress(Keys.F7, ControllingPlayer.Value, out player))
            {
                EnableOrDisableFlag(DebugViewFlags.CenterOfMass);
            }
            if (input.IsNewKeyPress(Keys.F8, ControllingPlayer.Value, out player))
            {
                EnableOrDisableFlag(DebugViewFlags.AABB);
            }

            #endif

            if (_userAgent != null)
            {
                HandleUserAgent(input);
            }

            if (EnableCameraControl)
            {
                HandleCamera(input, gameTime);
            }

            if (HasCursor)
            {
                HandleCursor(input);
            }

            PlayerIndex i;
            if (input.IsNewButtonPress(Buttons.Back, PlayerIndex.One, out i) || input.IsNewKeyPress(Keys.Escape, PlayerIndex.One, out i))
            {
                //if (this.ScreenState == GameStateManagement.ScreenState.Active && this.TransitionPosition == 0 && this.TransitionAlpha == 1)
                //{ //Give the screens a chance to transition
                    CleanUp();
                    ExitScreen();

                //}
            }
            base.HandleInput(gameTime, input);
        }
开发者ID:nadams810,项目名称:axiosengine,代码行数:80,代码来源:PhysicsGameScreen.cs

示例8: HandleKeyboardInput

 public override void HandleKeyboardInput(InputState input)
 {
     PlayerIndex player;
     if (input.IsNewKeyPress(Keys.Space, out player) || input.IsNewKeyPress(Keys.Enter, out player))
     {
         OnSelectEntry(selectedEntry, PlayerIndex.One);
     }
     else if (input.IsNewKeyPress(Keys.Escape, out player))
     {
         OnCancel(player);
     }
     else if (input.IsNewKeyPress(Keys.Up, out player))
     {
         if (selectedEntry > 0)
             selectedEntry--;
     }
     else if (input.IsNewKeyPress(Keys.Down, out player))
     {
         if (selectedEntry < menuEntries.Count - 1)
             selectedEntry++;
     }
     else 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();
     }
 }
开发者ID:VoronFX,项目名称:SummerPractice,代码行数:29,代码来源:MenuScreen.cs

示例9: HandleInput

        public override void HandleInput(InputState input)
        {
            if (input.IsNewKeyPress(Keys.Escape)) ScreenManager.AddScreen(new PauseMenuScreen());
            //if(input.IsNewKeyPress(Keys.Back)) MapGeneration.Generate(map);
            if (_endOfWave && _waveFade>=1f)
            {
                if (!_trading && _tradecost > 0 && (Ship.Instance.PowerUpMeter > 0 || Ship.Instance.PowerUpLevel > 0) &&
                    (input.IsNewKeyPress(Keys.X) || input.IsNewKeyPress(Keys.Space) ||
                     (input.CurrentGamePadState.Buttons.A == ButtonState.Pressed &&
                      input.LastGamePadState.Buttons.A == ButtonState.Released) ||
                     (input.CurrentGamePadState.Triggers.Right > 0.2f && input.LastGamePadState.Triggers.Right < 0.2f)))
                {
                    _trading = true;
                    DoTrade();

                }
            }

            if (_endOfWave && _waveFade>=1f) return;

            if (_gameOver && _goTimer >= 1f)
            {
                if (input.IsNewKeyPress(Keys.X) || input.IsNewKeyPress(Keys.Space) || input.IsNewKeyPress(Keys.Enter) || input.IsNewKeyPress(Keys.Escape))
                    LoadingScreen.Load(ScreenManager, false, new MainMenuScreen());
            }

            playerShip.HandleInput(input);
            base.HandleInput(input);
        }
开发者ID:GarethIW,项目名称:LD29,代码行数:29,代码来源:GameplayScreen.cs

示例10: HandleInput

 /// <summary>
 /// Responds to user input, capturing...
 /// </summary>
 public override void HandleInput(InputState input)
 {
     if (parentSlideMenu.IsPlaying) // If Playing, don't accept input
         return;
     PlayerIndex requesteeIndex;
     //press c to "capture"
     if(input.IsNewKeyPress(Keys.C, null,out requesteeIndex)){
         Captured();
     }
     //press "b" or the left arrow key to go back one slide
     if(input.IsNewKeyPress(Keys.B,null, out requesteeIndex)||input.IsNewKeyPress(Keys.Left, null, out requesteeIndex)){
         parentSlideMenu.PreviousSlide(requesteeIndex);
         this.ExitScreen();
     }
     //press u to undo last capture for this slide
     if (input.IsNewKeyPress(Keys.U, null, out requesteeIndex))
     {
         if (slideObjects.Count > 0)
         {
             slideObjects.RemoveAt(slideObjects.Count - 1);
         }
     }
     //press right arrow key to move forward one slide
     if (input.IsNewKeyPress(Keys.Right, null, out requesteeIndex))
     {
         parentSlideMenu.NextSlide(requesteeIndex);
     }
     //press "n" to create a new slide
     if (input.IsNewKeyPress(Keys.N, null, out requesteeIndex))
     {
         parentSlideMenu.NewSlide(requesteeIndex);
     }
     //press "z" to go to change to avatar1
     if (input.IsNewKeyPress(Keys.Z, null, out requesteeIndex))
     {
         parentSlideMenu.ChangeToAvatar(0);
         Console.Out.WriteLine("Changed to 0");
     }
     //press "x" to go to change to avatar2
     if (input.IsNewKeyPress(Keys.X, null, out requesteeIndex))
     {
         parentSlideMenu.ChangeToAvatar(1);
         Console.Out.WriteLine("Changed to 1");
     }
     //press "a" to go to change to avatar2
     if (input.IsNewKeyPress(Keys.A, null, out requesteeIndex))
     {
         parentSlideMenu.ChangeToAvatar(2);
         Console.Out.WriteLine("changed to 2");
     }
     //press "m" to go to slideMenu
     if (input.IsNewKeyPress(Keys.M, null, out requesteeIndex))
     {
         //TO DO implement menu!
     }
     if (input.IsNewKeyPress(Keys.Q, null, out requesteeIndex))
     {
         // DEBUGGING FUNCTION
         Console.Out.WriteLine("Num Slides in ScreenManager: " + ScreenManager.NumScreens);
         Console.Out.WriteLine("Num Hidden Slides in ScreenManager: " + ScreenManager.NumScreensHidden);
     }
     //Press 'r' to start recording. If you're recording, it will stop recording
     if (input.IsNewKeyPress(Keys.R, null, out requesteeIndex))
     {
         beginRecording();
     }
     //Press 'p' to play recording. If already playing, will stop it.
     if (input.IsNewKeyPress(Keys.P, null, out requesteeIndex))
     {
         playAudio();
     }
     if (input.IsNewKeyPress(Keys.W, null, out requesteeIndex))
     {
         // DEBUGGING FOR PLAY ALL FUNCTIONALITY
         parentSlideMenu.PlayAll(2000);
     }
 }
开发者ID:dcordoba,项目名称:Imagination-Labs,代码行数:80,代码来源:SlideScreen.cs

示例11: HandleInput

        /// <summary>
        /// Responds to user input, capturing...
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (parentSlideMenu.IsPlayingSlideshow) // If Playing, don't accept input
                return;
            PlayerIndex requesteeIndex;
            //SkeletonTracker skel = ScreenManager.Skeleton;
            //int leftHandX = skel.GetDisplayPosition(skel.Joints[JointType.HandLeft]);
              //  if(ScreenManager.Skeleton.
            #region keyboard commands
            //press c to "capture"
            if(input.IsNewKeyPress(Keys.C, null,out requesteeIndex)){
                Captured();
            }
            //press a to  cycle through avatars
            if (input.IsNewKeyPress(Keys.A, null, out requesteeIndex))
            {
                ScreenManager.CycleAvatar();
            }
            //press the left arrow key to go back one slide
            if(input.IsNewKeyPress(Keys.Left, null, out requesteeIndex)){
               // parentSlideMenu.PreviousSlide(requesteeIndex);
               // parentSlideMenu.PreviousSlide();
                //this.ExitScreen();
                PreviousSlide();
            }
               // press "b" to change the background
            if(input.IsNewKeyPress(Keys.B,null, out requesteeIndex)){

                backgroundIndex = (backgroundIndex + 1) % 4;

                //TODO: use gesture recognition to generate background indices.
                ChangeBackground(backgroundIndex);
            }
            //press u to undo last capture for this slide
            if (input.IsNewKeyPress(Keys.U, null, out requesteeIndex))
            {
                Undo();
                /*
                if (slideObjects.Count > 0)
                {
                    slideObjects.RemoveAt(slideObjects.Count - 1);
                }
                 * */
            }
            //press right arrow key to move forward one slide
            if (input.IsNewKeyPress(Keys.Right, null, out requesteeIndex))
            {
               // parentSlideMenu.NextSlide();
                NextSlide();
            }
            //press "n" to create a new slide
            if (input.IsNewKeyPress(Keys.N, null, out requesteeIndex))
            {
                parentSlideMenu.NewSlide();
            }
            //press "z" to go to change to avatar1
            if (input.IsNewKeyPress(Keys.Z, null, out requesteeIndex))
            {
                parentSlideMenu.ChangeToAvatar(0);
                //Console.Out.WriteLine("Changed to 0");
            }
            //press "x" to go to change to avatar2
            if (input.IsNewKeyPress(Keys.X, null, out requesteeIndex))
            {
                parentSlideMenu.ChangeToAvatar(1);
                //Console.Out.WriteLine("Changed to 1");
            }

            //press "v" to toggle voice recognition on or off
            if (input.IsNewKeyPress(Keys.V, null, out requesteeIndex))
            {
                ScreenManager.speechRecognitionOn = !ScreenManager.speechRecognitionOn;
            }
            if (input.IsNewKeyPress(Keys.Q, null, out requesteeIndex))
            {
                // DEBUGGING FUNCTION
                Console.Out.WriteLine("Num Slides in ScreenManager: " + ScreenManager.NumScreens);
                Console.Out.WriteLine("Num Hidden Slides in ScreenManager: " + ScreenManager.NumScreensHidden);
            }
            //Press 'r' to start recording. If you're recording, it will stop recording
            if (input.IsNewKeyPress(Keys.R, null, out requesteeIndex))
            {
                beginRecording();
            }
            //Press 'p' to play recording. If already playing, will stop it.
            if (input.IsNewKeyPress(Keys.P, null, out requesteeIndex))
            {

                playAudio();
            }
            if (input.IsNewKeyPress(Keys.W, null, out requesteeIndex))
            {
                // DEBUGGING FOR PLAY ALL FUNCTIONALITY
                parentSlideMenu.PlayAll(NarrationLength);
            }
            #endregion
        }
开发者ID:khoshino,项目名称:Imagination-Labs,代码行数:100,代码来源:SlideScreen.cs

示例12: HandleInput


//.........这里部分代码省略.........
                    }

                    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);

                    // debug code for organizing world map
                    if (OptionsMenuScreen.currentMap == OptionsMenuScreen.Map.World)// && cP.PI == PlayerIndex.Two)
                    {
                        if (keyboardState.IsKeyDown(Keys.LeftControl))
                        {
                            offset += movement * 10;
                        }
                        else if (cP.selected == true)
                        {
                            if (keyboardState.IsKeyDown(Keys.LeftShift))
                                movement *= 10 / scale;

                            if (mode == 1)
                            {
                                Vector2 pos = cP.origin.getLocation() + 0.2f*movement;
                                cP.origin.setLocation(pos);
                            }
                            else if(mode == 2)
                            {
                                Vector2 pos = cP.origin.getLabelOffset() + movement;
                                cP.origin.setLabelOffset(pos);
                            }
                        }

                        PlayerIndex output;
                        if (input.IsNewKeyPress(Keys.P, cP.PI, out output))
                        {
                            Console.Out.WriteLine("\n\nTerr. Locations:\n");
                            float tempRescale = 1;
                            foreach (KeyValuePair<string, Country> c in territories)
                            {

                                //Country c = new Country(new Vector2(320.448f, 500.0194f), new Vector2(0, 0), content.Load<Texture2D>("territories/alaska"), noone, 4);
                                //territories.Add("alaska", c);
                                Vector2 loc = c.Value.getLocation() * tempRescale + offset / scale;
                                Vector2 label = c.Value.getLabelOffset() * tempRescale;
                                Console.Out.WriteLine("c = new Country(new Vector2(" + loc.X + "f, " + loc.Y + "f), new Vector2(" + label.X + "f, " + label.Y + "f), content.Load<Texture2D>(\"territories/"+c.Key+"\"), noone, 4);");
                                Console.Out.WriteLine("territories.Add(\""+c.Key+"\", c);");
                                //Console.Out.WriteLine(c.Key+": "+(loc));
                            }
                            foreach (Doodad d in doodads)
                            {
                                Vector2 loc = d.location * tempRescale + offset / scale;
                                string name = d.image.Name;
                                Console.Out.WriteLine("doodads.Add(new Doodad(new Vector2(" + loc.X + "f, " + loc.Y + "f), content.Load<Texture2D>(\"doodads/" + name + "\"), \""+name+"\", Color.White));");
                            }
                        }
                        if (input.IsNewKeyPress(Keys.S, cP.PI, out output))
                            mode = (mode + 1) % 3;
                        if (input.IsNewKeyPress(Keys.Add, cP.PI, out output))
                            scale *= 2f;
                        if (input.IsNewKeyPress(Keys.Subtract, cP.PI, out output))
                            scale *= 0.5f;
                        if (input.IsNewKeyPress(Keys.R, cP.PI, out output))
                            offset = new Vector2(0,0);

                    }
                }
            }
        }
开发者ID:kzielnicki,项目名称:Brisk,代码行数:101,代码来源:GameplayScreen.cs

示例13: HandleInput

		public override void HandleInput (InputState input)
		{
			if (isLoading == true)
            {
#if ANDROID || IPHONE || LINUX || WINDOWS
                // Exit the screen and show the gameplay screen 
					// with pre-loaded assets
				ExitScreen ();
				ScreenManager.AddScreen (gameplayScreen, null);
#endif						
				base.HandleInput (input);
				return;
			}
			PlayerIndex player;
			if (input.IsNewKeyPress (Microsoft.Xna.Framework.Input.Keys.Space, ControllingPlayer, out player) ||
			    input.IsNewKeyPress (Microsoft.Xna.Framework.Input.Keys.Enter, ControllingPlayer, out player) ||
			    input.MouseGesture.HasFlag(MouseGestureType.LeftClick) ||
			    input.IsNewButtonPress (Microsoft.Xna.Framework.Input.Buttons.Start, ControllingPlayer, out player)) {
				// Create a new instance of the gameplay screen
				gameplayScreen = new GameplayScreen ();
				gameplayScreen.ScreenManager = ScreenManager;

                // Start loading the resources in additional thread
#if !LINUX && !WINDOWS
#if MONOMAC
				// create a new thread using BackgroundWorkerThread as method to execute
				thread = new Thread (LoadAssetsWorkerThread as ThreadStart);
#else     
				thread = new System.Threading.Thread (new System.Threading.ThreadStart (gameplayScreen.LoadAssets));    
#endif
				isLoading = true;
				// start it
				thread.Start ();
#else
                isLoading = true;
#endif
			}

			foreach (var gesture in input.Gestures) {
				if (gesture.GestureType == GestureType.Tap) {
					// Create a new instance of the gameplay screen
					gameplayScreen = new GameplayScreen ();
					gameplayScreen.ScreenManager = ScreenManager;

#if ANDROID || IPHONE	|| LINUX || WINDOWS
                    isLoading = true;									
#else						
					// Start loading the resources in additional thread
					thread = new System.Threading.Thread (new System.Threading.ThreadStart (gameplayScreen.LoadAssets));
					isLoading = true;
					thread.Start ();
#endif					
				}
			}

			base.HandleInput (input);
		}
开发者ID:Nailz,项目名称:MonoGame-Samples,代码行数:57,代码来源:InstructionsScreen.cs

示例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(GameTime gameTime, InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

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

            var keyboardState = input.CurrentKeyboardStates[playerIndex];

            playerIndex = input.CurrentGamePadStates[playerIndex + 4].IsConnected ? playerIndex + 4 : 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];

            PlayerIndex player;
            if (_pauseAction.Evaluate(input, ControllingPlayer, out player) || gamePadDisconnected)
            {
                ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer);
            }
            else
            {
                // Otherwise handle input.
                #region temporary keybord controls

                if (keyboardState.IsKeyDown(Keys.Home))
                    _camera.Pitch += .01f;
                if (keyboardState.IsKeyDown(Keys.End))
                    _camera.Pitch -= .01f;

                if (keyboardState.IsKeyDown(Keys.PageDown))
                    _camera.Translate(new Vector3(0, -.02f, 0));
                if (keyboardState.IsKeyDown(Keys.PageUp))
                    _camera.Translate(new Vector3(0, .02f, 0));

                // temporary camera controls
                if (input.IsKeyPressed(Keys.I, null, out player))
                    _camera.Translate(Vector3.UnitZ*-0.1f);
                if (input.IsKeyPressed(Keys.K, null, out player))
                    _camera.Translate(Vector3.UnitZ*0.1f);
                if (input.IsKeyPressed(Keys.J, null, out player))
                    _camera.Translate(Vector3.UnitX*-0.1f);
                if (input.IsKeyPressed(Keys.L, null, out player))
                    _camera.Translate(Vector3.UnitX*0.1f);

                // player 1 temporary controls)););)
                if (input.IsNewKeyPress(Keys.W, null, out player))
                    _puzzleBoard1.Up();
                if (input.IsNewKeyPress(Keys.S, null, out player))
                    _puzzleBoard1.Down();
                if (input.IsNewKeyPress(Keys.A, null, out player))
                    _puzzleBoard1.Left();
                if (input.IsNewKeyPress(Keys.D, null, out player))
                    _puzzleBoard1.Right();

                if (input.IsNewKeyPress(Keys.Q, null, out player))
                    _puzzleBoard1.Select();
                if (input.IsNewKeyPress(Keys.E, null, out player))
                    _puzzleBoard1.Accept();
                if (input.IsNewKeyPress(Keys.R, null, out player))
                    _puzzleBoard1.Randomize();

                // player 2 temporary controls
                if (input.IsNewKeyPress(Keys.Up, null, out player))
                    _puzzleBoard2.Up();
                if (input.IsNewKeyPress(Keys.Down, null, out player))
                    _puzzleBoard2.Down();
                if (input.IsNewKeyPress(Keys.Left, null, out player))
                    _puzzleBoard2.Left();
                if (input.IsNewKeyPress(Keys.Right, null, out player))
                    _puzzleBoard2.Right();
                if (input.IsNewKeyPress(Keys.RightControl, null, out player))
                    _puzzleBoard2.Select();
                if (input.IsNewKeyPress(Keys.Enter, null, out player))
                    _puzzleBoard2.Accept();
                if (input.IsNewKeyPress(Keys.Back, null, out player))
                    _puzzleBoard2.Randomize();

                if (keyboardState.IsKeyDown(Keys.Z))
                    _camera.Yaw += .01f;
                if (keyboardState.IsKeyDown(Keys.X))
                    _camera.Yaw -= .01f;

                // DEBUG, remove ASAP
                if (input.IsNewKeyPress(Keys.D1, null, out player))
                {
                    SpawnUnit("menele_ranged", _player1, Vector3.Zero);
                }
                if (input.IsNewKeyPress(Keys.D2, null, out player))
                {
                    SpawnUnit("menel_ram", _player1, Vector3.Zero);
//.........这里部分代码省略.........
开发者ID:szyszart,项目名称:Junkyard,代码行数:101,代码来源:GameplayScreen.cs


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