diff options
| author | Simon O'Shea <osheas1@wit.edu> | 2023-08-09 10:10:21 -0400 |
|---|---|---|
| committer | Simon O'Shea <osheas1@wit.edu> | 2023-08-09 10:10:21 -0400 |
| commit | 36b7778619b3765b04d0cb2453663fc461b467ff (patch) | |
| tree | a5bc49e1131c2c831be88727f1405d6a55c8192c /Pathfinding Visualizer/Assets/UI Elements/UI | |
| parent | 4046a86cd110bb978c5ab3c1bf05fcab0fbd41a9 (diff) | |
animation works in logan GUI - terribly inefficient
Diffstat (limited to 'Pathfinding Visualizer/Assets/UI Elements/UI')
| -rw-r--r-- | Pathfinding Visualizer/Assets/UI Elements/UI/Scripts/nMain.cs | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/Pathfinding Visualizer/Assets/UI Elements/UI/Scripts/nMain.cs b/Pathfinding Visualizer/Assets/UI Elements/UI/Scripts/nMain.cs index 30f3b49..f6bb494 100644 --- a/Pathfinding Visualizer/Assets/UI Elements/UI/Scripts/nMain.cs +++ b/Pathfinding Visualizer/Assets/UI Elements/UI/Scripts/nMain.cs @@ -27,9 +27,9 @@ public class nMain : MonoBehaviour void Start() { // Create world - int width = 32; - int height = 16; - float cellSize = 5f; + int width = 16; + int height = 8; + float cellSize = 10f; Vector3 origin = new Vector3(-77, -34); world = new LogicGrid(width, height, cellSize, origin); @@ -107,11 +107,15 @@ public class nMain : MonoBehaviour public void ResetGrid() { world.reset(); + agent = new Vector2Int(); + obstacles = new List<Vector2Int>(); + samples = new List<Vector2Int>(); } public void StartAlgorithm() { Vector2Int coord = new Vector2Int(); + bool agentFound = false; // Collect information about world for (int x = 0; x < world.GetWidth(); x++) @@ -120,7 +124,7 @@ public class nMain : MonoBehaviour int index = x * world.GetHeight() + y; int value = world.GetValue(x, y); - Debug.Log("x: " + x + " y: " + y + " | value: " + value); + //Debug.Log("x: " + x + " y: " + y + " | value: " + value); // Add coordinate to obstacle array if (value == 1) @@ -140,18 +144,33 @@ public class nMain : MonoBehaviour if (!samples.Contains(coord)) samples.Add(coord); } - // Add coordinate to obstacle array + // Add coordinate to agent array if (value == 3) { agent.x = x; agent.y = y; + agentFound = true; } } + if (!agentFound) + { + Debug.Log("NO AGENT!"); + return; + } + + if (samples.Count == 0) + { + Debug.Log("NO SAMPLES!"); + return; + } if (true) { - Pathfinder astar = new Pathfinder(world, agent, obstacles, samples, algorithm, 0); + Pathfinder path = new Pathfinder(world, agent, obstacles, samples, 0, 0); + Stack<Node> result = path.result; + Debug.Log("GO ANIMATE"); + cellMesh.Animate(result); } } |
