示例#1
0
        public bool AnyInput(int playerID)
        {
            switch (m_type)
            {
            case InputType.KeyButton:
                return(Input.GetKey(m_positive));

            case InputType.GamepadAnalogButton:
                return(axesAsButtonValues[playerID] == ButtonState.Pressed || axesAsButtonValues[playerID] == ButtonState.JustPressed);

            case InputType.GamepadButton:
                return(GamepadHandler.GetButton(m_gamepadButton, playerID));

            case InputType.GamepadAxis:
                return(GamepadHandler.GetAxisRaw(m_gamepadAxis, playerID, m_deadZone) != 0f);

            case InputType.DigitalAxis:
                return(digitalAxisValue != 0);

            case InputType.MouseAxis:
                return(Input.GetAxisRaw(rawMouseAxisName) != 0);

            default:
                return(false);
            }
        }
示例#2
0
        public float GetAxisRaw(int playerID)
        {
            float axis = 0;

            if (m_type == InputType.DigitalAxis)
            {
                if (Input.GetKey(m_positive))
                {
                    axis = m_invert ? -AXIS_POSITIVE : AXIS_POSITIVE;
                }
                else if (Input.GetKey(m_negative))
                {
                    axis = m_invert ? -AXIS_NEGATIVE : AXIS_NEGATIVE;
                }
            }
            else if (m_type == InputType.MouseAxis)
            {
                axis = Input.GetAxisRaw(rawMouseAxisName);
                axis = m_invert ? -axis : axis;
            }
            else if (m_type == InputType.GamepadAxis)
            {
                axis = GamepadHandler.GetAxisRaw(m_gamepadAxis, playerID, m_deadZone);
                axis = m_invert ? -axis : axis;
            }

            else if (m_type == InputType.KeyButton)
            {
                if (GetButton(playerID))
                {
                    axis = m_invert ? -AXIS_POSITIVE : AXIS_POSITIVE;
                }
            }
            else if (m_type == InputType.GamepadButton)
            {
                if (GetButton(playerID))
                {
                    axis = m_invert ? -AXIS_POSITIVE : AXIS_POSITIVE;
                }
            }
            else if (m_type == InputType.GamepadAnalogButton)
            {
                if (GetButton(playerID))
                {
                    axis = m_invert ? -AXIS_POSITIVE : AXIS_POSITIVE;
                }
            }


            return(axis);
        }