public void CreateTree(RainGridController grid, RainGridNode parent, int numRows, int numCols)
 {
     this.grid = grid;
     this.parent = parent;
     numChildren = numRows;
     RainGridNode temp = null;
     children = new RainGridNode[numChildren];
     float tempZFloat = grid.startZ;
     float tempXFloat = grid.startX;
     Vector3 tempLocation;
     for (int i = 0; i < numChildren; i++){
         temp = (RainGridNode)ScriptableObject.CreateInstance ("RainGridNode");
         if (this.parent == null)
         {
             //tempZFloat += grid.zStep;
             // Assume this is a direct child of the root. Update z steps
             tempLocation = new Vector3(location[0],location[1],tempZFloat + i*grid.xStep);
             temp.Init (tempLocation);
         }
         else if (this.parent.parent == null)
         {
             //tempXFloat += grid.xStep;
             // Assume this is a direct child of the root. Update z steps
             tempLocation = new Vector3(tempXFloat + i*grid.xStep,location[1],location[2]);
             temp.Init (tempLocation);
         }
         else
         {
             Debug.LogError ("Impossible case, this RainGridNode has no parent pointer AND no parent.parent pointer");
         }
         //temp.Init (location);
         temp.CreateTree(grid,this,numCols,0);
         children[i] = temp;
     }
 }
Example #2
0
 // When this comes into existense, set some properties.
 void Awake()
 {
     this.colliding = false;
     // Hook up the RainGrid script pointer
     grid = GameObject.Find ("RainGrid");
     controller = grid.GetComponent<RainGridController> ();
     // Initialize the ID
     ID = 0;
 }