More major updates to tools, added map area volume, made gold manager network managed per player.
This commit is contained in:
parent
b44eeaeeff
commit
56dc775c68
18 changed files with 632 additions and 283 deletions
|
|
@ -69,6 +69,11 @@ namespace TD.Levels
|
|||
[Tooltip("If true, GoalVolume gizmos draw whether or not the volume is selected.")]
|
||||
public bool alwaysShowGoals = false;
|
||||
|
||||
[Tooltip("If true, MapAreaVolume gizmos draw whether or not the volume is selected. " +
|
||||
"Defaults to true — the map boundary is generally useful to see while authoring " +
|
||||
"the rest of the map, not just when the MapAreaVolume itself is selected.")]
|
||||
public bool alwaysShowMapArea = true;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Bake API
|
||||
// -------------------------------------------------------------------
|
||||
|
|
@ -242,4 +247,4 @@ namespace TD.Levels
|
|||
Gizmos.color = prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -81,6 +81,13 @@ namespace TD.Levels
|
|||
"Length = GridSize.x * GridSize.y.")]
|
||||
public PlayerSlot[] OwnerGrid;
|
||||
|
||||
[Tooltip("Per-tile map-area membership. True if the tile is part of the playable map " +
|
||||
"(inside any MapAreaVolume); false for void tiles outside the map. This is the " +
|
||||
"outermost gating layer — gameplay queries (placement, ownership, walkability) " +
|
||||
"are only meaningful for tiles where MapAreaGrid is true. Length = GridSize.x * " +
|
||||
"GridSize.y.")]
|
||||
public bool[] MapAreaGrid;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Per-zone and per-goal structures (populated by bake from volume data).
|
||||
// -------------------------------------------------------------------
|
||||
|
|
@ -141,4 +148,4 @@ namespace TD.Levels
|
|||
[Tooltip("Full tile coverage of the goal volume.")]
|
||||
public Vector2Int[] TileArea;
|
||||
}
|
||||
}
|
||||
}
|
||||
103
Assets/_Project/Levels/MapAreaVolume.cs
Normal file
103
Assets/_Project/Levels/MapAreaVolume.cs
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
using UnityEngine;
|
||||
using TD.Core;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace TD.Levels
|
||||
{
|
||||
/// <summary>
|
||||
/// Authoring volume defining the playable map area — the bounds the builder can move within
|
||||
/// and the camera can pan to. Has no gameplay payload (no owner, no placement validity, no
|
||||
/// spawner data, no leak target). Multiple instances are allowed; their union defines the
|
||||
/// "map area" as referenced in the per-tile data layering spec.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Map area = where the player's attention can go.
|
||||
/// Gameplay area = union of PlayerZone, Spawner, LeakExit, Goal volumes (where rules apply).
|
||||
/// Buffer area = map area minus gameplay area (visible terrain, no gameplay, no building).
|
||||
///
|
||||
/// Coverage rule: every gameplay volume's tiles must be a subset of the map area. The bake
|
||||
/// validates this in Phase 5 (P5-12) and fails with a hard error if any gameplay volume
|
||||
/// pokes outside the map area.
|
||||
///
|
||||
/// Drawn as a thicker outline only (no fill) so it reads as a boundary marker rather than
|
||||
/// as a translucent overlay on top of the gameplay volumes. The "always show" toggle on
|
||||
/// LevelAuthoring defaults to true for this volume type because the map boundary is
|
||||
/// generally useful to see during all authoring, not just when this volume is selected.
|
||||
/// </remarks>
|
||||
public class MapAreaVolume : VolumeBase
|
||||
{
|
||||
// Map area draws BELOW player zones (which sit at 0.05). Just above the LevelAuthoring
|
||||
// map-bounds line (0.01) so it doesn't z-fight with that wireframe.
|
||||
private const float FillYLevel = 0.02f;
|
||||
|
||||
protected override bool GetAlwaysShowToggle(LevelAuthoring authoring)
|
||||
{
|
||||
return authoring.alwaysShowMapArea;
|
||||
}
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
DrawGizmosCore();
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
if (ShouldDrawAlwaysOn())
|
||||
{
|
||||
DrawGizmosCore();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawGizmosCore()
|
||||
{
|
||||
Color baseColor = PlayerColors.MapArea;
|
||||
DrawThickRectangularOutline(baseColor, yLevel: FillYLevel);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
var col = Collider;
|
||||
if (col != null)
|
||||
{
|
||||
Vector3 labelPos = new Vector3(col.bounds.center.x, FillYLevel + 0.1f, col.bounds.center.z);
|
||||
Handles.Label(labelPos, "Map Area");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Draws the volume's tight tile rectangle as a thicker outline. Unity's Gizmos.DrawLine
|
||||
// has no width parameter, so we approximate thickness by drawing the rectangle three
|
||||
// times with small lateral offsets. The offsets are in tile units; 0.04 reads as a
|
||||
// visibly thicker line at typical scene-view zoom without looking like multiple lines.
|
||||
private void DrawThickRectangularOutline(Color outlineColor, float yLevel)
|
||||
{
|
||||
if (!TryGetTightTileRect(out Vector2Int minTile, out Vector2Int maxTile)) return;
|
||||
|
||||
const float thickness = 0.04f;
|
||||
float halfTile = GridCoordinates.TILE_SIZE * 0.5f;
|
||||
|
||||
// Three concentric rectangles: the original edge, slightly inset, slightly outset.
|
||||
DrawOutlineAtInset(minTile, maxTile, halfTile, yLevel, 0f, outlineColor);
|
||||
DrawOutlineAtInset(minTile, maxTile, halfTile, yLevel, +thickness, outlineColor);
|
||||
DrawOutlineAtInset(minTile, maxTile, halfTile, yLevel, -thickness, outlineColor);
|
||||
}
|
||||
|
||||
private static void DrawOutlineAtInset(Vector2Int minTile, Vector2Int maxTile, float halfTile,
|
||||
float yLevel, float inset, Color color)
|
||||
{
|
||||
Vector3 sw = new Vector3(minTile.x - halfTile - inset, yLevel, minTile.y - halfTile - inset);
|
||||
Vector3 se = new Vector3(maxTile.x + halfTile + inset, yLevel, minTile.y - halfTile - inset);
|
||||
Vector3 ne = new Vector3(maxTile.x + halfTile + inset, yLevel, maxTile.y + halfTile + inset);
|
||||
Vector3 nw = new Vector3(minTile.x - halfTile - inset, yLevel, maxTile.y + halfTile + inset);
|
||||
|
||||
Color prev = Gizmos.color;
|
||||
Gizmos.color = color;
|
||||
Gizmos.DrawLine(sw, se);
|
||||
Gizmos.DrawLine(se, ne);
|
||||
Gizmos.DrawLine(ne, nw);
|
||||
Gizmos.DrawLine(nw, sw);
|
||||
Gizmos.color = prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/_Project/Levels/MapAreaVolume.cs.meta
Normal file
2
Assets/_Project/Levels/MapAreaVolume.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bacb3662546735544bc6c56b5bf5830a
|
||||
Loading…
Add table
Add a link
Reference in a new issue