示例#1
0
        public bool Matches(InputHelper.CommandMove command)
        {
            InputHelper.KeyState previousKeyState = command.GetPreviousMove();
            InputHelper.KeyState currentKeyState = command.GetCurrentMove();
            InputBuffer currentBuffer = GetNextBuffer(currentKeyState);

            if (currentKeyState.GetState() != InputHelper.ButtonState.Held)
            {
                if (command.IsMaxNegativeReached() == true)
                {
                    command.Reset();
                    return false;
                }
                
                if (currentBuffer.GetCurrentInputState() == currentKeyState.GetKey())
                {
                    command.Next();

                    if (command.GetCurrentMoveStep() >= command.GetMoves().Count - 1)
                    {
                        currentKeyState = command.GetMoves()[command.GetMoves().Count - 1];
                    }
                    else
                    {
                        currentKeyState = command.GetCurrentMove();
                    }

                    currentBuffer = GetNextBuffer(currentKeyState);
                    Debug.WriteLine("NEXT BUFFER: " + currentKeyState.GetState());
                }
                else
                {
                    command.IncrementNegativeCount();
                }
            }
            else
            {
                Debug.WriteLine("IN HELD");
                checkHeld(command, currentKeyState);
            }

            if (command.IsComplete())
            {
                Debug.WriteLine("IS COMPLETE");
                command.Reset();
                ResetBuffers();
                return true;
            }

            return false;
        }
示例#2
0
        private void checkHeld(InputHelper.CommandMove command, InputHelper.KeyState currentKeyState)
        {
            int held = 0;
            Debug.WriteLine("HELD KEY: " + currentKeyState.GetState());
            currentKeyState = command.GetCurrentMove();

            if (command.IsMaxNegativeReached() == true)
            {
                command.Reset();
                held = 0;
            }

            if (releasedState.GetCurrentInputState() != InputHelper.KeyPress.NONE)
            {
                if (releasedState.GetCurrentInputState() == currentKeyState.GetKey()
                        || (releasedState.GetCurrentInputState(releasedState.GetCurrentStateStep()-2) == currentKeyState.GetKey()
                                && releasedState.GetCurrentInputState() != currentKeyState.GetKey()))
                {
                    command.Reset();
                }
            }

            for (int i = 0; i < heldState.GetBuffer().Count - 1; i++)
            {
                bool reset = (releasedState.GetBuffer().Count >= i + 2
                                    && releasedState.GetBuffer()[i + 1] == currentKeyState.GetKey());

                if (reset)
                {
                    held = 0;
                    command.IncrementNegativeCount();
                    break;
                }

                if (heldState.GetBuffer()[i + 1] == currentKeyState.GetKey())
                {
                    held++;
                    command.ResetNegativeEdge();
                }
                else
                {
                    held = 0;
                    command.Reset();
                    break;
                }
            }

            Debug.WriteLine("HELD COUNT: " + held);
            Debug.WriteLine("HELD TIME: " + currentKeyState.GetKeyHeldTime());

            if (held >= currentKeyState.GetKeyHeldTime())
            {
                command.Next();
            }
            else
            {
                command.IncrementNegativeCount();
            }
        }