``` docs(readme): 更新文档说明 - 添加项目使用指南 - 完善API接口说明 - 修正错误的配置示例 ``` 注意:由于您提供的code differences部分为空,以上是一个示例模板。当您有具体的代码变更时,请提供详细的变更内容以便生成更准确的commit message。
51 lines
1.4 KiB
C#
51 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;
|
|
UnitTeam myTeam = unit.GetComponent<UnitTeam>();
|
|
if (target == null || myTeam == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Vector3 center = target.transform.position;
|
|
float radiusSquared = explosionRadius * explosionRadius;
|
|
HashSet<UnitBase> hitUnits = new HashSet<UnitBase>();
|
|
|
|
foreach (UnitTeam opponentTeam in GameObject.FindObjectsOfType<UnitTeam>())
|
|
{
|
|
GameObject opponent = opponentTeam.gameObject;
|
|
if (opponent == null
|
|
|| opponent.transform.root == unit.transform.root
|
|
|| !myTeam.IsEnemy(opponent))
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|