Adding 9 Player level

This commit is contained in:
Matt F 2026-05-21 23:36:19 -07:00
parent fdada6f132
commit a7be12fa9b
30 changed files with 45984 additions and 300 deletions

View file

@ -12,8 +12,11 @@ namespace TD.Core
///
/// Conventions:
/// - Tiles are 1.0 world unit on each side (TILE_SIZE).
/// - Tiles are CENTER-BASED: tile (0, 0) has its center at world (0, 0, 0)
/// and occupies world XZ from (-0.5, -0.5) to (+0.5, +0.5).
/// - Tiles are EDGE-ALIGNED: tile (N, N) occupies world XZ from (N, N) to (N+1, N+1),
/// with its center at (N+0.5, N+0.5). This makes integer-aligned BoxCollider bounds
/// align naturally with tile boundaries — a volume sized to N whole tiles at an
/// integer position covers exactly N tiles, with the rasterized tile geometry
/// matching the bounds rectangle exactly (no half-tile overhang).
/// - The grid lives on the XZ plane at Y = BUILDABLE_PLANE_Y. Grid-y maps to world-z.
/// - 4-connected (no diagonals).
/// </summary>
@ -32,26 +35,27 @@ namespace TD.Core
/// <summary>
/// Returns the world-space center of the given tile, on the buildable plane.
/// Use this for placing towers, drawing ghost previews, and for A* path waypoints.
/// Tile (N, N) is centered at world (N+0.5, N+0.5) since tiles occupy [N, N+1].
/// </summary>
public static Vector3 GridToWorld(Vector2Int gridPos)
{
return new Vector3(
gridPos.x * TILE_SIZE,
(gridPos.x + 0.5f) * TILE_SIZE,
BUILDABLE_PLANE_Y,
gridPos.y * TILE_SIZE);
(gridPos.y + 0.5f) * TILE_SIZE);
}
/// <summary>
/// Returns the tile that contains the given world position.
/// The Y component of worldPos is ignored. Uses round-to-nearest because
/// tiles are center-based — any world point within ±0.5 of a tile's center
/// belongs to that tile.
/// The Y component of worldPos is ignored. Uses floor because tiles are
/// edge-aligned — tile N occupies the half-open interval [N, N+1) on each axis,
/// so any world point in that range floors to tile N.
/// </summary>
public static Vector2Int WorldToGrid(Vector3 worldPos)
{
return new Vector2Int(
Mathf.RoundToInt(worldPos.x / TILE_SIZE),
Mathf.RoundToInt(worldPos.z / TILE_SIZE));
Mathf.FloorToInt(worldPos.x / TILE_SIZE),
Mathf.FloorToInt(worldPos.z / TILE_SIZE));
}
/// <summary>
@ -61,8 +65,8 @@ namespace TD.Core
public static Vector2Int WorldToGrid(Vector2 worldPosXZ)
{
return new Vector2Int(
Mathf.RoundToInt(worldPosXZ.x / TILE_SIZE),
Mathf.RoundToInt(worldPosXZ.y / TILE_SIZE));
Mathf.FloorToInt(worldPosXZ.x / TILE_SIZE),
Mathf.FloorToInt(worldPosXZ.y / TILE_SIZE));
}
// ----- Grid helpers --------------------------------------------------------
@ -200,9 +204,10 @@ namespace TD.Core
/// <summary>
/// Returns the world-space center of a footprint anchored at the given tile.
/// For a 2x2 footprint at anchor (5, 7) with TILE_SIZE = 1.0, returns (5.5, 0, 7.5).
/// Use this to position the tower's visual GameObject so it sits centered on its
/// footprint rather than on the anchor tile's center.
/// For a 2x2 footprint at anchor (5, 7) with TILE_SIZE = 1.0, returns (6, 0, 8) —
/// the geometric center of the four tiles (5,7),(6,7),(5,8),(6,8), which span
/// world XZ [5, 7]. Use this to position the tower's visual GameObject so it sits
/// centered on its footprint rather than on the anchor tile's center.
/// </summary>
public static Vector3 GetFootprintCenterWorld(Vector2Int anchor, Vector2Int footprintSize)
{