From 3ac2b11494bd372d77465c97dc925ab28d87d8dc Mon Sep 17 00:00:00 2001 From: Simon O'Shea Date: Tue, 8 Aug 2023 15:27:37 -0400 Subject: imported and translated java code starting to implement algorithms --- Pathfinding Visualizer/Assets/Scripts/Main.cs | 28 ++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 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 018ce33..a146859 100644 --- a/Pathfinding Visualizer/Assets/Scripts/Main.cs +++ b/Pathfinding Visualizer/Assets/Scripts/Main.cs @@ -16,7 +16,12 @@ public class Main : MonoBehaviour void Start() { // Create world - world = new LogicGrid(100, 100, 5f, new Vector3(-110, -110)); + int width = 100; + int height = 100; + float cellSize = 5f; + Vector3 origin = new Vector3(-110, -110); + + world = new LogicGrid(width, height, cellSize, origin); // Set default placement to Obstacle placementValue = 1; @@ -28,11 +33,16 @@ public class Main : MonoBehaviour } - // Update is called once per frame - void Update() + public void StartAStar() { - // Change Placement Modes: + AStar astar = new AStar(world, 0); + } + // Update contains keyboard shortcut options + void Update() + { + // Change Placement Mode Keyboard Shortcuts: + //////////////////////////////// // Place Obstacle in grid if (Input.GetKeyDown("o")) { @@ -59,15 +69,16 @@ public class Main : MonoBehaviour { ResetGrid(); } - + ////////////////////////// + // Update Cell: - // Change cell to obstacle + // Place value in cell based on selected placementValue with left click if (Input.GetMouseButton(0)) { world.SetValue(CodeMonkey.Utils.UtilsClass.GetMouseWorldPosition(), placementValue); } - // Clear cell + // Clear cell with right click if (Input.GetMouseButton(1)) { world.SetValue(CodeMonkey.Utils.UtilsClass.GetMouseWorldPosition(), 0); @@ -79,7 +90,6 @@ public class Main : MonoBehaviour } - public void SetModeObstacle() { placementValue = 1; @@ -96,5 +106,5 @@ public class Main : MonoBehaviour { world.reset(); } - + } -- cgit v1.3.1-4-g156e