Ejemplo n.º 1
0
	void Awake()
	{
		// prep our TKTouch cache so we avoid excessive allocations
		_touchCache = new TKTouch[kTotalTouchesToProcess];
		for( int i = 0; i < kTotalTouchesToProcess; i++ )
			_touchCache[i] = new TKTouch( i );
	}
Ejemplo n.º 2
0
 private void Awake()
 {
     // prep our TKTouch cache so we avoid excessive allocations
     _touchCache = new TKTouch[maxTouchesToProcess];
     for (int i = 0; i < maxTouchesToProcess; i++)
     {
         _touchCache[i] = new TKTouch(i);
     }
 }
Ejemplo n.º 3
0
    private void Awake()
    {
#if UNITY_IPHONE
        // check to see if we are on a retina device
        if (iPhone.generation == iPhoneGeneration.iPad3Gen || iPhone.generation == iPhoneGeneration.iPadUnknown || iPhone.generation == iPhoneGeneration.iPhone4 ||
            iPhone.generation == iPhoneGeneration.iPhone4S || iPhone.generation == iPhoneGeneration.iPhone5 || iPhone.generation == iPhoneGeneration.iPodTouch4Gen ||
            iPhone.generation == iPhoneGeneration.iPodTouch5Gen || iPhone.generation == iPhoneGeneration.iPodTouchUnknown)
        {
            isRetina = true;
        }
#elif UNITY_ANDROID
        // TODO: add retina checker for android
#endif

        // prep our TKTouch cache so we avoid excessive allocations
        _touchCache = new TKTouch[maxTouchesToProcess];
        for (int i = 0; i < maxTouchesToProcess; i++)
        {
            _touchCache[i] = new TKTouch(i);
        }
    }
Ejemplo n.º 4
0
    private bool checkForSwipeCompletion(TKTouch touch)
    {
        // if we have a time stipulation and we exceeded it stop listening for swipes
        if (timeToSwipe > 0.0f && (Time.time - _startTime) > timeToSwipe)
        {
            state = TKGestureRecognizerState.FailedOrEnded;
            return(false);
        }

        // Grab the total distance moved in both directions
        var xDeltaAbsCm = Mathf.Abs(_startPoint.x - touch.position.x) / TouchKit.instance.ScreenPixelsPerCm;
        var yDeltaAbsCm = Mathf.Abs(_startPoint.y - touch.position.y) / TouchKit.instance.ScreenPixelsPerCm;

        _endPoint = touch.position;
        swipeTime = Time.time - _startTime;

        // Get the velocity
        swipeVelocity = Mathf.Sqrt(xDeltaAbsCm * xDeltaAbsCm + yDeltaAbsCm * yDeltaAbsCm);

        // Calculate the movement vector
        var displacement = endPoint - startPoint;

        // Calculate the angle with respect to the x axis
        swipeAngle = Mathf.Rad2Deg * Mathf.Atan2(displacement.y, displacement.x);
        // Get it between 0 to 360
        if (swipeAngle < 0)
        {
            swipeAngle += 360;
        }

        swipeVelVector = _endPoint - _startPoint;

        // If we have enough distance, then return true
        if (swipeVelocity > minimumDistance)
        {
            return(true);
        }

        return(false);
    }
