Adding 9 Player level
This commit is contained in:
parent
fdada6f132
commit
a7be12fa9b
30 changed files with 45984 additions and 300 deletions
|
|
@ -219,19 +219,19 @@ namespace TD.Gameplay
|
|||
//
|
||||
// The grid covers tiles from GridOriginTile (inclusive, SW corner)
|
||||
// to GridOriginTile + GridSize - (1,1) (inclusive, NE corner).
|
||||
// Each tile is TILE_SIZE wide and centered on its integer coords.
|
||||
// Each tile is TILE_SIZE wide and edge-aligned: tile N occupies world [N, N+1].
|
||||
//
|
||||
// World extent on X:
|
||||
// left = (GridOriginTile.x - 0.5) * TILE_SIZE
|
||||
// right = (GridOriginTile.x + GridSize.x - 0.5) * TILE_SIZE
|
||||
// left = GridOriginTile.x * TILE_SIZE
|
||||
// right = (GridOriginTile.x + GridSize.x) * TILE_SIZE
|
||||
// width = GridSize.x * TILE_SIZE
|
||||
// centerX = (left + right) / 2 = (GridOriginTile.x + (GridSize.x - 1) / 2) * TILE_SIZE
|
||||
// centerX = (left + right) / 2 = (GridOriginTile.x + GridSize.x / 2) * TILE_SIZE
|
||||
//
|
||||
// Same shape on Z (grid-y maps to world-z).
|
||||
float worldCenterX =
|
||||
(level.GridOriginTile.x + (level.GridSize.x - 1) * 0.5f) * GridCoordinates.TILE_SIZE;
|
||||
(level.GridOriginTile.x + level.GridSize.x * 0.5f) * GridCoordinates.TILE_SIZE;
|
||||
float worldCenterZ =
|
||||
(level.GridOriginTile.y + (level.GridSize.y - 1) * 0.5f) * GridCoordinates.TILE_SIZE;
|
||||
(level.GridOriginTile.y + level.GridSize.y * 0.5f) * GridCoordinates.TILE_SIZE;
|
||||
float worldSizeX = level.GridSize.x * GridCoordinates.TILE_SIZE;
|
||||
float worldSizeZ = level.GridSize.y * GridCoordinates.TILE_SIZE;
|
||||
|
||||
|
|
@ -442,16 +442,17 @@ namespace TD.Gameplay
|
|||
|
||||
private void DrawGridBoundsGizmo()
|
||||
{
|
||||
// One outlined wire box covering the entire grid extent.
|
||||
float halfTile = GridCoordinates.TILE_SIZE * 0.5f;
|
||||
// One outlined wire box covering the entire grid extent. Tile N spans world
|
||||
// [N, N+1], so the grid's SW corner is at GridOriginTile and its NE corner
|
||||
// is at GridOriginTile + GridSize.
|
||||
Vector3 sw = new Vector3(
|
||||
level.GridOriginTile.x * GridCoordinates.TILE_SIZE - halfTile,
|
||||
level.GridOriginTile.x * GridCoordinates.TILE_SIZE,
|
||||
GridCoordinates.BUILDABLE_PLANE_Y,
|
||||
level.GridOriginTile.y * GridCoordinates.TILE_SIZE - halfTile);
|
||||
level.GridOriginTile.y * GridCoordinates.TILE_SIZE);
|
||||
Vector3 ne = new Vector3(
|
||||
(level.GridOriginTile.x + level.GridSize.x) * GridCoordinates.TILE_SIZE - halfTile,
|
||||
(level.GridOriginTile.x + level.GridSize.x) * GridCoordinates.TILE_SIZE,
|
||||
GridCoordinates.BUILDABLE_PLANE_Y,
|
||||
(level.GridOriginTile.y + level.GridSize.y) * GridCoordinates.TILE_SIZE - halfTile);
|
||||
(level.GridOriginTile.y + level.GridSize.y) * GridCoordinates.TILE_SIZE);
|
||||
|
||||
Gizmos.color = new Color(1f, 1f, 1f, 0.9f); // bright white outline
|
||||
Vector3 nw = new Vector3(sw.x, sw.y, ne.z);
|
||||
|
|
@ -466,11 +467,12 @@ namespace TD.Gameplay
|
|||
{
|
||||
// In play mode the collider exists; draw it directly. In edit mode
|
||||
// we don't have a collider yet, but we can draw the rectangle that
|
||||
// the loader WOULD instantiate, so designers can preview it.
|
||||
// the loader WOULD instantiate, so designers can preview it. Uses
|
||||
// the same formula as SpawnBuildablePlane (tiles are edge-aligned).
|
||||
float worldCenterX =
|
||||
(level.GridOriginTile.x + (level.GridSize.x - 1) * 0.5f) * GridCoordinates.TILE_SIZE;
|
||||
(level.GridOriginTile.x + level.GridSize.x * 0.5f) * GridCoordinates.TILE_SIZE;
|
||||
float worldCenterZ =
|
||||
(level.GridOriginTile.y + (level.GridSize.y - 1) * 0.5f) * GridCoordinates.TILE_SIZE;
|
||||
(level.GridOriginTile.y + level.GridSize.y * 0.5f) * GridCoordinates.TILE_SIZE;
|
||||
float worldSizeX = level.GridSize.x * GridCoordinates.TILE_SIZE;
|
||||
float worldSizeZ = level.GridSize.y * GridCoordinates.TILE_SIZE;
|
||||
|
||||
|
|
@ -505,10 +507,11 @@ namespace TD.Gameplay
|
|||
{
|
||||
int idx = y * level.GridSize.x + x;
|
||||
Gizmos.color = walk[idx] ? walkable : blocked;
|
||||
Vector3 c = new Vector3(
|
||||
(level.GridOriginTile.x + x) * tile,
|
||||
drawY,
|
||||
(level.GridOriginTile.y + y) * tile);
|
||||
// Use GridToWorld so tile centers stay consistent with the convention
|
||||
// (tile (N, N) center at world (N+0.5, N+0.5)).
|
||||
Vector3 c = GridCoordinates.GridToWorld(
|
||||
new Vector2Int(level.GridOriginTile.x + x, level.GridOriginTile.y + y));
|
||||
c.y = drawY;
|
||||
Gizmos.DrawCube(c, size);
|
||||
}
|
||||
}
|
||||
|
|
@ -523,7 +526,6 @@ namespace TD.Gameplay
|
|||
level.OwnerGrid.Length != level.GridSize.x * level.GridSize.y) return;
|
||||
|
||||
float tile = GridCoordinates.TILE_SIZE;
|
||||
float halfTile = tile * 0.5f;
|
||||
float drawY = GridCoordinates.BUILDABLE_PLANE_Y + 0.010f;
|
||||
|
||||
for (int y = 0; y < level.GridSize.y; y++)
|
||||
|
|
@ -534,18 +536,21 @@ namespace TD.Gameplay
|
|||
PlayerSlot owner = level.OwnerGrid[idx];
|
||||
if (owner == PlayerSlot.None) continue;
|
||||
|
||||
Vector3 c = new Vector3(
|
||||
(level.GridOriginTile.x + x) * tile,
|
||||
drawY,
|
||||
(level.GridOriginTile.y + y) * tile);
|
||||
// Tile (gx, gy) spans world XZ from (gx, gy) to (gx+1, gy+1) (edge-aligned).
|
||||
int gx = level.GridOriginTile.x + x;
|
||||
int gy = level.GridOriginTile.y + y;
|
||||
float wMinX = gx * tile;
|
||||
float wMaxX = (gx + 1) * tile;
|
||||
float wMinZ = gy * tile;
|
||||
float wMaxZ = (gy + 1) * tile;
|
||||
|
||||
Gizmos.color = PlayerColors.Get(owner);
|
||||
// Draw four edges as a wire square. We could DrawWireCube
|
||||
// but it would also draw vertical edges we don't want.
|
||||
Vector3 sw = new Vector3(c.x - halfTile, drawY, c.z - halfTile);
|
||||
Vector3 nw = new Vector3(c.x - halfTile, drawY, c.z + halfTile);
|
||||
Vector3 ne = new Vector3(c.x + halfTile, drawY, c.z + halfTile);
|
||||
Vector3 se = new Vector3(c.x + halfTile, drawY, c.z - halfTile);
|
||||
Vector3 sw = new Vector3(wMinX, drawY, wMinZ);
|
||||
Vector3 nw = new Vector3(wMinX, drawY, wMaxZ);
|
||||
Vector3 ne = new Vector3(wMaxX, drawY, wMaxZ);
|
||||
Vector3 se = new Vector3(wMaxX, drawY, wMinZ);
|
||||
Gizmos.DrawLine(sw, nw);
|
||||
Gizmos.DrawLine(nw, ne);
|
||||
Gizmos.DrawLine(ne, se);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue