Hi there, great series so far, really enjoying it!
I am using a different way of drawing the grid objects (the Shapes asset tool) and so the color is in my case specified directly in the code. I did not want to litter the GridSystemVisual class with all sorts of enums, colors, serializefields etc. so I decided to choose a different approach.
I made a really simple static class called GridColorProvider
public static class GridColorProvider
{
private static readonly Color MOVE_COLOR = Color.white;
private static readonly Color SHOOT_COLOR = Color.red;
private static readonly Color SPIN_COLOR = Color.blue;
private static readonly Color DEFAULT_COLOR = Color.gray;
public static Color GetGridCellColor(BaseAction selectedAction)
{
return selectedAction switch
{
MoveAction moveAction => MOVE_COLOR,
ShootAction shootAction => SHOOT_COLOR,
SpinAction spinAction => SPIN_COLOR,
_ => DEFAULT_COLOR
};
}
}
Then I can simply call
_color = GridColorProvider.GetGridCellColor((sender as UnitActionSystem).SelectedAction);
before updating the grid visuals on selected action changed.
This static GridColorProvider could be easily changed to ScriptableObject too.