Ejemplo n.º 5
0
    private bool checkForSwipeCompletion(TKTouch touch)
    {
        // if we have a time stipulation and we exceeded it stop listening for swipes, fail
        if (timeToSwipe > 0.0f && (Time.time - this._startTime) > timeToSwipe)
        {
            return(false);
        }

        // if we don't have at least two points to test yet, then fail
        if (this._points.Count < 2)
        {
            return(false);
        }

        // the ideal distance in pixels from the start to the finish
        float idealDistance = Vector2.Distance(startPoint, endPoint);

        // the ideal distance in centimeters, based on the screen pixel density
        float idealDistanceCM = idealDistance / TouchKit.instance.ScreenPixelsPerCm;

        // if the distance moved in cm was less than the minimum,
        if (idealDistanceCM < this._minimumDistance)
        {
            return(false);
        }

        // add up distances between all points sampled during the gesture to get the real distance
        float realDistance = 0f;

        for (int i = 1; i < this._points.Count; i++)
        {
            realDistance += Vector2.Distance(this._points[i], this._points[i - 1]);
        }

        // if the real distance is 10% greater than the ideal distance, then fail
        // this weeds out really irregular "lines" and curves from being considered swipes
        if (realDistance > idealDistance * 1.1f)
        {
            return(false);
        }

        // the speed in cm/s of the swipe
        swipeVelocity = idealDistanceCM / (Time.time - this._startTime);

        // turn the slope of the ideal swipe line into an angle in degrees
        Vector2 v2         = (endPoint - startPoint).normalized;
        float   swipeAngle = Mathf.Atan2(v2.y, v2.x) * Mathf.Rad2Deg;

        if (swipeAngle < 0)
        {
            swipeAngle = 360 + swipeAngle;
        }
        swipeAngle = 360 - swipeAngle;

        // depending on the angle of the line, give a logical swipe direction
        if (swipeAngle >= 292.5f && swipeAngle <= 337.5f)
        {
            completedSwipeDirection = TKSwipeDirection.UpRight;
        }
        else if (swipeAngle >= 247.5f && swipeAngle <= 292.5f)
        {
            completedSwipeDirection = TKSwipeDirection.Up;
        }
        else if (swipeAngle >= 202.5f && swipeAngle <= 247.5f)
        {
            completedSwipeDirection = TKSwipeDirection.UpLeft;
        }
        else if (swipeAngle >= 157.5f && swipeAngle <= 202.5f)
        {
            completedSwipeDirection = TKSwipeDirection.Left;
        }
        else if (swipeAngle >= 112.5f && swipeAngle <= 157.5f)
        {
            completedSwipeDirection = TKSwipeDirection.DownLeft;
        }
        else if (swipeAngle >= 67.5f && swipeAngle <= 112.5f)
        {
            completedSwipeDirection = TKSwipeDirection.Down;
        }
        else if (swipeAngle >= 22.5f && swipeAngle <= 67.5f)
        {
            completedSwipeDirection = TKSwipeDirection.DownRight;
        }
        else // swipeAngle >= 337.5f || swipeAngle <= 22.5f
        {
            completedSwipeDirection = TKSwipeDirection.Right;
        }

        return(true);
    }
Ejemplo n.º 6
0
 /// <summary>
 /// checks to see if the touch is currently being tracked by the recognizer
 /// </summary>
 protected bool isTrackingTouch(TKTouch t)
 {
     return(_trackingTouches.Contains(t));
 }
Ejemplo n.º 7
0
 internal bool isTouchWithinBoundaryFrame(TKTouch touch)
 {
     return(!boundaryFrame.HasValue || boundaryFrame.Value.contains(touch.position));
 }
    internal void recognizeTouches(List <TKTouch> touches)
    {
        if (this.shouldAttemptToRecognize)
        {
            this._sentTouchesBegan = this._sentTouchesMoved = this._sentTouchesEnded = false;
            for (int i = touches.Count - 1; i >= 0; i--)
            {
                int     num2;
                int     num3;
                TKTouch touch = touches[i];
                switch (touch.phase)
                {
                case TouchPhase.Began:
                    if (this._sentTouchesBegan || !this.isTouchWithinBoundaryFrame(touches[i]))
                    {
                        continue;
                    }
                    if (!this.touchesBegan(touches) || (this.zIndex <= 0))
                    {
                        goto Label_00E0;
                    }
                    num2 = 0;
                    num3 = touches.Count - 1;
                    goto Label_00CC;

                case TouchPhase.Moved:
                {
                    if (!this._sentTouchesMoved && this.populateSubsetOfTouchesBeingTracked(touches))
                    {
                        this.touchesMoved(this._subsetOfTouchesBeingTrackedApplicableToCurrentRecognizer);
                        this._sentTouchesMoved = true;
                    }
                    continue;
                }

                case TouchPhase.Stationary:
                {
                    continue;
                }

                case TouchPhase.Ended:
                case TouchPhase.Canceled:
                {
                    if (!this._sentTouchesEnded && this.populateSubsetOfTouchesBeingTracked(touches))
                    {
                        this.touchesEnded(this._subsetOfTouchesBeingTrackedApplicableToCurrentRecognizer);
                        this._sentTouchesEnded = true;
                    }
                    continue;
                }

                default:
                {
                    continue;
                }
                }
Label_00AC:
                if (touches[num3].phase == TouchPhase.Began)
                {
                    touches.RemoveAt(num3);
                    num2++;
                }
                num3--;
Label_00CC:
                if (num3 >= 0)
                {
                    goto Label_00AC;
                }
                if (num2 > 0)
                {
                    i -= num2 - 1;
                }
Label_00E0:
                this._sentTouchesBegan = true;
            }
        }
    }
