void OnDestroy()
        {
            _onXZPlane    = null;
            _onXZPlaneEnd = null;

            if (_gestureSwipe != null)
            {
                _gestureSwipe.Destroy();
                _gestureSwipe = null;
            }
        }
        void Start()
        {
            _gestureSwipe = new GestureSwipe(GestureSwiteCallback, stationary: true);

            if (_camera == null)
            {
                _camera = Camera.main;
            }

            var diagonal = new Vector2(Screen.width, Screen.height);

            _diagonalLen = diagonal.magnitude;
        }
コード例 #3
0
        void OnEnable() {
            TouchInputUpdater.EventTouchBegan.AddListener( OnTouchBegan );
            TouchInputUpdater.EventTouchMoved.AddListener( OnTouchMoved );
            TouchInputUpdater.EventTouchStationary.AddListener( OnTouchStationary );
            TouchInputUpdater.EventTouchEnd.AddListener( OnTouchEnd );

            if ( EnableGestureSwipe == true ) {
                cachedSwipeComponent = GetComponent<GestureSwipe>();

                AddGestureEvent( cachedSwipeComponent );
                
            }
            if ( EnableGestureDrag == true ) {
                cachedDragComponent = GetComponent<GestureDrag>();
                AddGestureEvent( cachedDragComponent );
            }            

        }
コード例 #4
0
    private void Start()
    {
        const float longTapTime = 1.25f;
        const float flickRange  = 100.0f;

        _tap = new GestureTap(() => {
            Debug.Log("Tap " + _tap.position.ToString());
        }, time: longTapTime);

        _longTap = new GestureLongTap(() => {
            Debug.Log("LongTap " + _longTap.position.ToString());
        }, time: longTapTime);

        _swipe = new GestureSwipe(() => {
            Debug.Log("Swipe " + _swipe.position.ToString());
        }, threshold: flickRange);

        _flick = new GestureFlick(() => {
            Debug.Log("Flick " + _flick.position.ToString());
        }, threshold: flickRange);
    }
コード例 #5
0
    private void TranslateGesture(GestureEventArgs e)
    {
        if (e.Gesture is GestureTap)
        {
            Actor.Rigidbody.velocity = Vector3.zero;
            if (!Actor.State.Equals(ActorState.GRABBING))
            {
                Actor.Animator.Rebind();
                CurrentAttack = atkManager.DetermineAttack(AttackType.HIT, Vector2.zero);
            }
            else
            {
                BreakGrab(false, true);
            }
        }
        else if (e.Gesture is GestureSwipe)
        {
            GestureSwipe gesture = e.Gesture as GestureSwipe;
            switch (gesture.Direction)
            {
            case GestureSwipeDirection.UP:
                if (!Actor.State.Equals(ActorState.GRABBING))
                {
                    Actor.Jump();
                }
                else
                {
                    CurrentAttack = atkManager.DetermineAttack(AttackType.THROW_GRAPPLE, (gesture.EndLocation - gesture.StartLocation).normalized);
                    Vector2 aim = CurrentAttack.Aim;
                    if (aim.x >= 0)
                    {
                        Actor.Rigidbody.rotation = Actor.FACE_LEFT;
                    }
                    else
                    {
                        Actor.Rigidbody.rotation = Actor.FACE_RIGHT;
                    }
                }
                break;

            case GestureSwipeDirection.DOWN:
                if (!Actor.State.Equals(ActorState.GRABBING))
                {
                    CurrentAttack = atkManager.DetermineAttack(AttackType.BLOCK, Vector2.zero);
                }
                else
                {
                    CurrentAttack = atkManager.DetermineAttack(AttackType.STRIKE_GRAPPLE, Vector2.zero);
                }
                break;

            case GestureSwipeDirection.LEFT:
                Actor.Rigidbody.rotation = Actor.FACE_RIGHT;
                if (!Actor.State.Equals(ActorState.GRABBING))
                {
                    Actor.Animator.Rebind();
                    CurrentAttack = atkManager.DetermineAttack(AttackType.GRAB, Vector2.zero);
                }
                else
                {
                    CurrentAttack = atkManager.DetermineAttack(AttackType.THROW_GRAPPLE, (gesture.EndLocation - gesture.StartLocation).normalized);
                }
                break;

            case GestureSwipeDirection.RIGHT:
                Actor.Rigidbody.rotation = Actor.FACE_LEFT;
                if (!Actor.State.Equals(ActorState.GRABBING))
                {
                    Actor.Animator.Rebind();
                    CurrentAttack = atkManager.DetermineAttack(AttackType.GRAB, Vector2.zero);
                }
                else
                {
                    CurrentAttack = atkManager.DetermineAttack(AttackType.THROW_GRAPPLE, (gesture.EndLocation - gesture.StartLocation).normalized);
                }
                break;
            }
        }
    }