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

@ -0,0 +1,60 @@
// Assets/_Project/Scripts/Gameplay/EnemyAbilities/BlinkAbilityDefinition.cs
using UnityEngine;
using TD.Core;
namespace TD.Gameplay.EnemyAbilities
{
/// <summary>
/// Every few seconds, the enemy teleports a short distance further along its path — skipping
/// tiles, and the towers covering them.
/// </summary>
/// <remarks>
/// Blinks follow the path rather than cutting toward the goal, so the maze still shapes the
/// route; the buff shortens time-under-fire rather than bypassing walls. See
/// <c>EnemyMovement.ServerBlinkForward</c>.
///
/// <para>The cooldown lives in this enemy's own timer slot rather than on the asset. A field
/// here would be shared by every enemy carrying the buff, so the whole wave would blink in
/// perfect unison — which looks like a bug even when the timing is right.</para>
/// </remarks>
[CreateAssetMenu(fileName = "BlinkAbility", menuName = "TD/Enemy Abilities/Blink")]
public class BlinkAbilityDefinition : EnemyAbilityDefinition
{
public override EnemyAbilityKind Kind => EnemyAbilityKind.Blink;
[Header("Blink")]
[Tooltip("Seconds between blinks.")]
[Min(0.1f)]
public float IntervalSeconds = 4f;
[Tooltip("How many path waypoints to skip per blink. Note that path smoothing can make " +
"one waypoint span several tiles, so this is a coarser dial than it looks.")]
[Min(1)]
public int BlinkWaypoints = 2;
[Tooltip("Random spread (seconds) added to each enemy's first blink so a wave doesn't " +
"blink in one synchronized block. Applied once, at spawn.")]
[Min(0f)]
public float StartJitterSeconds = 1.5f;
public override void ServerOnSpawn(EnemyAbility instance, int abilityIndex)
{
// Seed each enemy's cooldown with a different negative offset so the wave's first
// blink is staggered. Done once, here, rather than on the first tick — a tick-time
// check would have to distinguish "never started" from "just blinked", and both
// states read as a zero timer.
if (StartJitterSeconds > 0f)
instance.TimerFor(abilityIndex) = -Random.Range(0f, StartJitterSeconds);
}
public override void ServerTick(EnemyAbility instance, int abilityIndex, float dt)
{
ref float timer = ref instance.TimerFor(abilityIndex);
timer += dt;
if (timer < IntervalSeconds) return;
timer = 0f;
instance.GetComponent<EnemyMovement>()?.ServerBlinkForward(BlinkWaypoints);
}
}
}