Ejemplo n.º 9
0
    private bool checkForSwipeCompletion(TKTouch touch)
    {
        // if we have a time stipulation and we exceeded it stop listening for swipes
        if (timeToSwipe > 0.0f && (Time.time - _startTime) > timeToSwipe)
        {
            state = TKGestureRecognizerState.FailedOrEnded;
            return(false);
        }


        // when dealing with standalones (non touch-based devices) we need to be careful what we examaine
        // we filter out all touches (mouse movements really) that didnt move
#if UNITY_EDITOR || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_WEBPLAYER || UNITY_WEBGL
        if (touch.deltaPosition.x != 0.0f || touch.deltaPosition.y != 0.0f)
        {
#endif
        // check the delta move positions.  We can rule out at least 2 directions
        if (touch.deltaPosition.x > 0.0f)
        {
            _swipeDetectionState &= ~TKSwipeDirection.Left;
        }
        if (touch.deltaPosition.x < 0.0f)
        {
            _swipeDetectionState &= ~TKSwipeDirection.Right;
        }

        if (touch.deltaPosition.y < 0.0f)
        {
            _swipeDetectionState &= ~TKSwipeDirection.Up;
        }
        if (touch.deltaPosition.y > 0.0f)
        {
            _swipeDetectionState &= ~TKSwipeDirection.Down;
        }

#if UNITY_EDITOR || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_WEBPLAYER || UNITY_WEBGL
    }
#endif

        //Debug.Log( string.Format( "swipeStatus: {0}", swipeDetectionState ) );

        // Grab the total distance moved in both directions
        var xDeltaAbsCm = Mathf.Abs(_startPoint.x - touch.position.x) / TouchKit.instance.ScreenPixelsPerCm;
        var yDeltaAbsCm = Mathf.Abs(_startPoint.y - touch.position.y) / TouchKit.instance.ScreenPixelsPerCm;

        _endPoint = touch.position;

        // only check for swipes in directions that havent been ruled out yet
        // left check
        if ((_swipeDetectionState & TKSwipeDirection.Left) != 0)
        {
            if (xDeltaAbsCm > _minimumDistance)
            {
                if (yDeltaAbsCm < _allowedVariance)
                {
                    completedSwipeDirection = TKSwipeDirection.Left;
                    swipeVelocity           = xDeltaAbsCm / (Time.time - _startTime);
                    return(true);
                }

                // We exceeded our variance so this swipe is no longer allowed
                _swipeDetectionState &= ~TKSwipeDirection.Left;
            }
        }

        // right check
        if ((_swipeDetectionState & TKSwipeDirection.Right) != 0)
        {
            if (xDeltaAbsCm > _minimumDistance)
            {
                if (yDeltaAbsCm < _allowedVariance)
                {
                    completedSwipeDirection = TKSwipeDirection.Right;
                    swipeVelocity           = xDeltaAbsCm / (Time.time - _startTime);
                    return(true);
                }

                // We exceeded our variance so this swipe is no longer allowed
                _swipeDetectionState &= ~TKSwipeDirection.Right;
            }
        }

        // up check
        if ((_swipeDetectionState & TKSwipeDirection.Up) != 0)
        {
            if (yDeltaAbsCm > _minimumDistance)
            {
                if (xDeltaAbsCm < _allowedVariance)
                {
                    completedSwipeDirection = TKSwipeDirection.Up;
                    swipeVelocity           = yDeltaAbsCm / (Time.time - _startTime);
                    return(true);
                }

                // We exceeded our variance so this swipe is no longer allowed
                _swipeDetectionState &= ~TKSwipeDirection.Up;
            }
        }

        // cown check
        if ((_swipeDetectionState & TKSwipeDirection.Down) != 0)
        {
            if (yDeltaAbsCm > _minimumDistance)
            {
                if (xDeltaAbsCm < _allowedVariance)
                {
                    completedSwipeDirection = TKSwipeDirection.Down;
                    swipeVelocity           = yDeltaAbsCm / (Time.time - _startTime);
                    return(true);
                }

                // We exceeded our variance so this swipe is no longer allowed
                _swipeDetectionState &= ~TKSwipeDirection.Down;
            }
        }

        return(false);
    }
