Beispiel #1
0
 /// <summary>
 /// Criar um estado dos botões em branco. Todos os botões em estado Released.
 /// </summary>
 /// <returns>GameKeysState</returns>
 private GameKeysState createEmptyGameKeysState()
 {
     GameKeysState g = new GameKeysState(GameKeyState.Released,
         GameKeyState.Released, GameKeyState.Released, GameKeyState.Released,
         GameKeyState.Released, GameKeyState.Released, GameKeyState.Released,
         GameKeyState.Released, GameKeyState.Released, GameKeyState.Released,
         GameKeyState.Released, GameKeyState.Released, GameKeyState.Released,
         GameKeyState.Released, GameKeyState.Released, GameKeyState.Released,
         GameKeyState.Released, GameKeyState.Released, GameKeyState.Released,
         GameKeyState.Released, GameKeyState.Released, GameKeyState.Released,
         GameKeyState.Released, GameKeyState.Released, GameKeyState.Released,
         GameKeyState.Released, GameKeyState.Released, GameKeyState.Released,
         GameKeyState.Released, GameKeyState.Released);
     return g;
 }
 /// <summary>
 /// Construtor dos argumentos 
 /// </summary>
 /// <param name="state">Estado dos botões</param>
 /// <param name="key">Key envolvida no evento</param>
 public InputHandlerEventArgs(GameKeysState state, GameKeys key)
 {
     this.gameKeysState = state;
     this.key = key;
 }
Beispiel #3
0
        /// <summary>
        /// Se o input está espelhado troca a direita pela esquerda e vice versa.
        /// </summary>
        /// <param name="keysState">Estados das teclas atuais</param>
        /// <returns>GameKeysState</returns>
        private GameKeysState changeStateIfMirrored(GameKeysState keysState)
        {
            GameKeysState newKeysState = keysState;
            if (IsMirrored)
            {
                newKeysState.Left = keysState.Right;
                newKeysState.Right = keysState.Left;

                newKeysState.UpRight = keysState.UpLeft;
                newKeysState.UpLeft = keysState.UpRight;

                newKeysState.DownRight = keysState.DownLeft;
                newKeysState.DownLeft = keysState.DownRight;
            }
            return newKeysState;
        }
Beispiel #4
0
 public void ResetState()
 {
     _currentGameKeysState = createEmptyGameKeysState();
     _previousGameKeysState = createEmptyGameKeysState();
 }
Beispiel #5
0
        public override void Initialize()
        {
            if (_initialized) return;

            _previousGameKeysState = createEmptyGameKeysState();
            // Mapeia o teclado para jogar.
            mapKeyboard();

            _initialized = true;
        }
Beispiel #6
0
 private GameKeysState updateStateDirectionRight(Buttons direction, GameKeysState state)
 {
     // Calcula estado a parti da direção
     switch (direction)
     {
         case Direction.T2Up:
             state.T2Up = GameKeyState.Pressed;
             break;
         case Direction.T2Down:
             state.T2Down = GameKeyState.Pressed;
             break;
         case Direction.T2Left:
             state.T2Left = GameKeyState.Pressed;
             break;
         case Direction.T2Right:
             state.T2Right = GameKeyState.Pressed;
             break;
         case Direction.T2UpLeft:
             state.T2UpLeft = GameKeyState.Pressed;
             break;
         case Direction.T2UpRight:
             state.T2UpRight = GameKeyState.Pressed;
             break;
         case Direction.T2DownLeft:
             state.T2DownLeft = GameKeyState.Pressed;
             break;
         case Direction.T2DownRight:
             state.T2DownRight = GameKeyState.Pressed;
             break;
         case Direction.None:
             state.T2NoneDirection = GameKeyState.Pressed;
             break;
     }
     return state;
 }
