예제 #1
0
        private void DetectTouchpadInputs(out bool actionTeleportation, out bool shiftLeft, out bool shiftRight)
        {
            actionTeleportation = false;
            shiftLeft           = false;
            shiftRight          = false;

            /* on touch start, note current touch position and prepare for shift */
            Vector2 touchpadPosition = TBInput.GetAxis2D(TBInput.Button.Touchpad, controller);

            if (TBInput.GetTouchDown(TBInput.Button.Action1, controller))
            {
                touchpadPrepareForShift      = true;
                touchpadPositionOnTouchStart = touchpadPosition;
            }
            /* on touchpad release, check whether shift flag is still up and whether minimum threshold is met */
            else if (TBInput.GetTouchUp(TBInput.Button.Action1, controller) && touchpadPrepareForShift)
            {
                touchpadPrepareForShift = false;
                if (Mathf.Abs(touchpadPosition.x - touchpadPositionOnTouchStart.x) > touchpadSwipeThreshold)
                {
                    if (touchpadPosition.x < touchpadPositionOnTouchStart.x)
                    {
                        shiftLeft = true;
                    }
                    else
                    {
                        shiftRight = true;
                    }
                }
            }
            /* when button is clicked, initiate teleport and cancel shift */
            if (TBInput.GetButton(TBInput.Button.Action1, controller))
            {
                touchpadPrepareForShift = false;
                actionTeleportation     = true;
            }
        }