Ejemplo n.º 10
0
	private bool checkForSwipeCompletion( TKTouch touch )
	{
		// if we have a time stipulation and we exceeded it stop listening for swipes
		if( timeToSwipe > 0.0f && ( Time.time - _startTime ) > timeToSwipe )
		{
			state = TKGestureRecognizerState.FailedOrEnded;
			return false;
		}


        // when dealing with standalones (non touch-based devices) we need to be careful what we examaine
        // we filter out all touches (mouse movements really) that didnt move
#if UNITY_EDITOR || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_WEBPLAYER || UNITY_WEBGL
        if ( touch.deltaPosition.x != 0.0f || touch.deltaPosition.y != 0.0f )
		{
#endif
			// check the delta move positions.  We can rule out at least 2 directions
			if( touch.deltaPosition.x > 0.0f )
				_swipeDetectionState &= ~TKSwipeDirection.Left;
			if( touch.deltaPosition.x < 0.0f )
				_swipeDetectionState &= ~TKSwipeDirection.Right;
			
			if( touch.deltaPosition.y < 0.0f )
				_swipeDetectionState &= ~TKSwipeDirection.Up;			
			if( touch.deltaPosition.y > 0.0f )
				_swipeDetectionState &= ~TKSwipeDirection.Down;

#if UNITY_EDITOR || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_WEBPLAYER || UNITY_WEBGL
        }
#endif

        //Debug.Log( string.Format( "swipeStatus: {0}", swipeDetectionState ) );

		// Grab the total distance moved in both directions
		var xDeltaAbsCm = Mathf.Abs(_startPoint.x - touch.position.x) / TouchKit.instance.ScreenPixelsPerCm;
		var yDeltaAbsCm = Mathf.Abs(_startPoint.y - touch.position.y) / TouchKit.instance.ScreenPixelsPerCm;

		_endPoint = touch.position;

		// only check for swipes in directions that havent been ruled out yet
		// left check
		if( ( _swipeDetectionState & TKSwipeDirection.Left ) != 0 )
		{
			if (xDeltaAbsCm > _minimumDistance)
			{
				if (yDeltaAbsCm < _allowedVariance)
				{
					completedSwipeDirection = TKSwipeDirection.Left;
					swipeVelocity = xDeltaAbsCm / (Time.time - _startTime);
					return true;
				}
				
				// We exceeded our variance so this swipe is no longer allowed
				_swipeDetectionState &= ~TKSwipeDirection.Left;
			}
		}

		// right check
		if( ( _swipeDetectionState & TKSwipeDirection.Right ) != 0 )
		{
			if (xDeltaAbsCm > _minimumDistance)
			{
				if (yDeltaAbsCm < _allowedVariance)
				{
					completedSwipeDirection = TKSwipeDirection.Right;
					swipeVelocity = xDeltaAbsCm / (Time.time - _startTime);
					return true;
				}
				
				// We exceeded our variance so this swipe is no longer allowed
				_swipeDetectionState &= ~TKSwipeDirection.Right;
			}
		}
		
		// up check
		if( ( _swipeDetectionState & TKSwipeDirection.Up ) != 0 )
		{
			if (yDeltaAbsCm > _minimumDistance)
			{
				if (xDeltaAbsCm < _allowedVariance)
				{
					completedSwipeDirection = TKSwipeDirection.Up;
					swipeVelocity = yDeltaAbsCm / (Time.time - _startTime);
					return true;
				}
				
				// We exceeded our variance so this swipe is no longer allowed
				_swipeDetectionState &= ~TKSwipeDirection.Up;
			}
		}
		
		// cown check
		if( ( _swipeDetectionState & TKSwipeDirection.Down ) != 0 )
		{
			if (yDeltaAbsCm > _minimumDistance)
			{
				if (xDeltaAbsCm < _allowedVariance)
				{
					completedSwipeDirection = TKSwipeDirection.Down;
					swipeVelocity = yDeltaAbsCm / (Time.time - _startTime);
					return true;
				}
				
				// We exceeded our variance so this swipe is no longer allowed
				_swipeDetectionState &= ~TKSwipeDirection.Down;
			}
		}
		
		return false;
	}
