enemies split, but it needs a bit of work
This commit is contained in:
parent
8714885efa
commit
11ad19992d
10 changed files with 111 additions and 3 deletions
|
|
@ -28,7 +28,7 @@ namespace TD.Gameplay.EnemyAbilities
|
|||
[Tooltip("Relative weight of an enemy rolling no ability at all, vs. the combined " +
|
||||
"weight of every entry in 'abilities'. Higher = abilities are rarer.")]
|
||||
[Min(0f)]
|
||||
[SerializeField] private float noAbilityWeight = 20f;
|
||||
[SerializeField] private float noAbilityWeight = 100f;
|
||||
|
||||
// Fixed-size, enum-indexed lookup built once in Awake. Sized to the enum's entry count,
|
||||
// not authored count, so an out-of-range Kind is a compile-time impossibility rather
|
||||
|
|
|
|||
|
|
@ -28,12 +28,17 @@ namespace TD.Gameplay.EnemyAbilities
|
|||
|
||||
public override void ServerOnDeath(EnemyAbility instance, EnemyHealth health)
|
||||
{
|
||||
Debug.Log($"[SplitOnDeathAbility] ServerOnDeath fired for {instance.name}. " +
|
||||
$"SplitInto={(SplitInto != null ? SplitInto.name : "null")}, " +
|
||||
$"WaveManager.Instance={(WaveManager.Instance != null)}");
|
||||
|
||||
if (SplitInto == null) return;
|
||||
|
||||
var movement = instance.GetComponent<EnemyMovement>();
|
||||
var atTile = GridCoordinates.WorldToGrid(instance.transform.position);
|
||||
var ownerSlot = movement != null ? movement.OriginZone : PlayerSlot.None;
|
||||
|
||||
Debug.Log($"[SplitOnDeathAbility] Spawning {SplitCount}x {SplitInto.name} at tile {atTile}.");
|
||||
WaveManager.Instance?.ServerSpawnSplitEnemies(SplitInto, SplitCount, atTile, ownerSlot, ScatterRadius);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,9 @@ namespace TD.Gameplay
|
|||
kind.Value = (byte)(Definition != null ? Definition.Kind : EnemyAbilityKind.None);
|
||||
hasPendingInit = false;
|
||||
|
||||
if (Definition != null)
|
||||
Debug.Log($"[EnemyAbility] {name} rolled {Definition.Kind}.");
|
||||
|
||||
Definition?.ServerOnSpawn(this);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -580,6 +580,8 @@ namespace TD.Gameplay
|
|||
// this kill's activeEnemyCount-- below, or a split on a wave's last enemy could let
|
||||
// CheckWaveComplete see activeEnemyCount hit 0 and advance the wave prematurely.
|
||||
var ability = health.GetComponent<EnemyAbility>();
|
||||
Debug.Log($"[WaveManager] HandleEnemyKilled: ability={(ability != null)}, " +
|
||||
$"definition={(ability != null ? ability.Definition?.name ?? "null" : "n/a")}");
|
||||
ability?.Definition?.ServerOnDeath(ability, health);
|
||||
|
||||
UnsubscribeEnemy(health);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue