public override bool GetButtonCurrentUpState()
 {
     // As XboxJoystickDPad is an exact copy of XboxDPad
     // in this implementation, I can just cast the enum.
     return(XCI.GetDPadUp((XboxDPad)this.button));
 }
Esempio n. 2
0
    private void UpdateCtrl_XCI()
    {
        Vector2 vec = new Vector2();

        // Left Stick
        if (XCI.GetButtonDown(XboxButton.LeftStick, m_Ctrler))
        {
        }

        // Right Stick
        if (XCI.GetButtonDown(XboxButton.RightStick, m_Ctrler))
        {
        }

        // Left stick movement
        float axisLX = XCI.GetAxis(XboxAxis.LeftStickX, m_Ctrler);
        float axisLY = XCI.GetAxis(XboxAxis.LeftStickY, m_Ctrler);

        vec.x = axisLX;
        vec.y = axisLY;
        if (vec.magnitude > m_MinStickDragDis)
        {
            InputManager.instance.InputCommand(m_Role, CommandType.Move, vec);
        }
        else
        {
            InputManager.instance.InputCommand(m_Role, CommandType.StopMove);
        }

        // Right stick movement
        float axisRX = XCI.GetAxis(XboxAxis.RightStickX, m_Ctrler);
        float axisRY = XCI.GetAxis(XboxAxis.RightStickY, m_Ctrler);

        vec.x = axisRX;
        vec.y = axisRY;
        if (vec.magnitude > m_MinStickDragDis)
        {
            InputManager.instance.InputCommand(m_Role, CommandType.Attack, vec);
        }
        else
        {
            InputManager.instance.InputCommand(m_Role, CommandType.StopAttack);
            InputManager.instance.InputCommand(m_Role, CommandType.CastAttack);
        }

        // D-Pad
        if (XCI.GetDPad(XboxDPad.Up, m_Ctrler))
        {
            InputManager.instance.InputCommand(m_Role, CommandType.Move, Vector2.up);
        }
        if (XCI.GetDPad(XboxDPad.Down, m_Ctrler))
        {
            InputManager.instance.InputCommand(m_Role, CommandType.Move, Vector2.down);
        }
        if (XCI.GetDPad(XboxDPad.Left, m_Ctrler))
        {
            InputManager.instance.InputCommand(m_Role, CommandType.Move, Vector2.left);
        }
        if (XCI.GetDPad(XboxDPad.Right, m_Ctrler))
        {
            InputManager.instance.InputCommand(m_Role, CommandType.Move, Vector2.right);
        }
        if (XCI.GetDPadUp(XboxDPad.Up, m_Ctrler) || XCI.GetDPadUp(XboxDPad.Down, m_Ctrler) ||
            XCI.GetDPadUp(XboxDPad.Left, m_Ctrler) || XCI.GetDPadUp(XboxDPad.Right, m_Ctrler))
        {
            InputManager.instance.InputCommand(m_Role, CommandType.StopMove);
        }

        // A,B,X,Y
        if (XCI.GetButton(XboxButton.A, m_Ctrler))
        {
            // InputManager.instance.InputCommand(m_Role, CommandType.Attack, Vector2.down);
            m_Role.EnsureTransmission();
        }
        // if (XCI.GetButton(XboxButton.B, m_Ctrler))
        // {
        //     InputManager.instance.InputCommand(m_Role, CommandType.Attack, Vector2.right);
        // }
        // if (XCI.GetButton(XboxButton.X, m_Ctrler))
        // {
        //     InputManager.instance.InputCommand(m_Role, CommandType.Attack, Vector2.left);
        // }
        // if (XCI.GetButton(XboxButton.Y, m_Ctrler))
        // {
        //     InputManager.instance.InputCommand(m_Role, CommandType.Attack, Vector2.up);
        // }
        // if (XCI.GetButtonUp(XboxButton.A, m_Ctrler) || XCI.GetButtonUp(XboxButton.B, m_Ctrler) ||
        // XCI.GetButtonUp(XboxButton.X, m_Ctrler) || XCI.GetButtonUp(XboxButton.Y, m_Ctrler))
        // {
        //     InputManager.instance.InputCommand(m_Role, CommandType.StopAttack);
        //     InputManager.instance.InputCommand(m_Role, CommandType.CastAttack);
        // }

        // Trigger input
        float trigL = XCI.GetAxis(XboxAxis.LeftTrigger, m_Ctrler);
        float trigR = XCI.GetAxis(XboxAxis.RightTrigger, m_Ctrler);

        // Bumper input
        if (XCI.GetButtonDown(XboxButton.LeftBumper, m_Ctrler))
        {
        }
        if (XCI.GetButtonDown(XboxButton.RightBumper, m_Ctrler))
        {
        }

        // Start and back, same as bumpers but smaller bullets
        if (XCI.GetButtonUp(XboxButton.Back, m_Ctrler))
        {
        }
        if (XCI.GetButtonUp(XboxButton.Start, m_Ctrler))
        {
        }
    }
    // Update is called once per frame
    void Update()
    {
        ButtonTimer += Time.deltaTime * 5.0f;

        // If menu is enabled
        if (!IsDisabled)
        {
            // Main Menu Only
            if (button[buttonIndex].GetComponent <ButtonBehavior>().IsMainMenu)
            {
                // Menu Up
                if (XCI.GetDPadUp(XboxDPad.Down) || ((XCI.GetAxis(XboxAxis.RightStickY) < 0 || XCI.GetAxis(XboxAxis.LeftStickY) < 0) && ButtonTimer > 1.0f))
                {
                    button[buttonIndex].GetComponent <ButtonBehavior>().HighLighted = false;
                    buttonIndex++;
                    if (buttonIndex > buttonTotal - 1)
                    {
                        buttonIndex = 0;
                    }
                    button[buttonIndex].GetComponent <ButtonBehavior>().HighLighted = true;
                    ButtonTimer = 0.0f;
                    PlayNavSound();
                }

                // Menu Down
                if (XCI.GetDPadUp(XboxDPad.Up) || ((XCI.GetAxis(XboxAxis.RightStickY) > 0 || XCI.GetAxis(XboxAxis.LeftStickY) > 0) && ButtonTimer > 1.0f))
                {
                    button[buttonIndex].GetComponent <ButtonBehavior>().HighLighted = false;
                    buttonIndex--;
                    if (buttonIndex < 0)
                    {
                        buttonIndex = buttonTotal - 1;
                    }
                    button[buttonIndex].GetComponent <ButtonBehavior>().HighLighted = true;
                    ButtonTimer = 0.0f;
                    PlayNavSound();
                }
            }

            // Indicate button was pressed
            if (XCI.GetButtonUp(XboxButton.A) && !button[buttonIndex].GetComponent <ButtonBehavior>().IsFunctionButton&& ButtonTimer > 1.0f)
            {
                button[buttonIndex].GetComponent <ButtonBehavior>().Pressed = true;

                button[buttonIndex].GetComponent <ButtonBehavior>().OptionEnabled = button[buttonIndex].GetComponent <ButtonBehavior>().OptionEnabled ? false : true;

                ButtonTimer = 0.0f;
            }

            // If Button Has a function
            else if (XCI.GetButtonUp(XboxButton.A) && ButtonTimer > 1.0f)
            {
                ButtonFunction(button[buttonIndex].GetComponent <ButtonBehavior>().ButtonName);
                ButtonTimer = 0.0f;
            }


            // Options Only
            if (button[buttonIndex].GetComponent <ButtonBehavior>().IsOption)
            {
                if (FirstFrame)
                {
                    ImageHolder.GetComponent <Image>().sprite = HowToPlayImages[ImageIndex].GetComponent <Image>().sprite;
                    ImageHolder.GetComponent <Animator>().runtimeAnimatorController = HowToPlayImages[ImageIndex].GetComponent <Animator>().runtimeAnimatorController;
                    FirstFrame = false;
                }

                if (XCI.GetButtonUp(XboxButton.B))
                {
                    OptionCanvas.SetActive(OptionCanvas.activeSelf == false ? true : false);
                    button[buttonIndex].GetComponent <ButtonBehavior>().OptionEnabled = button[buttonIndex].GetComponent <ButtonBehavior>().OptionEnabled ? false : true;
                    button[buttonIndex].GetComponent <ButtonBehavior>().Pressed       = false;
                    ButtonFunction("Close");
                }

                // Indicate button was pressed
                if (XCI.GetButtonUp(XboxButton.A) && button[buttonIndex].GetComponent <ButtonBehavior>().IsFunctionButton&& ButtonTimer > 1.0f)
                {
                    button[buttonIndex].GetComponent <ButtonBehavior>().Pressed = true;

                    button[buttonIndex].GetComponent <ButtonBehavior>().OptionEnabled = button[buttonIndex].GetComponent <ButtonBehavior>().OptionEnabled ? false : true;
                    ButtonFunction(button[buttonIndex].GetComponent <ButtonBehavior>().ButtonName);
                    ButtonTimer = 0.0f;
                }

                if (XCI.GetDPadUp(XboxDPad.Left) || ((XCI.GetAxis(XboxAxis.RightStickX) < 0 || XCI.GetAxis(XboxAxis.LeftStickX) < 0) && ButtonTimer > 1.0f))
                {
                    button[buttonIndex].GetComponent <ButtonBehavior>().HighLighted = false;
                    buttonIndex--;
                    buttonIndex = Mathf.Clamp(buttonIndex, 0, 2);
                    button[buttonIndex].GetComponent <ButtonBehavior>().HighLighted = true;
                    PlayNavSound();
                    ButtonTimer = 0.0f;
                }

                if (XCI.GetDPadUp(XboxDPad.Right) || ((XCI.GetAxis(XboxAxis.RightStickX) > 0 || XCI.GetAxis(XboxAxis.LeftStickX) > 0) && ButtonTimer > 1.0f))
                {
                    button[buttonIndex].GetComponent <ButtonBehavior>().HighLighted = false;
                    buttonIndex++;
                    buttonIndex = Mathf.Clamp(buttonIndex, 0, 2);
                    button[buttonIndex].GetComponent <ButtonBehavior>().HighLighted = true;
                    PlayNavSound();
                    ButtonTimer = 0.0f;
                }

                button[0].GetComponent <ButtonBehavior>().IsDisabled = (ImageIndex == 0 ? true : false);
                button[2].GetComponent <ButtonBehavior>().IsDisabled = (ImageIndex == HowToPlayImages.Length - 1 ? true : false);
            }
        }
    }