Ejemplo n.º 11
0
    private void Awake()
    {
        #if UNITY_IPHONE
        // check to see if we are on a retina device
        if( iPhone.generation == iPhoneGeneration.iPad3Gen || iPhone.generation == iPhoneGeneration.iPadUnknown || iPhone.generation == iPhoneGeneration.iPhone4
            || iPhone.generation == iPhoneGeneration.iPhone4S || iPhone.generation == iPhoneGeneration.iPhone5 || iPhone.generation == iPhoneGeneration.iPodTouch4Gen
            || iPhone.generation == iPhoneGeneration.iPodTouch5Gen || iPhone.generation == iPhoneGeneration.iPodTouchUnknown )
            isRetina = true;

        #elif UNITY_ANDROID

        // TODO: add retina checker for android

        #endif

        // prep our TKTouch cache so we avoid excessive allocations
        _touchCache = new TKTouch[maxTouchesToProcess];
        for( int i = 0; i < maxTouchesToProcess; i++ )
            _touchCache[i] = new TKTouch( i );
    }
    private bool checkForSwipeCompletion(TKTouch touch)
    {
        // if we have a time stipulation and we exceeded it stop listening for swipes
        if (timeToSwipe > 0.0f && (Time.time - _startTime) > timeToSwipe)
        {
            state = TKGestureRecognizerState.FailedOrEnded;
            return false;
        }

        // Grab the total distance moved in both directions
        var xDeltaAbsCm = Mathf.Abs (_startPoint.x - touch.position.x) / TouchKit.instance.ScreenPixelsPerCm;
        var yDeltaAbsCm = Mathf.Abs (_startPoint.y - touch.position.y) / TouchKit.instance.ScreenPixelsPerCm;

        _endPoint = touch.position;

        // Get the velocity
        swipeVelocity = Mathf.Sqrt (xDeltaAbsCm * xDeltaAbsCm + yDeltaAbsCm * yDeltaAbsCm);

        // Calculate the movement vector
        var displacement = endPoint - startPoint;
        // Calculate the angle with respect to the x axis
        swipeAngle = Mathf.Rad2Deg * Mathf.Atan2 (displacement.y, displacement.x);
        // Get it between 0 to 360
        if (swipeAngle < 0)
        {
            swipeAngle += 360;
        }

        swipeVelVector = _endPoint - _startPoint;

        // If we have enough distance, then return true
        if (swipeVelocity > minimumDistance)
        {
            return true;
        }

        return false;
    }
    private bool checkForSwipeCompletion(TKTouch touch)
    {
        // if we have a time stipulation and we exceeded it stop listening for swipes, fail
        if (timeToSwipe > 0.0f && (Time.time - this._startTime) > timeToSwipe)
            return false;

        // if we don't have at least two points to test yet, then fail
        if (this._points.Count < 2)
            return false;

        // the ideal distance in pixels from the start to the finish
        float idealDistance = Vector2.Distance(startPoint, endPoint);

        // the ideal distance in centimeters, based on the screen pixel density
        float idealDistanceCM = idealDistance / TouchKit.instance.ScreenPixelsPerCm;

        // if the distance moved in cm was less than the minimum,
        if (idealDistanceCM < this._minimumDistance)
            return false;

        // add up distances between all points sampled during the gesture to get the real distance
        float realDistance = 0f;
        for (int i = 1; i < this._points.Count; i++)
            realDistance += Vector2.Distance(this._points[i], this._points[i - 1]);

        // if the real distance is 10% greater than the ideal distance, then fail
        // this weeds out really irregular "lines" and curves from being considered swipes
        if (realDistance > idealDistance * 1.1f)
            return false;

        // the speed in cm/s of the swipe
        swipeVelocity = idealDistanceCM / (Time.time - this._startTime);

        // turn the slope of the ideal swipe line into an angle in degrees
        Vector2 v2 = (endPoint - startPoint).normalized;
        float swipeAngle = Mathf.Atan2(v2.y, v2.x) * Mathf.Rad2Deg;
        if (swipeAngle < 0)
            swipeAngle = 360 + swipeAngle;
        swipeAngle = 360 - swipeAngle;

        // depending on the angle of the line, give a logical swipe direction
        if (swipeAngle >= 292.5f && swipeAngle <= 337.5f)
            completedSwipeDirection = TKSwipeDirection.UpRight;
        else if (swipeAngle >= 247.5f && swipeAngle <= 292.5f)
            completedSwipeDirection = TKSwipeDirection.Up;
        else if (swipeAngle >= 202.5f && swipeAngle <= 247.5f)
            completedSwipeDirection = TKSwipeDirection.UpLeft;
        else if (swipeAngle >= 157.5f && swipeAngle <= 202.5f)
            completedSwipeDirection = TKSwipeDirection.Left;
        else if (swipeAngle >= 112.5f && swipeAngle <= 157.5f)
            completedSwipeDirection = TKSwipeDirection.DownLeft;
        else if (swipeAngle >= 67.5f && swipeAngle <= 112.5f)
            completedSwipeDirection = TKSwipeDirection.Down;
        else if (swipeAngle >= 22.5f && swipeAngle <= 67.5f)
            completedSwipeDirection = TKSwipeDirection.DownRight;
        else // swipeAngle >= 337.5f || swipeAngle <= 22.5f
            completedSwipeDirection = TKSwipeDirection.Right;

        return true;
    }
