Ejemplo n.º 1
0
 public void Pathfind(int x, int y)
 {
     bool[][] testedGrid = new bool[MapGeneration3.sizeX][];
     for(int i = 0; i < MapGeneration3.sizeX; i++)
     {
         testedGrid[i] = new bool[MapGeneration3.sizeY];
     }
     head = (Astar)ScriptableObject.CreateInstance("Astar");
     head.Astarinit(null, (int)transform.position.x, (int)transform.position.y, testedGrid, x, y, MapGeneration3.occupiedGrid);
     //head = new Astar (null, (int)transform.position.x, (int)transform.position.y, testedGrid, x, y, MapGeneration3.occupiedGrid);
     int patience;
     for(patience = 1000; !(head.isFinal ()) && patience > 0; patience--)
     {
         head.extend();
     }
     //print ("Found at patience = " + patience);
     if(patience == 0) m.found = true;
     testedGrid = null;
 }