// Assets/_Project/Scripts/Gameplay/EnemyAbilities/FlightAbilityDefinition.cs using UnityEngine; using TD.Core; namespace TD.Gameplay.EnemyAbilities { /// /// Grounded enemies take to the air: they path over the baked terrain grid instead of through /// the maze, and towers flagged ground-only can no longer touch them. /// /// /// The single most punishing card in the set, because it doesn't weaken the maze — it /// deletes it. Everything a player built to lengthen the route stops mattering for that wave, /// and only their anti-air coverage counts. Weight it accordingly in the pools. /// /// Purely a spawn-time change: EnemyMovement reads the flying flag once at /// initialization to pick which grid to path on and to opt out of re-path scheduling, and /// TowerCombat reads the replicated flag on EnemyHealth when filtering targets. /// Both are already wired for flight — this card only has to flip the bit before the enemy is /// built. /// [CreateAssetMenu(fileName = "FlightAbility", menuName = "TD/Enemy Abilities/Flight")] public class FlightAbilityDefinition : EnemyAbilityDefinition { public override EnemyAbilityKind Kind => EnemyAbilityKind.Flight; [Header("Flight")] [Tooltip("Height above the ground these enemies hover at. Keep modest — tower targeting " + "uses 3D range, so altitude eats into the effective reach of anything that CAN " + "shoot them.")] [Min(0f)] public float FlightHeight = 3f; [Tooltip("Speed multiplier applied when the enemy takes flight. Flying enemies travel a " + "much shorter route, so values below 1 are a reasonable counterweight.")] [Range(0.1f, 2f)] public float SpeedMultiplier = 1f; public override void ServerModifySpawn(ref EnemySpawnContext context) { // Already-flying enemies keep their authored height rather than being overwritten by // this card's — the wave was designed around it, and stacking Flight onto a flier // shouldn't quietly relocate it. if (!context.IsFlying) { context.IsFlying = true; context.FlightHeight = FlightHeight; } context.MoveSpeed *= SpeedMultiplier; } } }