Exemplo n.º 1
0
        /// <summary>
        /// Responde ao input, aceitando ou cancelando a mensagem da janela
        /// </summary>
        public override void HandleInput(InputState input)
        {
            PlayerIndex playerIndex;

            // Se o 'ESC' for selecionado
            if (input.IsMenuSelect(this.ControllingPlayer, out playerIndex))
            {
                // Se o evento for diferente de nulo
                if (this.Accepted != null)
                {
                    this.Accepted(this, new PlayerIndexEventArgs(playerIndex));
                }
                // Chama saída do game
                this.ExitScreen();
            }
            else if (input.IsMenuCancel(this.ControllingPlayer, out playerIndex))
            {
                // Se o evento for diferente de nulo
                if (this.Cancelled != null)
                {
                    this.Cancelled(this, new PlayerIndexEventArgs(playerIndex));
                }
                // Chama saída da tela
                this.ExitScreen();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Verifica a entrada do teclado
        /// </summary>
        public override void HandleInput(InputState inputState)
        {
            // Se mover para entrada(item) anterior
            if (inputState.IsMenuUp(this.ControllingPlayer))
            {
                // Decrementa para subir pelos itens
                this.selectedEntry--;

                // Se for menor que zera
                if (this.selectedEntry < 0)
                {
                    // Vai para o último item do menu
                    this.selectedEntry = this.menuEntries.Count - 1;
                }
            }

            // Se mover para entrada(item) anterior
            if (inputState.IsMenuDown(this.ControllingPlayer))
            {
                // Incrementa para descer pelos itens
                this.selectedEntry++;

                // Se for maior que a quantidade de itens do menu
                if (this.selectedEntry >= this.menuEntries.Count)
                {
                    // Vai para o primeiro item do menu
                    this.selectedEntry = 0;
                }
            }

            // Controlador nulo inicialmente, que será passado através de 'OnSelectItem' e 'OnCancel'
            PlayerIndex playerIndex;

            // Se algum item do menu foi selecionado
            if (inputState.IsMenuSelect(ControllingPlayer, out playerIndex))
            {
                OnSelectEntry(selectedEntry, playerIndex);
            }
            // Senão...
            else if (inputState.IsMenuCancel(ControllingPlayer, out playerIndex))
            {
                OnCancel(playerIndex);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Recebe a entrada do teclado
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            // Pega a posição de jogador ativa
            int playerIndex = (int)ControllingPlayer.Value;

            // Recebe estado do teclado e GamePad
            KeyboardState keyboardState = input.CurrentKeyboardStates[playerIndex];
            GamePadState gamePadState = input.CurrentGamePadStates[playerIndex];

            // Desconectado?
            bool gamePadDisconnected = !gamePadState.IsConnected && input.GamePadWasConnected[playerIndex];

            // Se o game for pausado
            if (input.IsPauseGame(ControllingPlayer) || gamePadDisconnected)
            {
                // Adiciona o menu de 'Pause'
                ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer);
            }
            // Senão... verificar se vai reiniciar a fase
            else if (input.IsReload(this.ControllingPlayer))
            {
                this.ReloadCurrentLevel();
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Chamado somente quanto a tela estiver ativa, diferente do 'Update'
 /// </summary>
 public virtual void HandleInput(InputState input)
 {
 }