Beispiel #7
0
        /// <summary>
        /// Checa o estado
        /// </summary>
        private void updateState(GameTime gameTime)
        {
            if (_lastUpdateState.Add(_updateStateDelay).CompareTo(gameTime.TotalGameTime) >= 0)
                return;
            else
                _lastUpdateState = gameTime.TotalGameTime;

            #if XBOX
            _currentGameKeysState = getGameKeysStateFromGamepad();
            #elif WINDOWS
            //if(ZouInfo.Controllers.CurrentStates[(int)PlayerIndex] == ControllerState.On)
                //_currentGameKeysState = getGameKeysStateFromGamepad();
            //else
                _currentGameKeysState = getGameKeysStateFromKeyBoard();
            #endif

            _currentGameKeysState = changeStateIfMirrored(_currentGameKeysState);

            // Corrige problema de precionado.
            if (_currentGameKeysState.UpLeft == GameKeyState.Pressed)
            {
                _currentGameKeysState.Up = GameKeyState.Pressed;
                _currentGameKeysState.Left = GameKeyState.Pressed;
            }

            if (_currentGameKeysState.UpRight == GameKeyState.Pressed)
            {
                _currentGameKeysState.Up = GameKeyState.Pressed;
                _currentGameKeysState.Right = GameKeyState.Pressed;
            }

            if (_currentGameKeysState.DownLeft == GameKeyState.Pressed)
            {
                _currentGameKeysState.Down = GameKeyState.Pressed;
                _currentGameKeysState.Left = GameKeyState.Pressed;
            }

            if (_currentGameKeysState.DownRight == GameKeyState.Pressed)
            {
                _currentGameKeysState.Down = GameKeyState.Pressed;
                _currentGameKeysState.Right = GameKeyState.Pressed;
            }

            checkKeyState(GameKeys.A, _previousGameKeysState.A, _currentGameKeysState.A);
            checkKeyState(GameKeys.B, _previousGameKeysState.B, _currentGameKeysState.B);
            checkKeyState(GameKeys.X, _previousGameKeysState.X, _currentGameKeysState.X);
            checkKeyState(GameKeys.Y, _previousGameKeysState.Y, _currentGameKeysState.Y);

            checkKeyState(GameKeys.LB, _previousGameKeysState.L1, _currentGameKeysState.L1);
            checkKeyState(GameKeys.LT, _previousGameKeysState.L2, _currentGameKeysState.L2);
            checkKeyState(GameKeys.RB, _previousGameKeysState.R1, _currentGameKeysState.R1);
            checkKeyState(GameKeys.RT, _previousGameKeysState.R2, _currentGameKeysState.R2);

            checkKeyState(GameKeys.Start, _previousGameKeysState.Start, _currentGameKeysState.Start);
            checkKeyState(GameKeys.Back, _previousGameKeysState.Back, _currentGameKeysState.Back);

            checkKeyState(GameKeys.UpRight, _previousGameKeysState.UpRight, _currentGameKeysState.UpRight);
            checkKeyState(GameKeys.UpLeft, _previousGameKeysState.UpLeft, _currentGameKeysState.UpLeft);
            checkKeyState(GameKeys.DownLeft, _previousGameKeysState.DownLeft, _currentGameKeysState.DownLeft);
            checkKeyState(GameKeys.DownRight, _previousGameKeysState.DownRight, _currentGameKeysState.DownRight);

            checkKeyState(GameKeys.Up, _previousGameKeysState.Up, _currentGameKeysState.Up);
            checkKeyState(GameKeys.Down, _previousGameKeysState.Down, _currentGameKeysState.Down);
            checkKeyState(GameKeys.Left, _previousGameKeysState.Left, _currentGameKeysState.Left);
            checkKeyState(GameKeys.Right, _previousGameKeysState.Right, _currentGameKeysState.Right);

            checkKeyState(GameKeys.NoneDirection, _previousGameKeysState.NoneDirection, _currentGameKeysState.NoneDirection);

            //T2
            checkKeyState(GameKeys.T2UpRight, _previousGameKeysState.T2UpRight, _currentGameKeysState.T2UpRight);
            checkKeyState(GameKeys.T2UpLeft, _previousGameKeysState.T2UpLeft, _currentGameKeysState.T2UpLeft);
            checkKeyState(GameKeys.T2DownLeft, _previousGameKeysState.T2DownLeft, _currentGameKeysState.T2DownLeft);
            checkKeyState(GameKeys.T2DownRight, _previousGameKeysState.T2DownRight, _currentGameKeysState.T2DownRight);

            checkKeyState(GameKeys.T2Up, _previousGameKeysState.T2Up, _currentGameKeysState.T2Up);
            checkKeyState(GameKeys.T2Down, _previousGameKeysState.T2Down, _currentGameKeysState.T2Down);
            checkKeyState(GameKeys.T2Left, _previousGameKeysState.T2Left, _currentGameKeysState.T2Left);
            checkKeyState(GameKeys.T2Right, _previousGameKeysState.T2Right, _currentGameKeysState.T2Right);

            checkKeyState(GameKeys.T2NoneDirection, _previousGameKeysState.T2NoneDirection, _currentGameKeysState.T2NoneDirection);

            checkKeyState(GameKeys.LeftStick, _previousGameKeysState.LeftStick, _currentGameKeysState.LeftStick);
            checkKeyState(GameKeys.RightStick, _previousGameKeysState.RightStick, _currentGameKeysState.RightStick);

            _previousGameKeysState = _currentGameKeysState;
        }