Example #1
0
        TooltipGroup FindClosestEntry()
        {
            List <TooltipGroup> groups = TooltipGroup.ActiveGroups.FindAll(e => e.groupId == groupId);
            int          leastHops     = int.MaxValue;
            TooltipGroup closestGroup  = null;

            for (int i = 0; i < groups.Count; i++)
            {
                bool      foundMatch   = false;
                int       x            = 0;
                Transform myTrackedObj = transform;
                while (myTrackedObj != null && !foundMatch)
                {
                    Transform theirTrackedObj = groups[i].transform;
                    int       y = 0;
                    while (theirTrackedObj != null && !foundMatch)
                    {
                        if (myTrackedObj == theirTrackedObj)
                        {
                            if (leastHops > x + y)
                            {
                                leastHops    = x + y;
                                closestGroup = groups[i];
                            }
                            foundMatch = true;
                        }
                        theirTrackedObj = theirTrackedObj.parent;
                        y++;
                    }
                    myTrackedObj = myTrackedObj.parent;
                    x++;
                }
            }
            return(closestGroup);
        }
Example #2
0
 void AttachToGroup()
 {
     AttachedTo = FindClosestEntry();
     if (AttachedTo != null)
     {
         AttachedTo.CurrentEntry = this;
     }
 }
Example #3
0
 void RemoveFromGroup()
 {
     if (AttachedTo != null)
     {
         if (AttachedTo.CurrentEntry == this)
         {
             AttachedTo.CurrentEntry = null;
         }
         AttachedTo = null;
     }
 }