My game has a 2d tilemap that I want to be initially hidden to players, and then expose it as they move. Assuming I've already exposed a circle of tiles around the player, and I want to just expose the edge of the quadrant(s).
I'm assuming it's correct for example to expose Q1 and Q2 when the player moves up, Q2 only when player moves up left, etc.
I think I've got the exposing code worked out, what I'm having a problem with is coming up with an elegant solution in the initialisation.
I want to have already created an array of the quadrants I need to expose when the player moves and passes in a direction xy vector.
I can create individual calls to manually do this for each of the possible 8 directions, something like this:
private void CreateUpDirection()
{
directionDetails[Vector2Int.up.x + 1, Vector2Int.up.y + 1] = new DirectionDetail(quadrantDetails[Constants.QUADRANT_ONE],
quadrantDetails[Constants.QUADRANT_TWO]);
}
but is there a way I can determine the correct quadrant(s) by the xy vector values themselves, so I can do something like this?
CreateDirectionDetail(Vector2Int.up);
CreateDirectionDetail(Vector2Int.up + Vector2Int.left);
CreateDirectionDetail(Vector2Int.up + Vector2Int.right);
CreateDirectionDetail(Vector2Int.left);
CreateDirectionDetail(Vector2Int.right);
CreateDirectionDetail(Vector2Int.down);
CreateDirectionDetail(Vector2Int.down + Vector2Int.left);
CreateDirectionDetail(Vector2Int.down + Vector2Int.right);
I hope I've made that clear enough. Thanks.