From ddc02784c24baf22903527871233f9b4db6745ed Mon Sep 17 00:00:00 2001 From: Simon O'Shea Date: Tue, 8 Aug 2023 17:17:45 -0400 Subject: pathfinding class now interprets grid properly can successfully read in the user-generated world! --- Pathfinding Visualizer/Assets/Scripts/Main.cs | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'Pathfinding Visualizer/Assets/Scripts/Main.cs') diff --git a/Pathfinding Visualizer/Assets/Scripts/Main.cs b/Pathfinding Visualizer/Assets/Scripts/Main.cs index 53bbec2..42866f0 100644 --- a/Pathfinding Visualizer/Assets/Scripts/Main.cs +++ b/Pathfinding Visualizer/Assets/Scripts/Main.cs @@ -14,9 +14,9 @@ public class Main : MonoBehaviour // Coordinates for pathfinding - public Vector2 agent = new Vector2(); - public List obstacles = new List(); - public List samples = new List(); + public Vector2Int agent = new Vector2Int(); + public List obstacles = new List(); + public List samples = new List(); // Start is called before the first frame update void Start() @@ -71,8 +71,8 @@ public class Main : MonoBehaviour { StartAlgorithm(); } + ////////////////////////// - // Update Cell: // Place value in cell based on selected placementValue with left click @@ -85,11 +85,6 @@ public class Main : MonoBehaviour { world.SetValue(CodeMonkey.Utils.UtilsClass.GetMouseWorldPosition(), 0); } - - // Make functionality for when "start" button is pressed. - // should call some sort of function that will take in the world - // and perform the selected algorithm - } public void SetModeObstacle() @@ -111,7 +106,7 @@ public class Main : MonoBehaviour public void StartAlgorithm() { - Vector2 coord = new Vector2(); + Vector2Int coord = new Vector2Int(); // Collect information about world for (int x = 0; x < world.GetWidth(); x++) @@ -125,8 +120,6 @@ public class Main : MonoBehaviour // Add coordinate to obstacle array if (value == 1) { - //coord = new int[2][]; - coord.x = x; coord.y = y; @@ -136,18 +129,17 @@ public class Main : MonoBehaviour // Add coordinate to sample array if (value == 2) { - //coord = new int[2][]; - coord.x = x; coord.y = y; - samples.Add(coord); + if (!samples.Contains(coord)) + samples.Add(coord); } // Add coordinate to obstacle array if (value == 3) { - agent[0] = x; - agent[1] = y; + agent.x = x; + agent.y = y; } } -- cgit v1.3.1-4-g156e