Exemplo n.º 1
0
    public void GetInput()
    {
        ///STICKS
        LeftStick.Excecute(character, controller.MainLeftJoystick());
        RightStick.Excecute(character, controller.MainRightJoystick());
        if (controller.LeftStickClick())
        {
            LeftStickButton.Excecute(character);
        }
        if (controller.RightStickClick())
        {
            RightStickButton.Excecute(character);
        }

        ///BUTTON TAPS / HOLD
        if (controller.AButton())
        {
            buttonDownPressTimer = Time.time;
            ButtonDown.Excecute(character, -1);
        }
        if (controller.VerticalDPad() < 0 && !DPadDownPressed)
        {
            DPadDownPressTimer = Time.time;
            DPadDownPressed    = true;
            DPadDown.Excecute(character);
        }

        if (controller.BButton())
        {
            buttonRightPressTimer = Time.time;
            ButtonRight.Excecute(character, -1);
        }
        if (controller.HorizontalDPad() > 0 && !DPadRightPressed)
        {
            DPadRightPressTimer = Time.time;
            DPadRightPressed    = true;
            ButtonRight.Excecute(character, -1);
        }


        if (controller.XButton())
        {
            buttonLeftPressTimer = Time.time;
            ButtonLeft.Excecute(character, -1);
        }
        if (controller.HorizontalDPad() < 0 && !DPadLeftPressed)
        {
            DPadLeftPressTimer = Time.time;
            DPadLeftPressed    = true;
            DPadLeft.Excecute(character, -1);
        }


        if (controller.YButton())
        {
            buttonUpPressTimer = Time.time;
            ButtonUp.Excecute(character, -1);
        }
        if (controller.VerticalDPad() > 0 && !DPadUpPressed)
        {
            DPadUpPressTimer = Time.time;
            DPadUpPressed    = true;
            DPadUp.Excecute(character, -1);
        }

        ///BUTTON UPS
        if (controller.AButtonRelease())
        {
            float time = Time.time - buttonDownPressTimer;
            ButtonDown.Excecute(character, time);
        }
        if (controller.VerticalDPad() >= 0 && DPadDownPressed)
        {
            float time = Time.time - DPadDownPressTimer;
            DPadDownPressed = false;
            DPadDown.Excecute(character, time);
        }

        if (controller.BButtonRelease())
        {
            float time = Time.time - buttonRightPressTimer;
            ButtonRight.Excecute(character, time);
        }
        if (controller.HorizontalDPad() <= 0 && DPadRightPressed)
        {
            float time = Time.time - DPadRightPressTimer;
            DPadRightPressed = false;
            DPadRight.Excecute(character, time);
        }

        if (controller.XButtonRelease())
        {
            float time = Time.time - buttonLeftPressTimer;
            ButtonLeft.Excecute(character, time);
        }
        if (controller.HorizontalDPad() >= 0 && DPadLeftPressed)
        {
            float time = Time.time - DPadLeftPressTimer;
            DPadLeftPressed = false;
            DPadLeft.Excecute(character, time);
        }

        if (controller.YButtonRelease())
        {
            float time = Time.time - buttonUpPressTimer;
            ButtonUp.Excecute(character, time);
        }
        if (controller.VerticalDPad() <= 0 && DPadUpPressed)
        {
            float time = Time.time - DPadUpPressTimer;
            DPadUpPressed = false;
            DPadUp.Excecute(character, time);
        }

        ///BUMPERS
        if (controller.RightBumper())
        {
            RightBumper.Excecute(character);
        }

        if (controller.LeftBumper())
        {
            LeftBumper.Excecute(character);
        }

        if (controller.RightBumperRelease())
        {
            RightBumper.Excecute(character);
        }

        if (controller.LeftBumperRelease())
        {
            LeftBumper.Excecute(character);
        }

        ///TRIGGERS
        if (controller.RightTrigger() > 0)
        {
            rightTriggerInUse  = true;
            RightTriggerTimer += Time.deltaTime;

            if (RightTriggerTimer > 0.5f)
            {
                RightTrigger.Excecute(character, true);
            }
        }
        if (controller.RightTrigger() <= 0 && rightTriggerInUse)
        {
            if (RightTriggerTimer > 0.5f)
            {
                RightTrigger.Excecute(character, false);
            }
            else
            {
                RightTrigger.Excecute(character);
            }

            RightTriggerTimer = 0;
            rightTriggerInUse = false;
        }

        if (controller.LeftTrigger() > 0)
        {
            LeftTrigger.Excecute(character);
        }
        if (controller.LeftTrigger() <= 0 && leftTriggerInUse)
        {
            LeftTrigger.Excecute(character);
        }

        ///OPTIONS
        if (controller.SelectButton())
        {
            ShareButton.Excecute(character);
        }

        if (controller.StartButton())
        {
            OptionsButton.Excecute(character);
        }
    }