From 7c3fd8d5630482d96dbbfbed2cd08c0d3530d5ad Mon Sep 17 00:00:00 2001 From: Simon O'Shea Date: Mon, 7 Aug 2023 13:59:44 -0400 Subject: cells now change color based on value!!! colors are a bit weird though, need to figure that out --- Pathfinding Visualizer/Assets/Scripts/LogicGrid.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'Pathfinding Visualizer/Assets/Scripts/LogicGrid.cs') 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 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 + }); + ; } } -- cgit v1.3.1-4-g156e