Ejemplo n.º 1
0
 public void CreateTree(RiverGridController grid, RiverGridNode parent, int numRows, int numCols)
 {
     this.grid = grid;
     this.parent = parent;
     numChildren = numRows;
     RiverGridNode temp = null;
     children = new RiverGridNode[numChildren];
     float tempZFloat = grid.startZ;
     float tempYFloat = grid.startY;
     Vector3 tempLocation;
     for (int i = 0; i < numChildren; i++){
         temp = (RiverGridNode)ScriptableObject.CreateInstance ("RiverGridNode");
         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.zStep);
             temp.Init (tempLocation);
         }
         else if (this.parent.parent == null)
         {
             //tempXFloat += grid.xStep;
             // Assume this is a direct child of the root. Update x steps
             tempLocation = new Vector3(location[0],tempYFloat + i*grid.yStep,location[2]);
             temp.Init (tempLocation);
         }
         else
         {
             Debug.LogError ("Impossible case in CreateTree, this RiverGridNode has no parent pointer AND no parent.parent pointer");
         }
         //temp.Init (location);
         temp.CreateTree(grid,this,numCols,0);
         children[i] = temp;
     }
 }
Ejemplo n.º 2
0
 // When this comes into existense, set some properties.
 void Awake()
 {
     this.colliding = false;
     // Hook up the RiverGrid script pointer
     grid = GameObject.Find ("RiverGrid");
     if (grid != null) {
         controller = grid.GetComponent<RiverGridController> ();
     }
     // Initialize the ID
     ID = 0;
 }