cells now change color based on value!!!
colors are a bit weird though, need to figure that out
This commit is contained in:
@@ -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
|
||||
});
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user