imported and translated java code

starting to implement algorithms
This commit is contained in:
Simon O'Shea
2023-08-08 15:27:37 -04:00
parent f825ec9c27
commit 3ac2b11494
4 changed files with 257 additions and 180 deletions
@@ -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
{