예제 #1
0
    void abc(ref List <ChildLevel> k, Transform c, int level)
    {
        level++;
        for (int i = 0; i < c.childCount; i++)
        {
            abc(ref k, c.GetChild(i), level);
        }
        ChildLevel cl = new ChildLevel();

        cl.child = c;
        cl.level = level;
        k.Add(cl);
    }
예제 #2
0
    //获得最深的孩子
    Transform FindLastChild(Transform shoulder)
    {
        if (shoulder == null)
        {
            return(null);
        }

        Action <Transform, int> act       = null;
        List <ChildLevel>       childList = new List <ChildLevel>();

        act += (t, l) =>
        {
            if (t.childCount == 0)
            {
                ChildLevel cl = new ChildLevel();
                cl.child = t;
                cl.level = l;
                childList.Add(cl);
            }
            l++;
            for (int i = 0; i < t.childCount; i++)
            {
                act(t.GetChild(i), l);
            }
        };
        act(shoulder, 0);

        childList.Sort((left, right) =>
        {
            if (left.level > right.level)
            {
                return(1);
            }
            else if (left.level == right.level)
            {
                return(0);
            }
            else
            {
                return(-1);
            }
        });

        return(childList[childList.Count - 1].child);
    }
예제 #3
0
        protected virtual IEnumerable <Repository> GetAllRepositoriesForChildSites(Site site, ChildLevel level)
        {
            List <Repository> repositoryList = new List <Repository>();

            GetAllRepositories(Kooboo.CMS.Sites.Services.ServiceFactory.SiteManager.ChildSites(site), repositoryList, level);

            return(repositoryList);
        }
예제 #4
0
 private void GetAllRepositories(IEnumerable <Site> sites, List <Repository> repositoryList, ChildLevel level)
 {
     foreach (var site in sites)
     {
         var repository = site.GetRepository();
         if (!repositoryList.Contains(repository))
         {
             repositoryList.Add(repository);
         }
         if (level == ChildLevel.All)
         {
             GetAllRepositories(Kooboo.CMS.Sites.Services.ServiceFactory.SiteManager.ChildSites(site), repositoryList, level);
         }
     }
 }
예제 #5
0
    //获得最深的孩子
    Transform FindLastChild(Transform shoulder)
    {
        if (shoulder == null) return null;

        Action<Transform, int> act = null;
        List<ChildLevel> childList = new List<ChildLevel>();

        act += (t, l) =>
        {

            if (t.childCount == 0)
            {
                ChildLevel cl = new ChildLevel();
                cl.child = t;
                cl.level = l;
                childList.Add(cl);
            }
            l++;
            for (int i = 0; i < t.childCount; i++)
            {
                act(t.GetChild(i), l);
            }
        };
        act(shoulder, 0);

        childList.Sort((left, right) =>
        {
            if (left.level > right.level)
                return 1;
            else if (left.level == right.level)
                return 0;
            else
                return -1;
        });

        return childList[childList.Count - 1].child;
    }
예제 #6
0
    Transform[] FindDistals(Transform hand)
    {
        if (hand == null) return null;

        Action<Transform, int> act = null;
        List<ChildLevel> childList = new List<ChildLevel>();

        act += (t, l) =>
        {

            if (t.childCount == 0)
            {
                ChildLevel cl = new ChildLevel();
                cl.child = t;
                cl.level = l;
                childList.Add(cl);
            }
            l++;
            for (int i = 0; i < t.childCount; i++)
            {
                act(t.GetChild(i), l);
            }
        };
        act(hand, 0);

        childList.Sort((left, right) =>
        {
            if (left.level < right.level)
                return 1;
            else if (left.level == right.level)
                return 0;
            else
                return -1;
        });
        for (int i = 1; i < childList.Count; i++)
        {
            if (childList[i].level < childList[i - 1].level)
            {
                childList.RemoveRange(i, childList.Count - i);
                break;
            }
        }

        childList.Sort((left, right) =>
        {
            if (left.child.position.z < right.child.position.z)
                return 1;
            else if (left.child.position.z == right.child.position.z)
                return 0;
            else
                return -1;
        });

        Transform[] distal = new Transform[childList.Count];
        for (int i = 0; i < childList.Count; i++)
        {
            distal[i] = childList[i].child;
        }
        return distal;
    }
예제 #7
0
 void abc(ref List<ChildLevel> k, Transform c, int level)
 {
     level++;
     for (int i = 0; i < c.childCount; i++)
     {
         abc(ref k, c.GetChild(i), level);
     }
     ChildLevel cl = new ChildLevel();
     cl.child = c;
     cl.level = level;
     k.Add(cl);
 }
예제 #8
0
    Transform[] FindDistals(Transform hand)
    {
        if (hand == null)
        {
            return(null);
        }

        Action <Transform, int> act       = null;
        List <ChildLevel>       childList = new List <ChildLevel>();

        act += (t, l) =>
        {
            if (t.childCount == 0)
            {
                ChildLevel cl = new ChildLevel();
                cl.child = t;
                cl.level = l;
                childList.Add(cl);
            }
            l++;
            for (int i = 0; i < t.childCount; i++)
            {
                act(t.GetChild(i), l);
            }
        };
        act(hand, 0);

        childList.Sort((left, right) =>
        {
            if (left.level < right.level)
            {
                return(1);
            }
            else if (left.level == right.level)
            {
                return(0);
            }
            else
            {
                return(-1);
            }
        });
        for (int i = 1; i < childList.Count; i++)
        {
            if (childList[i].level < childList[i - 1].level)
            {
                childList.RemoveRange(i, childList.Count - i);
                break;
            }
        }

        childList.Sort((left, right) =>
        {
            if (left.child.position.z < right.child.position.z)
            {
                return(1);
            }
            else if (left.child.position.z == right.child.position.z)
            {
                return(0);
            }
            else
            {
                return(-1);
            }
        });

        Transform[] distal = new Transform[childList.Count];
        for (int i = 0; i < childList.Count; i++)
        {
            distal[i] = childList[i].child;
        }
        return(distal);
    }