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:
parent
7e5c3a8279
commit
4892d7253d
64 changed files with 4023 additions and 344 deletions
|
|
@ -0,0 +1,62 @@
|
|||
// Assets/_Project/Scripts/Gameplay/EnemyUpgrades/AbilityEnemyUpgradeOption.cs
|
||||
using UnityEngine;
|
||||
using TD.Gameplay.EnemyAbilities;
|
||||
using TD.Gameplay.Waves;
|
||||
|
||||
namespace TD.Gameplay.EnemyUpgrades
|
||||
{
|
||||
/// <summary>
|
||||
/// The workhorse enemy-buff card: grants an <see cref="EnemyAbilityDefinition"/> to a wave
|
||||
/// slot. Every enemy spawned by that wave, in every later cycle of the phase, carries the
|
||||
/// ability.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// There is nothing to do at vote-resolution time — recording the option id on the slot IS the
|
||||
/// effect, because the spawn path builds each enemy's ability set from the slot's recorded
|
||||
/// options. <see cref="Ability"/> is what that lookup resolves to.
|
||||
/// </remarks>
|
||||
[CreateAssetMenu(fileName = "EnemyUpgrade_Ability",
|
||||
menuName = "TD/Enemy Upgrades/Ability Card", order = 20)]
|
||||
public class AbilityEnemyUpgradeOption : EnemyUpgradeOption
|
||||
{
|
||||
[Header("Payload")]
|
||||
[Tooltip("The ability every enemy in this wave gains. Must also be present in the scene's " +
|
||||
"EnemyAbilityPool so it can be resolved at spawn time.")]
|
||||
public EnemyAbilityDefinition Ability;
|
||||
|
||||
public override bool IsValidForSlot(RunState run, int slot)
|
||||
{
|
||||
if (Ability == null) return false;
|
||||
|
||||
// Don't offer an ability the slot already has by another card's hand. Exact-id repeats
|
||||
// are filtered by the caller, but two different cards can grant the same ability, and
|
||||
// stacking one twice is a no-op the players would rightly feel cheated by.
|
||||
return !SlotAlreadyHasAbility(run, slot);
|
||||
}
|
||||
|
||||
// Shared scratch: validation runs on the server during vote generation, which is
|
||||
// single-threaded, so one reused list beats allocating per candidate per slot.
|
||||
private static readonly System.Collections.Generic.List<int> s_idScratch
|
||||
= new System.Collections.Generic.List<int>();
|
||||
|
||||
private bool SlotAlreadyHasAbility(RunState run, int slot)
|
||||
{
|
||||
var pool = EnemyUpgradePool.Instance;
|
||||
if (run == null || pool == null) return false;
|
||||
|
||||
var ids = s_idScratch;
|
||||
run.GetUpgradesForSlot(slot, ids);
|
||||
|
||||
foreach (int id in ids)
|
||||
{
|
||||
if (pool.Get(id) is AbilityEnemyUpgradeOption other && other.Ability == Ability)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>Inherits nothing automatically — <see cref="EnemyAbilityDefinition"/> carries no
|
||||
/// icon, so the card's own <see cref="EnemyUpgradeOption.Icon"/> is the only source.</summary>
|
||||
public override Sprite ResolveIcon() => Icon;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue