Пример #1
0
 int placeChildren(Tech tech, int layer)
 {
     //Debug.Log("Placing " + tech.name);
     if (tech.GetChildren().Count < 1)
     {
         //Debug.Log("This was called");
         if (layer > maxLayer)
         {
             maxLayer = layer;
         }
         placeTech(tech, layer, nexty);
         int lasty = nexty;
         nexty += ySpace;
         return(lasty);
     }
     else
     {
         List <int> y        = new List <int>();
         int        numchild = 0;
         foreach (Tech child in tech.GetChildren())
         {
             int lasty = placeChildren(child, layer + 1);
             y.Add(lasty);
             numchild++;
         }
         int min = Mathf.Min(y.ToArray());
         int max = Mathf.Max(y.ToArray());
         if (max + 30 > maxY)
         {
             maxY = max + 30;
         }
         //Debug.Log("Min/Max of " + tech.name + " " + min.ToString() + "/" + max.ToString());
         int newPos = ((min + (max + 30)) / 2) - 15;
         placeTech(tech, layer, newPos);
         return(newPos);
     }
 }