Files
daluandou/Assets/Script/ShieldGuardSkill.cs
T
2026-09-01 18:17:34 +08:00

45 lines
1.1 KiB
C#

using UnityEngine;
public class ShieldGuardSkill : UnitSkill
{
[Header("盾牌参数")]
[Min(1f)]
public float shieldDurability = 220f;
[Min(0.1f)]
public float shieldDuration = 6f;
public Vector3 shieldLocalPosition = new Vector3(0f, 1f, 0.7f);
public Vector3 shieldSize = new Vector3(1.5f, 1.8f, 0.12f);
private ShieldBarrier shield;
public ShieldBarrier ActiveShield => shield;
public override void ReleaseSkill()
{
EnsureShield();
shield.Refresh(shieldDurability, shieldDuration, shieldLocalPosition, shieldSize);
}
private void EnsureShield()
{
if (shield != null)
{
return;
}
GameObject shieldObject = new GameObject("ShieldBarrier");
shieldObject.transform.SetParent(unit.transform, false);
BoxCollider boxCollider = shieldObject.AddComponent<BoxCollider>();
boxCollider.isTrigger = true;
boxCollider.size = shieldSize;
shield = shieldObject.AddComponent<ShieldBarrier>();
shield.Configure(unit, boxCollider);
shieldObject.SetActive(false);
}
}