Files
daluandou/Assets/Script/CastleMageSkill.cs
T
huadexuan f93d69d8ee ```
docs(clipboard): 添加剪贴板功能相关图片资源

添加了两个剪贴板功能的截图文件,用于文档说明和功能展示。
```
2026-09-09 23:59:15 +08:00

53 lines
1.4 KiB
C#

using System.Collections.Generic;
using UnityEngine;
public class CastleMageSkill : UnitSkill
{
[Header("小型魔爆参数")]
[Min(0.1f)]
public float explosionRadius = 1.8f;
[Min(0f)]
public float explosionDamage = 85f;
public override void ReleaseSkill()
{
GameObject target = unit.Target;
if (target == null)
{
return;
}
string opponentTag = unit.OpponentTag;
if (string.IsNullOrEmpty(opponentTag))
{
return;
}
Vector3 center = target.transform.position;
float radiusSquared = explosionRadius * explosionRadius;
HashSet<UnitBase> hitUnits = new HashSet<UnitBase>();
foreach (GameObject opponent in GameObject.FindGameObjectsWithTag(opponentTag))
{
if (opponent == null || opponent.transform.root == unit.transform.root)
{
continue;
}
Vector3 offset = opponent.transform.position - center;
offset.y = 0f;
if (offset.sqrMagnitude > radiusSquared)
{
continue;
}
UnitBase targetUnit = opponent.GetComponentInParent<UnitBase>();
if (targetUnit != null && hitUnits.Add(targetUnit))
{
targetUnit.ReceiveDamage(explosionDamage, unit.gameObject);
}
}
}
}