/// <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 (InputManager.IsActionTriggered(InputManager.Action.ExitGame))
            {
                if (!IsExiting)
                {
                    if ((world != null) && !world.GameExited)
                    {
                        if (input.PauseGame && !world.GameWon)
                        {
                            // If they pressed pause, bring up the pause menu screen.
                            const string message = "Exit the game?";
                            MessageBoxScreen messageBox = new MessageBoxScreen(message,
                                false);
                            messageBox.Accepted += ExitMessageBoxAccepted;
                            ScreenManager.AddScreen(messageBox);
                        }
                        if (input.MenuSelect && world.GameWon)
                        {
                            world.GameExited = true;
                            world = null;
                            if (!IsExiting)
                            {
                                ExitScreen();
                            }
                            networkSession = null;
                        }
                    }
                }
            }
            if (InputManager.IsActionTriggered(InputManager.Action.ZoomIn))
            {

            }
        }
Beispiel #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)
        {
            // safety-check the parameter
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            if ((networkSession != null) && (networkSession.LocalGamers.Count > 0))
            {
                // update the ready state
                if (input.MarkReady)
                {
                    networkSession.LocalGamers[0].IsReady =
                        !networkSession.LocalGamers[0].IsReady;
                }

                // update the player data
                PlayerData playerData = networkSession.LocalGamers[0].Tag as PlayerData;
                if (playerData != null)
                {
                    bool playerDataChanged = false;

                    // if the data changed, send an update to the others
                    if (playerDataChanged)
                    {
                        packetWriter.Write((int)World.PacketTypes.PlayerData);
                        playerData.Serialize(packetWriter);
                        networkSession.LocalGamers[0].SendData(packetWriter,
                            SendDataOptions.ReliableInOrder);
                    }
                }
            }

            base.HandleInput(input);
        }
Beispiel #3
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            // Move to the previous menu entry?
            if (input.MenuUp)
            {
                selectedEntry--;

                if (selectedEntry < 0)
                    selectedEntry = menuEntries.Count - 1;

                AudioManager.PlayCue("menuMove");
            }

            // Move to the next menu entry?
            if (input.MenuDown)
            {
                selectedEntry++;

                if (selectedEntry >= menuEntries.Count)
                    selectedEntry = 0;

                AudioManager.PlayCue("menuMove");
            }

            // Accept or cancel the menu?
            if (input.MenuSelect)
            {
                AudioManager.PlayCue("menuSelect");
                OnSelectEntry(selectedEntry);
            }
            else if (input.MenuCancel)
            {
                OnCancel();
            }
        }
Beispiel #4
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)
 {
 }