Esempio n. 1
0
    /// <summary>
    /// Checks if button has been released before allowing it to be pressed.
    /// </summary>
    /// <param name="button"></param>
    /// <returns></returns>
    public bool IsButtonPressed(PlayerInputButton button)
    {
        if (button == PlayerInputButton.A && aAllowed)
        {
            bool pressed = currentInputFrame.IsButtonPressed(button);
            aAllowed = !pressed;
            return(pressed);
        }
        else if (button == PlayerInputButton.B && bAllowed)
        {
            return(false);
        }
        else if (button == PlayerInputButton.C && cAllowed)
        {
            return(false);
        }
        else if (button == PlayerInputButton.D && dAllowed)
        {
            return(false);
        }
        else if (button == PlayerInputButton.SWAP && swapAllowed)
        {
            return(false);
        }

        return(currentInputFrame.IsButtonPressed(button));
    }
Esempio n. 2
0
    public void Enqueue(PlayerInputFrame frame)
    {
        if (inputBuffer.Count >= size)
        {
            inputBuffer.Dequeue();
        }

        currentInputFrame = frame;
        inputBuffer.Enqueue(frame);

        if (frame.IsButtonPressed(PlayerInputButton.A_RELEASE))
        {
            aAllowed = true;
        }
    }
Esempio n. 3
0
    public override bool ExecuteInput()
    {
        PlayerInputFrame currentInputFrame = player.currentInputFrame;
        InputBuffer      inputBuffer       = player.inputBuffer;

        if (currentInputFrame.IsButtonPressed(PlayerInputButton.UP))
        {
            if (currentInputFrame.IsForwardPressed())
            {
                machine.ChangeState <JumpingForwardState>();
            }
            else if (currentInputFrame.IsBackwardPressed())
            {
                machine.ChangeState <JumpingBackwardState>();
            }
            else
            {
                machine.ChangeState <JumpingUpState>();
            }
        }
        else if (currentInputFrame.IsForwardPressed())
        {
            machine.ChangeState <WalkingForwardState>();
        }
        else if (currentInputFrame.IsBackwardPressed())
        {
            machine.ChangeState <WalkingBackwardState>();
        }
        else if (inputBuffer.IsButtonPressed(PlayerInputButton.A))
        {
            machine.ChangeState <StandingAState>();
        }
        else
        {
            machine.ChangeState <StandingState>();
        }

        return(false);
    }