Ejemplo n.º 1
0
        private void HandleFingerUp(LeanFinger finger)
        {
            // Find link for this finger, and clear it
            var fingerData = LeanFingerData.Find(fingerDatas, finger);

            if (fingerData != null)
            {
                fingerDatas.Remove(fingerData);

                if (fingerData.LastSet == true)
                {
                    if (onFingerUp != null)
                    {
                        onFingerUp.Invoke(finger);
                    }

                    if (onWorldUp != null)
                    {
                        var position = ScreenDepth.Convert(finger.ScreenPosition, gameObject);

                        onWorldUp.Invoke(position);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void HandleFingerUp(LeanFinger finger)
        {
            var fingerData = LeanFingerData.Find(fingerDatas, finger);

            if (fingerData != null && Shape != null && Shape.Points != null)
            {
                //Debug.Log("count " + fingerData.Points.Count);
                var minimum = Shape.ConnectEnds == true ? Shape.Points.Count + 1 : Shape.Points.Count;

                if (MinimumPoints > 0 && MinimumPoints < minimum)
                {
                    minimum = MinimumPoints;
                }

                if (fingerData.Points.Count >= minimum)
                {
                    if (OnDetected != null)
                    {
                        OnDetected.Invoke(fingerData);
                    }
                }
            }

            LeanFingerData.Remove(fingerDatas, finger, fingerDataPool);
        }
        protected virtual void HandleFingerUp(LeanFinger finger)
        {
            var link = LeanFingerData.Find(fingerDatas, finger);

            if (link != null)
            {
                link.Finger = null; // The line will gradually fade out in Update
            }
        }
Ejemplo n.º 4
0
        private void HandleFingerUpdate(LeanFinger finger)
        {
            var fingerData = LeanFingerData.Find(fingerDatas, finger);

            if (fingerData != null && Vector2.Distance(finger.ScreenPosition, fingerData.EndPoint) > StepThreshold)
            {
                fingerData.Points.Add(finger.ScreenPosition);
            }
        }
Ejemplo n.º 5
0
        private void FingerUp(LeanFinger finger)
        {
            // Get link and reset cooldown
            var link = LeanFingerData.Find(ref fingerDatas, finger);

            if (link != null)
            {
                link.Cooldown = false;
            }
        }
        private void HandleFingerSet(LeanFinger finger)
        {
            // Try and find the link for this finger
            var fingerData = LeanFingerData.Find(fingerDatas, finger);

            // Link exists?
            if (fingerData != null && fingerData.Box != null)
            {
                WriteTransform(fingerData.Box, fingerData.Finger);
            }
        }
Ejemplo n.º 7
0
        private void FingerSet(LeanFinger finger)
        {
            // Try and find the link for this finger
            var leanFingerData = LeanFingerData.Find(ref fingerDatas, finger);

            // Link exists?
            if (leanFingerData != null && leanFingerData.Line != null)
            {
                WritePositions(leanFingerData.Line, leanFingerData.Finger);
            }
        }
Ejemplo n.º 8
0
        private void HandleFingerUpdate(LeanFinger finger)
        {
            var fingerData = LeanFingerData.Find(fingerDatas, finger);

            if (fingerData != null)
            {
                if (Select != null)
                {
                    Select.SelectScreenPosition(finger);
                }
            }
        }
Ejemplo n.º 9
0
        private void HandleFingerUp(LeanFinger finger)
        {
            var fingerData = LeanFingerData.Find(fingerDatas, finger);
            var points     = fingerData.Points;

            LeanFingerData.Remove(fingerDatas, finger, fingerDataPool);

            if (Shape != null)
            {
                ranges.Clear();

                var min = Shape.Points.Count;
                var max = Shape.Points.Count;

                if (MinimumPoints > 0)
                {
                    min = MinimumPoints;
                }

                for (var i = max; i >= min; i--)
                {
                    if (Shape.ConnectEnds == true)
                    {
                        for (var j = 0; j < Shape.Points.Count; j++)
                        {
                            AddRange(j, j + i - 1);
                        }
                    }
                    else
                    {
                        var steps = Shape.Points.Count - i;

                        for (var j = 0; j <= steps; j++)
                        {
                            AddRange(j, j + i - 2);
                        }
                    }
                }

                foreach (var range in ranges)
                {
                    if (CalculateMatch(points, Shape.Points, DistanceThreshold, ErrorThreshold, range.x, range.y) == true)
                    {
                        if (onDetected != null)
                        {
                            onDetected.Invoke(finger);
                        }

                        return;
                    }
                }
            }
        }
Ejemplo n.º 10
0
        private void FingerUp(LeanFinger finger)
        {
            // If link with this finger exists, null finger and assign life, so it can be destroyed later
            var fingerData = LeanFingerData.Find(ref fingerDatas, finger);

            if (fingerData != null)
            {
                // Call up method
                LinkFingerUp(fingerData);

                fingerData.Finger = null;
                fingerData.Life   = FadeTime;
            }
        }
Ejemplo n.º 11
0
        private void FingerUp(LeanFinger finger)
        {
            // Find link for this finger, and clear it
            var fingerData = LeanFingerData.Find(ref fingerDatas, finger);

            if (fingerData != null)
            {
                fingerDatas.Remove(fingerData);

                LinkFingerUp(fingerData);

                if (fingerData.Line != null)
                {
                    Destroy(fingerData.Line.gameObject);
                }
            }
        }
        private void HandleFingerUp(LeanFinger finger)
        {
            // Try and find the link for this finger
            var fingerData = LeanFingerData.Find(fingerDatas, finger);

            // Link exists?
            if (fingerData != null)
            {
                // Remove link from list
                fingerDatas.Remove(fingerData);

                // Destroy box GameObject
                if (fingerData.Box != null)
                {
                    Destroy(fingerData.Box.gameObject);
                }
            }
        }
Ejemplo n.º 13
0
        private void HandleFingerUp(LeanFinger finger)
        {
            // Find link for this finger, and clear it
            var fingerData = LeanFingerData.Find(fingerDatas, finger);

            if (fingerData != null)
            {
                fingerDatas.Remove(fingerData);

                if (fingerData.LastSet == true)
                {
                    if (onFingerUp != null)
                    {
                        onFingerUp.Invoke(finger);
                    }
                }
            }
        }
Ejemplo n.º 14
0
        private void FingerUp(LeanFinger finger)
        {
            // Try and find the link for this finger
            var link = LeanFingerData.Find(ref fingerDatas, finger);

            // Link exists?
            if (link != null)
            {
                // Remove link from list
                fingerDatas.Remove(link);

                // Destroy line GameObject
                if (link.Line != null)
                {
                    Destroy(link.Line.gameObject);
                }

                Shoot(finger);
            }
        }
Ejemplo n.º 15
0
        private void SelectGlobal(LeanSelectable selectable, LeanFinger finger)
        {
            if (waitingForSelection == true)
            {
                LeanFingerData.FindOrCreate(ref fingerDatas, finger);
            }

            var fingerData = LeanFingerData.Find(fingerDatas, finger);

            if (fingerData != null)
            {
                // Good selection?
                if (MaximumSeparation <= 0.0f || fingerData.LastSelectable == null || Vector3.Distance(fingerData.LastSelectable.transform.position, selectable.transform.position) <= MaximumSeparation)
                {
                    fingerData.LastSelectable = selectable;
                }
                // Too far to select?
                else
                {
                    selectable.Deselect();
                }
            }
        }
Ejemplo n.º 16
0
        protected override void HandleFingerUp(LeanFinger finger)
        {
            var fingerData = LeanFingerData.Find(fingerDatas, finger);

            if (fingerData != null)
            {
                var line = fingerData.Line;

                if (line != null && line.positionCount == 2)
                {
                    var worldFrom = line.GetPosition(0);
                    var worldTo   = line.GetPosition(1);

                    if (onReleasedFrom != null)
                    {
                        onReleasedFrom.Invoke(worldFrom);
                    }

                    if (onReleasedTo != null)
                    {
                        onReleasedTo.Invoke(worldTo);
                    }

                    if (onReleasedDelta != null)
                    {
                        onReleasedDelta.Invoke(worldTo - worldFrom);
                    }

                    if (onReleasedFromTo != null)
                    {
                        onReleasedFromTo.Invoke(worldFrom, worldTo);
                    }
                }

                fingerData.Finger = null; // The line will gradually fade out in Update
            }
        }
Ejemplo n.º 17
0
        private void HandleFingerUpdate(LeanFinger finger)
        {
            // Try and find the link for this finger
            var fingerData = LeanFingerData.Find(fingerDatas, finger);

            if (fingerData != null)
            {
                fingerData.Movement += finger.ScaledDelta;

                if (fingerData.Movement.magnitude > MaximumMovement)
                {
                    fingerData.Eligible = false;
                }

                if (IsHeld(finger, fingerData) == true)
                {
                    if (fingerData.Held == false)
                    {
                        fingerData.Held = true;

                        InvokeDown(finger);
                    }

                    InvokeUpdate(finger);
                }
                else if (fingerData.Held == true)
                {
                    InvokeUp(finger);

                    fingerDatas.Remove(fingerData);
                }
                else if (finger.Set == false)
                {
                    fingerDatas.Remove(fingerData);
                }
            }
        }
Ejemplo n.º 18
0
        private void HandleFingerSet(LeanFinger finger)
        {
            // Try and find the link for this finger
            var fingerData = LeanFingerData.Find(fingerDatas, finger);

            if (fingerData != null)
            {
                // Has this finger been held for more than MinimumAge without moving more than MaximumMovement?
                var set = finger.Age >= MinimumAge && fingerData.TotalScaledDelta.magnitude < MaximumMovement;

                fingerData.TotalScaledDelta += finger.ScaledDelta;

                if (set == true && fingerData.LastSet == false)
                {
                    if (onFingerDown != null)
                    {
                        onFingerDown.Invoke(finger);
                    }

                    if (onPositionDown != null)
                    {
                        var position = ScreenDepth.Convert(finger.ScreenPosition, gameObject);

                        onPositionDown.Invoke(position);
                    }
                }

                if (set == true)
                {
                    if (onFingerSet != null)
                    {
                        onFingerSet.Invoke(finger);
                    }

                    if (onPositionSet != null)
                    {
                        var position = ScreenDepth.Convert(finger.ScreenPosition, gameObject);

                        onPositionSet.Invoke(position);
                    }
                }

                if (set == false && fingerData.LastSet == true)
                {
                    if (onFingerUp != null)
                    {
                        onFingerUp.Invoke(finger);
                    }

                    if (onPositionUp != null)
                    {
                        var position = ScreenDepth.Convert(finger.ScreenPosition, gameObject);

                        onPositionUp.Invoke(position);
                    }
                }

                // Store last value
                fingerData.LastSet = set;
            }
        }