Esempio n. 1
0
    // Use this for initialization
    //void Start ()
    //{
    //
    //}

    // Update is called once per frame
    void Update()
    {
        if (anim != null)
        {
            object data = InputSystem.GetLogicInputEvent(ELogicInputEventType.MainJoystickSway);
            if (data != null)
            {
                JoystickInputData inputData = (JoystickInputData)data;
                if (inputData.status == EJoystickStatus.Released)
                {
                    anim.SetFloat("Speed", 0f);
                }
                else if (inputData.status == EJoystickStatus.Holden || inputData.status == EJoystickStatus.Swayed)
                {
                    anim.SetFloat("Speed", inputData.swayVector.magnitude);
                    // calculate actual running direction from controller parameters
                    float releAngle = Vector2.Angle(Vector2.up, inputData.swayVector);
                    // if angle from Vector.up to direction greater than 180 degree, make it negative
                    if (inputData.swayVector.x < 0f)
                    {
                        releAngle = -releAngle;
                    }
                    anim.SetFloat("Turn", releAngle);
                }
            }
        }
    }
Esempio n. 2
0
 private void Awake()
 {
     currentData = new JoystickInputData {
         swayVector = Vector2.zero, swayDelta = Vector2.zero, status = EJoystickStatus.Invalid
     };
     prevData = currentData;
 }
Esempio n. 3
0
    // Use this for initialization
    //void Start ()
    //{
    //
    //}

    // Update is called once per frame
    void LateUpdate()
    {
        object data = InputSystem.GetLogicInputEvent(ELogicInputEventType.SecondaryJoystickSway);

        if (data != null)
        {
            JoystickInputData inputData = (JoystickInputData)data;
            if (inputData.status == EJoystickStatus.Holden || inputData.status == EJoystickStatus.Swayed)
            {
                Vector3 temp =
                    new Vector3(
                        transform.eulerAngles.x + inputData.swayVector.y * cameraYSensitivity * (reverseY ? -1f : 1f),
                        transform.eulerAngles.y + inputData.swayVector.x * cameraXSensitivity * (reverseX ? -1f : 1f),
                        transform.eulerAngles.z
                        );
                transform.eulerAngles = temp;
            }
        }
        //if (inputData.status == EJoystickStatus.Released)
        //	anim.SetFloat("Speed", 0f);
        //else if (inputData.status == EJoystickStatus.Holden || inputData.status == EJoystickStatus.Swayed)
        //{
        //	anim.SetFloat("Speed", inputData.swayVector.magnitude);
        //	// calculate actual running direction from controller parameters
        //	float releAngle = Vector2.Angle(Vector2.up, inputData.swayVector);
        //	// if angle from Vector.up to direction greater than 180 degree, make it negative
        //	if (inputData.swayVector.x < 0f)
        //		releAngle = -releAngle;
        //	anim.SetFloat("Turn", releAngle);
        //}
    }
Esempio n. 4
0
 protected override void ResetAllFlags()
 {
     prevData = currentData;
     currentData.swayVector = Vector2.zero;
     currentData.swayDelta  = Vector2.zero;
     currentData.status     = EJoystickStatus.Invalid;
 }
Esempio n. 5
0
 protected override void ResetAllFlags()
 {
     prevMainData = currentMainData;
     currentMainData.swayVector      = Vector2.zero;
     currentMainData.swayDelta       = Vector2.zero;
     currentMainData.status          = EJoystickStatus.Invalid;
     prevSecondaryData               = currentSecondaryData;
     currentSecondaryData.swayVector = Vector2.zero;
     currentSecondaryData.swayDelta  = Vector2.zero;
     currentSecondaryData.status     = EJoystickStatus.Invalid;
 }