Updating HUD, Gold Config, and finishing off Play flow for 9player map.

This commit is contained in:
Matt F 2026-05-22 12:18:23 -07:00
parent a7be12fa9b
commit 3dcc0e7edd
28 changed files with 2272 additions and 9601 deletions

View file

@ -1,4 +1,5 @@
// Assets/_Project/Scripts/Gameplay/LevelLoader.cs
using System.Collections.Generic;
using UnityEngine;
using TD.Core;
using TD.Levels;
@ -379,6 +380,12 @@ namespace TD.Gameplay
/// <c>false</c>) and when a tower is sold/destroyed (pass <c>true</c>).
/// No-ops silently for out-of-bounds tiles.
/// </summary>
/// <remarks>
/// Fires <see cref="OnWalkabilityChanged"/> once if the tile actually changed.
/// For multi-tile stamps (a tower footprint), prefer
/// <see cref="SetWalkableBatch"/> to fire the event ONCE for the whole batch
/// instead of per-tile — every event triggers all enemy re-paths.
/// </remarks>
public void SetWalkable(Vector2Int tile, bool walkable)
{
if (!TryFlatIndex(tile, out int idx)) return;
@ -387,6 +394,28 @@ namespace TD.Gameplay
OnWalkabilityChanged?.Invoke();
}
/// <summary>
/// Batched variant of <see cref="SetWalkable"/>: updates every tile in
/// <paramref name="tiles"/> to <paramref name="walkable"/> and fires
/// <see cref="OnWalkabilityChanged"/> AT MOST ONCE for the entire batch
/// (only if at least one tile actually changed). Use this for tower footprint
/// stamps so a 2×2 placement triggers a single enemy re-path instead of four.
/// Out-of-bounds tiles in the list are skipped silently.
/// </summary>
public void SetWalkableBatch(IList<Vector2Int> tiles, bool walkable)
{
if (tiles == null) return;
bool anyChanged = false;
for (int i = 0; i < tiles.Count; i++)
{
if (!TryFlatIndex(tiles[i], out int idx)) continue;
if (runtimeWalkability[idx] == walkable) continue;
runtimeWalkability[idx] = walkable;
anyChanged = true;
}
if (anyChanged) OnWalkabilityChanged?.Invoke();
}
/// <summary>
/// Sets the runtime occupancy of <paramref name="tile"/>. Called alongside
/// <see cref="SetWalkable"/> — always update both grids together so they