Ejemplo n.º 14
0
    private bool checkForSwipeCompletion(TKTouch touch)
    {
        // if we have a time stipulation and we exceeded it stop listening for swipes, fail
        //if( timeToSwipe > 0.0f && ( Time.time - this._startTime ) > timeToSwipe )
        //	return false;

        // if we don't have at least two points to test yet, then fail
        if (this._points.Count < 2)
        {
            return(false);
        }

        // the ideal distance in pixels from the start to the finish
        float idealDistance = Vector2.Distance(startPoint, endPoint);

        // the ideal distance in centimeters, based on the screen pixel density
        float idealDistanceCM = idealDistance / TouchKit.instance.ScreenPixelsPerCm;

        // if the distance moved in cm was less than the minimum,
        //if( idealDistanceCM < this._minimumDistance || idealDistanceCM > this._maximumDistance )
        //	return false;

        // add up distances between all points sampled during the gesture to get the real distance
        float realDistance = 0f;

        for (int i = 1; i < this._points.Count; i++)
        {
            realDistance += Vector2.Distance(this._points[i], this._points[i - 1]);
        }

        // if the real distance is 10% greater than the ideal distance, then fail
        // this weeds out really irregular "lines" and curves from being considered swipes
        //if( realDistance > idealDistance * 1.1f )
        //	return false;

        // the speed in cm/s of the swipe
        swipeVelocity = idealDistanceCM / (Time.time - this._startTime);

        // turn the slope of the ideal swipe line into an angle in degrees
        Vector2 v2         = (endPoint - startPoint).normalized;
        float   swipeAngle = Mathf.Atan2(v2.y, v2.x) * Mathf.Rad2Deg;

        if (swipeAngle < 0)
        {
            swipeAngle = 360 + swipeAngle;
        }
        swipeAngle = 360 - swipeAngle;

        // depending on the angle of the line, give a logical swipe direction
        if (swipeAngle >= 292.5f && swipeAngle <= 337.5f)
        {
            completedSwipeDirection = TKSwipeDirection.UpRight;
        }
        else if (swipeAngle >= 247.5f && swipeAngle <= 292.5f)
        {
            completedSwipeDirection = TKSwipeDirection.Up;
        }
        else if (swipeAngle >= 202.5f && swipeAngle <= 247.5f)
        {
            completedSwipeDirection = TKSwipeDirection.UpLeft;
        }
        else if (swipeAngle >= 157.5f && swipeAngle <= 202.5f)
        {
            completedSwipeDirection = TKSwipeDirection.Left;
        }
        else if (swipeAngle >= 112.5f && swipeAngle <= 157.5f)
        {
            completedSwipeDirection = TKSwipeDirection.DownLeft;
        }
        else if (swipeAngle >= 67.5f && swipeAngle <= 112.5f)
        {
            completedSwipeDirection = TKSwipeDirection.Down;
        }
        else if (swipeAngle >= 22.5f && swipeAngle <= 67.5f)
        {
            completedSwipeDirection = TKSwipeDirection.DownRight;
        }
        else         // swipeAngle >= 337.5f || swipeAngle <= 22.5f
        {
            completedSwipeDirection = TKSwipeDirection.Right;
        }

        v2 = (endPoint - this._points[this._points.Count - 2]).normalized;
        float swipeAngle2 = Mathf.Atan2(v2.y, v2.x) * Mathf.Rad2Deg;

        if (swipeAngle2 < 0)
        {
            swipeAngle2 = -swipeAngle2;
        }
        else
        {
            swipeAngle2 = 360 - swipeAngle2;
        }

        TKSwipeDirection swipeDirection;

        // depending on the angle of the line, give a logical swipe direction
        if (swipeAngle2 >= 292.5f && swipeAngle2 <= 337.5f)
        {
            swipeDirection = TKSwipeDirection.UpRight;
        }
        else if (swipeAngle2 >= 247.5f && swipeAngle2 <= 292.5f)
        {
            swipeDirection = TKSwipeDirection.Up;
        }
        else if (swipeAngle2 >= 202.5f && swipeAngle2 <= 247.5f)
        {
            swipeDirection = TKSwipeDirection.UpLeft;
        }
        else if (swipeAngle2 >= 157.5f && swipeAngle2 <= 202.5f)
        {
            swipeDirection = TKSwipeDirection.Left;
        }
        else if (swipeAngle2 >= 112.5f && swipeAngle2 <= 157.5f)
        {
            swipeDirection = TKSwipeDirection.DownLeft;
        }
        else if (swipeAngle2 >= 67.5f && swipeAngle2 <= 112.5f)
        {
            swipeDirection = TKSwipeDirection.Down;
        }
        else if (swipeAngle2 >= 22.5f && swipeAngle2 <= 67.5f)
        {
            swipeDirection = TKSwipeDirection.DownRight;
        }
        else         // swipeAngle2 >= 337.5f || swipeAngle2 <= 22.5f
        {
            swipeDirection = TKSwipeDirection.Right;
        }

        if (swipeDirection == swipeDirections[currDirIdx].direction ||
            ((swipeDirection & swipeDirections[currDirIdx].direction) != 0) &&
            (((swipeDirection | swipeDirections[currDirIdx].direction) == TKSwipeDirection.UpLeft) ||
             ((swipeDirection | swipeDirections[currDirIdx].direction) == TKSwipeDirection.DownLeft) ||
             ((swipeDirection | swipeDirections[currDirIdx].direction) == TKSwipeDirection.UpRight) ||
             ((swipeDirection | swipeDirections[currDirIdx].direction) == TKSwipeDirection.DownRight))
            )
        {
            if (completedSwipeDirection == swipeDirections[currDirIdx].direction)
            {
                if (!swipeDirections[currDirIdx].isSuccess)
                {
                    Debug.LogFormat("Direction at index {0} is recognized", currDirIdx);
                    swipeDirections[currDirIdx].isSuccess = true;
                }
            }
            else
            {
                int a = 0;
            }
            //if (!swipeDirections[currDirIdx].isSuccess)
            //{
            //    Debug.LogFormat("Direction at index {0} is recognized", currDirIdx);
            //    swipeDirections[currDirIdx].isSuccess = true;
            //}
        }
        else
        {
            Debug.Log("Changing direction");
            currDirIdx++;
            if (currDirIdx >= swipeDirections.Count)
            {
                state = TKGestureRecognizerState.FailedOrEnded;
                return(false);
            }

            startIdx = this._points.Count - 2;
        }

        return(true);
    }