fix slow area spell area of effect
This commit is contained in:
parent
04d7b42e60
commit
35ea90f71b
3 changed files with 92 additions and 18 deletions
|
|
@ -14,6 +14,12 @@ namespace TD.Gameplay.BuilderSpells
|
|||
/// while aiming, and this spell resolves against that same radius (no separate field).
|
||||
/// Reuses the existing slow/DoT system (<see cref="EnemyStatus.ApplyEffect"/>) rather than
|
||||
/// introducing a new status mechanism.
|
||||
/// <para>
|
||||
/// The cast spawns a <see cref="SlowAreaZone"/> that lingers for
|
||||
/// <see cref="EffectDuration"/> and keeps re-applying the slow to anything standing in
|
||||
/// the radius, so enemies walking through the area get slowed rather than only whatever
|
||||
/// happened to be standing there at the exact instant of cast.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[CreateAssetMenu(fileName = "SlowAreaSpell", menuName = "TD/Builder Spells/Slow Area")]
|
||||
public class SlowAreaSpellDefinition : BuilderSpellDefinition
|
||||
|
|
@ -35,7 +41,9 @@ namespace TD.Gameplay.BuilderSpells
|
|||
[Range(0f, 1f)]
|
||||
public float SlowFactor = 0.5f;
|
||||
|
||||
[Tooltip("Seconds the slow lasts. Re-casting on an already-slowed enemy refreshes it.")]
|
||||
[Tooltip("Seconds the slow lasts on an affected enemy, and how long the area itself " +
|
||||
"lingers, re-slowing anything that walks through it. Re-casting on an " +
|
||||
"already-slowed enemy refreshes it.")]
|
||||
[Min(0f)]
|
||||
public float EffectDuration = 3f;
|
||||
|
||||
|
|
@ -43,25 +51,12 @@ namespace TD.Gameplay.BuilderSpells
|
|||
{
|
||||
PlayerSlot owner = PlayerMatchState.SlotForClient(clientId);
|
||||
|
||||
int count = Physics.OverlapSphereNonAlloc(
|
||||
targetPoint, Mathf.Max(Radius, 0.01f), s_overlapBuffer, enemyLayerMask);
|
||||
SlowAreaZone.Spawn(targetPoint, Mathf.Max(Radius, 0.01f), SlowFactor,
|
||||
EffectDuration, enemyLayerMask, owner);
|
||||
|
||||
bool hitAny = false;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var enemyHealth = s_overlapBuffer[i].GetComponent<EnemyHealth>();
|
||||
if (enemyHealth == null || enemyHealth.IsDead) continue;
|
||||
|
||||
var enemyStatus = s_overlapBuffer[i].GetComponent<EnemyStatus>();
|
||||
if (enemyStatus == null) continue;
|
||||
|
||||
enemyStatus.ApplyEffect(DamageType.Cold, SlowFactor, EffectDuration, owner);
|
||||
hitAny = true;
|
||||
}
|
||||
|
||||
return hitAny;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override void ClientSpawnVfx(Vector3 targetPoint)
|
||||
{
|
||||
if (areaVfxPrefab != null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue