Exemple #1
0
        // Deselect the specified selectable, if it exists
        public void Deselect(NewLeanSelectable selectable)
        {
            // Loop through all current selectables
            if (CurrentSelectables != null)
            {
                for (var i = CurrentSelectables.Count - 1; i >= 0; i--)
                {
                    var currentSelectable = CurrentSelectables[i];

                    if (currentSelectable != null)
                    {
                        // Match?
                        if (currentSelectable == selectable)
                        {
                            selectable.Deselect();

                            CurrentSelectables.Remove(selectable);

                            return;
                        }
                    }
                    else
                    {
                        CurrentSelectables.RemoveAt(i);
                    }
                }
            }
        }
Exemple #2
0
        public void Select(NewLeanFinger finger, NewLeanSelectable selectable)
        {
            // Something was selected?
            if (selectable != null && selectable.isActiveAndEnabled == true)
            {
                if (CurrentSelectables == null)
                {
                    CurrentSelectables = new List <NewLeanSelectable>();
                }

                // Loop through all current selectables
                for (var i = CurrentSelectables.Count - 1; i >= 0; i--)
                {
                    var currentSelectable = CurrentSelectables[i];

                    if (currentSelectable != null)
                    {
                        // Already selected?
                        if (currentSelectable == selectable)
                        {
                            return;
                        }
                    }
                    else
                    {
                        CurrentSelectables.RemoveAt(i);
                    }
                }

                // Not selected yet, so select it
                CurrentSelectables.Add(selectable);

                selectable.Select(finger);
            }
        }
Exemple #3
0
        // If ignoreGuiFingers is set, Fingers will be filtered to remove any with StartedOverGui
        // If requiredFingerCount is greather than 0, this method will return null if the finger count doesn't match
        // If requiredSelectable is set, and its SelectingFinger isn't null, it will return just that finger
        public static List <NewLeanFinger> GetFingers(bool ignoreGuiFingers, int requiredFingerCount = 0, NewLeanSelectable requiredSelectable = null)
        {
            filteredFingers.Clear();

            if (requiredSelectable != null && requiredSelectable.SelectingFinger != null)
            {
                filteredFingers.Add(requiredSelectable.SelectingFinger);

                return(filteredFingers);
            }

            for (var i = 0; i < Fingers.Count; i++)
            {
                var finger = Fingers[i];

                if (ignoreGuiFingers == true)
                {
                    if (finger.StartedOverGui == false)
                    {
                        filteredFingers.Add(finger);
                    }
                }
                else
                {
                    filteredFingers.Add(finger);
                }
            }

            if (requiredFingerCount > 0)
            {
                if (filteredFingers.Count != requiredFingerCount)
                {
                    return(null);
                }
            }

            return(filteredFingers);
        }