예제 #1
0
        public void PerformMove(Move moveToPerform, KeyboardState keyboardStateInput, GamePadState gamepadStateInput)
        {
            if (moveToPerform.name == "RunLeft")
            {
                _speed.X = -1.25f;
                if (gamepadStateInput.IsButtonUp(Buttons.DPadLeft) && gamepadStateInput.IsButtonUp(Buttons.LeftThumbstickLeft) && keyboardStateInput.IsKeyUp(Keys.Left))
                {
                    _speed.X = 0;
                    _playerMostRecentMove = null;
                }
            }
            if (moveToPerform.name == "RunRight")
            {
                _speed.X = 1.25f;
                if (gamepadStateInput.IsButtonUp(Buttons.DPadRight) && gamepadStateInput.IsButtonUp(Buttons.LeftThumbstickRight) && keyboardStateInput.IsKeyUp(Keys.Right))
                {
                    _speed.X = 0;
                    _playerMostRecentMove = null;
                }
            }
            if (moveToPerform.name == "SprintLeft")
            {
                _speed.X = -1.75f;
                if (gamepadStateInput.IsButtonUp(Buttons.DPadLeft) && gamepadStateInput.IsButtonUp(Buttons.LeftThumbstickLeft) && keyboardStateInput.IsKeyUp(Keys.Left))
                {
                    _speed.X = 0;
                    _playerMostRecentMove = null;
                }
            }
            if (moveToPerform.name == "SprintRight")
            {
                _speed.X = 1.75f;
                if (gamepadStateInput.IsButtonUp(Buttons.DPadRight) && gamepadStateInput.IsButtonUp(Buttons.LeftThumbstickRight) && keyboardStateInput.IsKeyUp(Keys.Right))
                {
                    _speed.X = 0;
                    _playerMostRecentMove = null;
                }
            }
            if (moveToPerform.name == "Jump")
            {
                _isJumping = true;
                /*if (gamepadStateInput.IsButtonUp(Buttons.A) && keyboardStateInput.IsKeyUp(Keys.A))
                {
                    isJumping = false;
                    playerMostRecentMove = null;
                }*/

            }
        }
        ///<summary>
        ///determines if a move matches the current input history.
        ///unless the move is a sub-move, the history is "consumed" to prevent it from matching twice.
        ///</summary>
        ///<returns> true if the move matches the input history. </returns>
        public bool SequenceMatchesMove(Move moveInput)
        {
            //if the move is longer than the buffer, it can't possibly match
            if (sequenceBuffer.Count < moveInput.comboSequence.Length)
                return false;

            //loop backwards to match against the most recent input
            for (int i = 1; i <= moveInput.comboSequence.Length; ++i)
            {
                if (sequenceBuffer[sequenceBuffer.Count - i] != moveInput.comboSequence[moveInput.comboSequence.Length - i])
                {
                    return false;
                }
            }

            //Runless this move is a component of a larger sequence
            if (!moveInput.IsSubMove)
            {
                //consume the used input
                sequenceBuffer.Clear();
            }

            return true;
        }
예제 #3
0
        public void Update(GameTime gameTimeInput, KeyboardState keyboardStateInput, GamePadState gamepadStateInput)
        {
            //update the input
            _inputManager.Update(gameTimeInput);

            // Dection and record the currents player's move recent move
            Move newMove = _currentMoveList.DetectMove(_inputManager);
            if (newMove != null)
            {
                _playerMostRecentMove = newMove;
                _playerMostRecentMoveTime = gameTimeInput.TotalGameTime;
            }

            if (_playerMostRecentMove != null)
            {
                PerformMove(_playerMostRecentMove, keyboardStateInput, gamepadStateInput);
            }

            //temp stuff to test jumping
            _isJumping = gamepadStateInput.IsButtonDown(Buttons.A);
            _isJumping = keyboardStateInput.IsKeyDown(Keys.A);

            base.Update(gameTimeInput);
        }