public void FindPaths() { grid = new PathGrid(Drones, Targets); pathData.Sort((a, b) => a.distance.CompareTo(b.distance)); totalTime = 0.0f; foreach (PathData path in pathData) { StartPath(path, grid); } totalTime += TIMESTEP; grid.ClearOccupancy(); int completeCount = 0; int iterationCount = 0; while (completeCount < pathData.Count) { completeCount = StepPathfinding(); iterationCount += 1; if (iterationCount >= MaxIterations) { break; } } MergeNodes(); Debug.Log("Complete count: " + completeCount + " / " + pathData.Count); EditorApplication.QueuePlayerLoopUpdate(); }
public int StepPathfinding() { int completeCount = pathData.Count(item => item.complete); if (completeCount == pathData.Count) { return(completeCount); } grid.ClearOccupancy(); Step(grid, TIMESTEP, totalTime); //Debug.Log($"Grid occupancy: {grid.TotalOccupancy} / {grid.Capacity}"); totalTime += TIMESTEP; EditorApplication.QueuePlayerLoopUpdate(); return(completeCount); }
public void StartPathfinding() { grid = new PathGrid(Drones, Targets); pathData.Sort((a, b) => a.distance.CompareTo(b.distance)); totalTime = 0.0f; foreach (PathData path in pathData) { StartPath(path, grid); } totalTime += TIMESTEP; grid.ClearOccupancy(); EditorApplication.QueuePlayerLoopUpdate(); }