draft options working; spells won't cast though

This commit is contained in:
Ian Woods 2026-07-14 20:56:50 -07:00
parent 2429efbf6a
commit 7cf15dcaa6
37 changed files with 1340 additions and 0 deletions

View file

@ -0,0 +1,47 @@
// Assets/_Project/Scripts/Gameplay/BuilderSpells/FireballSpellDefinition.cs
using UnityEngine;
using TD.Core;
namespace TD.Gameplay.BuilderSpells
{
/// <summary>
/// Builder spell #1 — drop a fireball on a point, dealing direct damage to whatever's
/// there plus splash damage to nearby enemies.
/// </summary>
/// <remarks>
/// <see cref="BuilderSpellDefinition.TargetType"/> is <see cref="SpellTargetType.PointTarget"/>
/// — the cast controller shows only a fixed-size reticle, even though
/// <see cref="BuilderSpellDefinition.Radius"/> is still used internally here as the splash
/// radius (0 = no splash, direct hit only).
/// </remarks>
[CreateAssetMenu(fileName = "FireballSpell", menuName = "TD/Builder Spells/Fireball")]
public class FireballSpellDefinition : BuilderSpellDefinition
{
public override BuilderSpellKind Kind => BuilderSpellKind.Fireball;
[Header("Fireball")]
[Tooltip("Damage dealt to every enemy within Radius of the target point.")]
[Min(0f)]
public float Damage = 50f;
public override bool ServerCast(ulong clientId, Vector3 targetPoint)
{
PlayerSlot owner = PlayerMatchState.SlotForClient(clientId);
int count = Physics.OverlapSphereNonAlloc(
targetPoint, Mathf.Max(Radius, 0.01f), s_overlapBuffer, enemyLayerMask);
bool hitAny = false;
for (int i = 0; i < count; i++)
{
var enemyHealth = s_overlapBuffer[i].GetComponent<EnemyHealth>();
if (enemyHealth == null || enemyHealth.IsDead) continue;
enemyHealth.TakeDamage(Damage, DamageType.Fire, owner);
hitAny = true;
}
return hitAny;
}
}
}