public override void HandleInput(InputState input)
        {
            // cancel the current screen if the user presses the back button
            PlayerIndex player;
            if (input.IsNewButtonPress(Buttons.Back, null, out player))
            {
                ExitScreen();
            }

            RootControl.HandleInput(input);

            base.HandleInput(input);
        }
 public override void HandleInput(InputState input)
 {
     foreach (GestureSample gest in input.Gestures)
     {
         if(gest.GestureType == GestureType.Tap)
         {
             if (_gameToPlay == GameToPlay.NewGame)
             {
                 LoadingScreen.Load(ScreenManager, true, _e.PlayerIndex,
                                    new GameplayScreen(GameToPlay.NewGame));
             }
             else
             {
                 LoadingScreen.Load(ScreenManager, true, _e.PlayerIndex,
                        new GameplayScreen(GameToPlay.SurvivalGame));
             }
         }
     }
     base.HandleInput(input);
 }
 public override void HandleInput(InputState input)
 {
     scrollTracker.HandleInput(input);
     base.HandleInput(input);
 }
Пример #4
0
 /// <summary>
 /// Called once per frame to update the control; override this method if your control requires custom updates.
 /// Call base.Update() to update any child controls.
 /// </summary>
 public virtual void HandleInput(InputState input)
 {
     for (int i = 0; i < ChildCount; i++)
     {
         children[i].HandleInput(input);
     }
 }
Пример #5
0
 /// <summary>
 /// Allows the screen to handle user input. Unlike Update, this method
 /// is only called when the screen is active, and not when some other
 /// screen has taken the focus.
 /// </summary>
 public virtual void HandleInput(InputState input)
 {
 }
Пример #6
0
        // This must be called manually each tick that the ScrollTracker is active.
        public void HandleInput(InputState input)
        {
            // Turn on tracking as soon as we seen any kind of touch. We can't use gestures for this
            // because no gesture data is returned on the initial touch. We have to be careful to
            // pick out only 'Pressed' locations, because TouchState can return other events a frame
            // *after* we've seen GestureType.Flick or GestureType.DragComplete.
            if (!IsTracking)
            {
                for (int i = 0; i < input.TouchState.Count; i++)
                {
                    if (input.TouchState[i].State == TouchLocationState.Pressed)
                    {
                        Velocity = Vector2.Zero;
                        UnclampedViewOrigin = ViewOrigin;
                        IsTracking = true;
                        break;
                    }
                }
            }

            foreach (GestureSample sample in input.Gestures)
            {
                switch (sample.GestureType)
                {
                    case GestureType.VerticalDrag:
                        UnclampedViewOrigin.Y -= sample.Delta.Y;
                        break;

                    case GestureType.Flick:
                        // Only respond to mostly-vertical flicks
                        if (Math.Abs(sample.Delta.X) < Math.Abs(sample.Delta.Y))
                        {
                            IsTracking = false;
                            Velocity = -sample.Delta;
                        }
                        break;

                    case GestureType.DragComplete:
                        IsTracking = false;
                        break;
                }
            }
        }
Пример #7
0
        /// <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);
            }

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

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

                        if (GetMenuEntryHitBounds(menuEntry).Contains(tapLocation))
                        {
                            // 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);
                        }
                    }
                }
            }
        }
Пример #8
0
        /// <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)
        {
            try
            {
                if (input == null)
                    throw new ArgumentNullException("input");
                if (input.IsPauseGame(null))
                {
                    PauseCurrentGame();
                }
                // Look up inputs for the active player profile.
                if (ControllingPlayer != null)
                {
                    var playerIndex = (int)ControllingPlayer.Value;

            #pragma warning disable 168
                    KeyboardState keyboardState = input.CurrentKeyboardStates[playerIndex];
                    GamePadState gamePadState = input.CurrentGamePadStates[playerIndex];
            #pragma warning restore 168
                }

                // if the user pressed the back button, we return to the main menu
                PlayerIndex player;
                if (input.IsNewButtonPress(Buttons.Back, ControllingPlayer, out player))
                {
                    //SaveGame();
                    LoadingScreen.Load(ScreenManager, false, ControllingPlayer, new BackgroundScreen(),
                                       new MainMenuScreen());

                }
                else
                {
                    foreach (GestureSample gest in input.Gestures)
                    {
                        //Screen touch point
                        var stp = new Point((int)gest.Position.X, (int)gest.Position.Y);
                        //Map touch point
                        var mtp = new Point((int)(_camera.Position.X + gest.Position.X),
                                            (int)(_camera.Position.Y + gest.Position.Y));

                        switch (gest.GestureType)
                        {
                            case GestureType.Tap:
                                {
                                    _currentTouchPosition = (_camera.Position + gest.Position);
                                    if (
                                        !(HUD.HandleInput(stp)
                                        || PlayerManager.HandleInput(mtp, stp)
                                        || EnemyManager.HandleInput(mtp))
                                        )
                                    {
                                        if (!IsPaused)
                                            PlayerManager.Nathaniel.Destination = (_currentTouchPosition);
                                    }

                                    if (IsPaused && !GameManager.GameOver)
                                    {
                                        _pauseMenu.HandleInput(stp);
                                    }
                                    if (GameManager.GameOver)
                                        _gameOverScreen.HandleInput(stp);
                                    if (GameManager.LevelWon)
                                        _winScreen.HandleInput(stp);
                                    //Touching the screen should move the main character unless an action is being performed
                                    //on something else

                                }
                                break;

                            case GestureType.FreeDrag:
                                {
                                    BuildStructureMenu.HandleBuildMenuSelection(stp, gest);
                                }
                                break;
                            case GestureType.DragComplete:
                                {
                                    BuildStructureMenu.TryPlaceDefensiveStructure();
                                }
                                break;
                        }
                    }
                }
            }
            catch
            {
                //Empty
            }
        }