First pass at full refactor to 2.0 design

Restructures the game around the cyclical run loop from Game Design Doc V2:
5 waves = a cycle, 3 cycles = a phase, each phase ends in a boss.

- New TD.Gameplay.Waves: WaveGroup / PhaseDefinition / RunDefinition author the
  run as draggable weighted pools; RunState owns phase/cycle position, the drawn
  wave slots, and the per-slot enemy buff sets. WaveManager's flat wave array is
  gone -- it now only runs the encounter RunState points at.
- New TD.Gameplay.EnemyUpgrades: the post-wave enemy-buff vote, with public
  live-replicated ballots so the HUD can show who voted for what.
- Inter-wave flow is now strictly sequential: draft -> vote -> build, each stage
  ending early once every player has acted.
- Enemy abilities inverted from per-instance random rolls to deterministic,
  stacking per-wave-slot sets. Six cards ship: Split (reworked), Flight, Blink,
  No Bounty, Gold Theft, Double Up.
- Tower upgrades are a two-step tree: a draft pick unlocks a node, gold converts
  an already-placed tower in place.
- Boss encounters flag their enemies and drive a boss HP bar.
- Player cap reduced to 3 via MatchRules.MaxPlayers.
- GoldConfig is now keyed by global encounter number rather than wave index.

Compiles clean; NOT yet verified in-engine. Editor wiring still required --
see Docs/2.0_Setup_Checklist.md.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Matt F 2026-07-30 17:45:11 -07:00
parent 7e5c3a8279
commit 4892d7253d
64 changed files with 4023 additions and 344 deletions

View file

@ -282,6 +282,45 @@ namespace TD.Gameplay
NetworkObject.Despawn();
}
// ----- Ability-driven movement ----------------------------------------
/// <summary>
/// Server-only: teleport this enemy forward along its existing path by up to
/// <paramref name="tiles"/> waypoints. Used by the Blink wave buff.
/// </summary>
/// <remarks>
/// <b>Follows the path rather than the straight line to the goal.</b> Jumping toward the
/// goal as the crow flies would let a grounded enemy blink through walls, which is the
/// flying buff's job, not this one. Skipping waypoints keeps the enemy inside the maze —
/// it cuts corners, it doesn't ignore them.
///
/// <para>Zone tracking still runs on the destination tile, so an enemy that blinks out of
/// its origin zone still credits its owner a leak. Skipping that would make the buff a way
/// to launder leaks past the no-leak bonus.</para>
///
/// <para>Blinking onto the final waypoint resolves as a normal goal arrival, despawn and
/// life cost included.</para>
/// </remarks>
public void ServerBlinkForward(int tiles)
{
if (!IsServer || tiles <= 0) return;
if (hasReachedGoal || remainingPath.Count == 0) return;
if (health != null && health.IsHeld) return;
int skip = Mathf.Min(tiles, remainingPath.Count);
Vector2Int destination = remainingPath[skip - 1];
remainingPath.RemoveRange(0, skip);
// Preserve Y so flyers stay at altitude and grounded pivots don't sink.
Vector3 world = GridCoordinates.GridToWorld(destination);
transform.position = new Vector3(world.x, transform.position.y, world.z);
CheckZoneTransition(destination);
if (remainingPath.Count == 0)
HandleGoalReached();
}
// ----- Path invalidation ----------------------------------------------
// Called by PathfindingService's budgeted scheduler after a walkability change