예제 #1
0
        public void HandleInput(InputState input)
        {
            if (GameSession.Instance.Team1Win || GameSession.Instance.Team2Win) return;
            if (GameSession.Instance.Team1ClientType != GameClientType.Human && GameSession.Instance.Team2ClientType != GameClientType.Human) return;

            foreach (Button b in Buttons)
            {
                if (input.TapPosition.HasValue && b.UIRect.Contains(new Point((int)input.TapPosition.Value.X, (int)input.TapPosition.Value.Y)))
                {
                    b.MouseOver();
                    if (input.MouseLeftClick)
                    {
                        b.MouseDown();
                    }
                    else b.MouseUp();
                }
                else b.MouseOut();

                if (input.CurrentKeyboardStates[0].IsKeyDown(b.ShortcutKey) && b.IsEnabled)
                {
                    if (b.SoulButton == 0)
                    {
                        Deselect();
                        b.IsSelected = true;
                    }
                    else
                    {
                        b.ActivateFunction(null);
                    }
                }
            }
        }
예제 #2
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)
        {
            if (input == null)
                throw new ArgumentNullException("input");

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

            gameSession.HandleInput(input);
        }
예제 #3
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);
                        }
                    }
                }
            }

            if (!ScreenManager.IsPhone)
            {
                Point mouseLocation = new Point(input.CurrentMouseState.X, input.CurrentMouseState.Y);

                for (int i = 0; i < menuEntries.Count; i++)
                {
                    MenuEntry menuEntry = menuEntries[i];

                    if (GetMenuEntryHitBounds(menuEntry).Contains(mouseLocation))
                    {
                        selectedEntry = i;

                        // Mouse left click?
                        if (input.CurrentMouseState.LeftButton == ButtonState.Released && input.LastMouseState.LeftButton == ButtonState.Pressed)
                        {
                            // 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);
                        }
                    }
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Responds to user input, accepting or cancelling the message box.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            PlayerIndex playerIndex;

            // We pass in our ControllingPlayer, which may either be null (to
            // accept input from any player) or a specific index. If we pass a null
            // controlling player, the InputState helper returns to us which player
            // actually provided the input. We pass that through to our Accepted and
            // Cancelled events, so they can tell which player triggered them.
            if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
            {
                // Raise the accepted event, then exit the message box.
                if (Accepted != null)
                    Accepted(this, new PlayerIndexEventArgs(playerIndex));

                ExitScreen();
            }
            else if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
            {
                // Raise the cancelled event, then exit the message box.
                if (Cancelled != null)
                    Cancelled(this, new PlayerIndexEventArgs(playerIndex));

                ExitScreen();
            }
        }
예제 #5
0
        /// <summary>
        /// Responds to user input, accepting or cancelling the message box.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            PlayerIndex playerIndex;

            if (TransitionPosition == 0)
            {
                foreach (GestureSample gesture in input.Gestures)
                {
                    if (gesture.GestureType == GestureType.Tap)
                    {
                        Exit();

                    }
                }

                if (!ScreenManager.IsPhone)
                {
                    Point mouseLocation = new Point(input.CurrentMouseState.X, input.CurrentMouseState.Y);

                    if (input.CurrentMouseState.LeftButton == ButtonState.Released && input.LastMouseState.LeftButton == ButtonState.Pressed)
                    {
                        Exit();
                    }
                }

                if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
                {
                    Exit();
                }
            }
        }
예제 #6
0
        public void HandleInput(InputState input, int team)
        {
            bool found = false;

            foreach (Dude d in Dudes)
            {
                if (!d.Active) continue;

                if (!found)
                {
                    if (d.Team == team)
                    {
                        if (d.UIRect.Contains(new Point(input.CurrentMouseState.X, input.CurrentMouseState.Y)))
                        {
                            d.UIHover = true;
                            found = true;
                        }

                        if (input.TapPosition.HasValue && d.UIRect.Contains(new Point((int)input.TapPosition.Value.X, (int)input.TapPosition.Value.Y)))
                        {
                            GameSession.Instance.ButtonController.DudeClicked(d);
                            found = true;
                        }
                    }
                }
            }
        }
예제 #7
0
        public void HandleInput(InputState input)
        {
            if (!IsAttractMode && !Team1Win && !Team2Win && StartCountdown<=0)
            {
                var kbscroll = Vector2.Zero;
                if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.D)) kbscroll.X = 10f;
                if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.A)) kbscroll.X = -10f;
                if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.W)) kbscroll.Y = -10f;
                if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.S)) kbscroll.Y = 10f;
                if (kbscroll != Vector2.Zero) this.Map.DoScroll(kbscroll);

                if (input.PinchGesture.HasValue)
                {
                    this.Map.DoZoom(input.GetScaleFactor(input.PinchGesture.Value));
                }
                if (input.DragGesture.HasValue)
                {
                    this.Map.DoScroll(new Vector2(-input.DragGesture.Value.Delta.X, input.DragGesture.Value.Delta.Y) * 3f);
                }
                if (input.MouseDragging)
                {
                    this.Map.DoScroll(new Vector2(-input.MouseDelta.X, input.MouseDelta.Y));
                }
                if (input.CurrentMouseState.ScrollWheelValue > input.LastMouseState.ScrollWheelValue) this.Map.DoZoom(1.03f);
                if (input.CurrentMouseState.ScrollWheelValue < input.LastMouseState.ScrollWheelValue) this.Map.DoZoom(0.97f);

                if (Team1ClientType == GameClientType.Human) DudeController.HandleInput(input, 0);
                if (Team2ClientType == GameClientType.Human) DudeController.HandleInput(input, 1);

                ButtonController.HandleInput(input);

            }
        }