summaryrefslogtreecommitdiff
path: root/Pathfinding Visualizer/Assets/Scripts/LogicGrid.cs
diff options
context:
space:
mode:
authorSimon O'Shea <osheas1@wit.edu>2023-08-07 13:59:44 -0400
committerSimon O'Shea <osheas1@wit.edu>2023-08-07 13:59:44 -0400
commit7c3fd8d5630482d96dbbfbed2cd08c0d3530d5ad (patch)
tree470579942ac20179c0112ddb03d05657b217fbab /Pathfinding Visualizer/Assets/Scripts/LogicGrid.cs
parent94b8f55509cfea3706299abb7a909c9cd413ba80 (diff)
cells now change color based on value!!!
colors are a bit weird though, need to figure that out
Diffstat (limited to 'Pathfinding Visualizer/Assets/Scripts/LogicGrid.cs')
-rw-r--r--Pathfinding Visualizer/Assets/Scripts/LogicGrid.cs17
1 files changed, 16 insertions, 1 deletions
diff --git a/Pathfinding Visualizer/Assets/Scripts/LogicGrid.cs b/Pathfinding Visualizer/Assets/Scripts/LogicGrid.cs
index 873822a..2428594 100644
--- a/Pathfinding Visualizer/Assets/Scripts/LogicGrid.cs
+++ b/Pathfinding Visualizer/Assets/Scripts/LogicGrid.cs
@@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
+using System;
// INSPIRED BY "CODE MONKEY" ON YOUTUBE
@@ -14,10 +15,16 @@ public class LogicGrid
// Actual Grid Array
private int[,] gridArray;
-
// Debug Grid Array used for updating the text-objects
private TextMesh[,] debugTextArray;
+ public event EventHandler<OnGridValueChangedEventArgs> OnGridValueChanged;
+ public class OnGridValueChangedEventArgs : EventArgs
+ {
+ public int x;
+ public int y;
+ }
+
public LogicGrid(int width, int height, float cellSize, Vector3 originPosition)
@@ -83,6 +90,14 @@ public class LogicGrid
// Set the value in our debug mesh so that our Text on-screen gets updated
debugTextArray[x, y].text = gridArray[x, y].ToString();
+
+ if (OnGridValueChanged != null)
+ OnGridValueChanged(this, new OnGridValueChangedEventArgs
+ {
+ x = x,
+ y = y
+ });
+ ;
}
}