public static ArrayList Path(Vector3 _start, Vector3 _end) { closedList = new priorityQ (); map = new Map (); cntLine = (int)Mathf.Sqrt (map.map2.Length); for (int i = 0; i < cntLine; i++) { for (int j = 0; j < cntLine; j++) { if (map.map2 [i, j].pos == _start) { start = map.map2 [i, j]; closedList.Push (start); } if (map.map2 [i, j].pos == _end) { end = map.map2 [i, j]; } } } //pushq 루프 while (!closedList.Contain (end)) { PushQ (closedList.Start ()); } if (closedList.Contain (end)) { hNode = end; while (hNode != start) { path.Add (hNode); hNode = end.parent; } path.Add (start); } return path; }
public static ArrayList Path(Vector3 _start, Vector3 _end) { closedList = new priorityQ(); map = new Map(); cntLine = (int)Mathf.Sqrt(map.map2.Length); for (int i = 0; i < cntLine; i++) { for (int j = 0; j < cntLine; j++) { if (map.map2 [i, j].pos == _start) { start = map.map2 [i, j]; closedList.Push(start); } if (map.map2 [i, j].pos == _end) { end = map.map2 [i, j]; } } } //pushq 루프 while (!closedList.Contain(end)) { PushQ(closedList.Start()); } if (closedList.Contain(end)) { hNode = end; while (hNode != start) { path.Add(hNode); hNode = end.parent; } path.Add(start); } return(path); }