summaryrefslogtreecommitdiff
path: root/Pathfinding Visualizer/Assets/Scripts/LogicGrid.cs
diff options
context:
space:
mode:
authorSimon O'Shea <osheas1@wit.edu>2023-08-08 15:27:37 -0400
committerSimon O'Shea <osheas1@wit.edu>2023-08-08 15:27:37 -0400
commit3ac2b11494bd372d77465c97dc925ab28d87d8dc (patch)
tree2c1d89041c58d4a5c5aee18f5a32f9d9a6903936 /Pathfinding Visualizer/Assets/Scripts/LogicGrid.cs
parentf825ec9c278af326bde56524a08888d067b2a68f (diff)
imported and translated java code
starting to implement algorithms
Diffstat (limited to 'Pathfinding Visualizer/Assets/Scripts/LogicGrid.cs')
-rw-r--r--Pathfinding Visualizer/Assets/Scripts/LogicGrid.cs50
1 files changed, 50 insertions, 0 deletions
diff --git a/Pathfinding Visualizer/Assets/Scripts/LogicGrid.cs b/Pathfinding Visualizer/Assets/Scripts/LogicGrid.cs
index 212eb91..c87514e 100644
--- a/Pathfinding Visualizer/Assets/Scripts/LogicGrid.cs
+++ b/Pathfinding Visualizer/Assets/Scripts/LogicGrid.cs
@@ -18,6 +18,12 @@ public class LogicGrid
// Debug Grid Array used for updating the text-objects
private TextMesh[,] debugTextArray;
+
+ // Coordinates for pathfinding
+ public int[] agent;
+ public List<int[][]> obstacles;
+ public List<int[][]> samples;
+
public event EventHandler<OnGridValueChangedEventArgs> OnGridValueChanged;
public class OnGridValueChangedEventArgs : EventArgs
{
@@ -97,6 +103,46 @@ public class LogicGrid
x = x,
y = y
});
+
+ // If deleting a cell's value, remove coord from set
+ if (value == 0)
+ {
+
+ // make behavior to check for -1 values in coords
+ if (agent[0].Equals(x) && agent[1].Equals(y))
+ {
+ agent[0] = -1;
+ agent[1] = -2;
+ }
+
+ }
+
+ // Add coordinate to obstacle array
+ if (value == 1)
+ {
+ int[][] coord = new int[2][];
+
+ coord[0][0] = x;
+ coord[1][0] = y;
+
+ obstacles.Add(coord);
+ }
+ // Add coordinate to sample array
+ if (value == 2)
+ {
+ int[][] coord = new int[2][];
+
+ coord[0][0] = x;
+ coord[1][0] = y;
+
+ samples.Add(coord);
+ }
+ // Add coordinate to obstacle array
+ if (value == 3)
+ {
+ agent[0] = x;
+ agent[1] = y;
+ }
}
}
@@ -137,6 +183,10 @@ public class LogicGrid
{
gridArray = new int[width, height];
+ agent = new int[2];
+ obstacles = new List<int[][]>();
+ samples = new List<int[][]>();
+
if (OnGridValueChanged != null)
OnGridValueChanged(this, new OnGridValueChangedEventArgs
{