完善盾卫技能
This commit is contained in:
1 parent
195a459c76
commit
9572db06ad
41 files changed
+25241
-351
No files matched your search
@@ -244,6 +244,7 @@ public class UnitBase : MonoBehaviour
|
||||
{
|
||||
worldHealthBar.maxHealth = health;
|
||||
worldHealthBar.currentHealth = health;
|
||||
worldHealthBar.SetLevel(level);
|
||||
}
|
||||
|
||||
Debug.Log($"{gameObject.name} 从 CharacterData 初始化 (Level {level}): HP={health} ATK={attack} SPD={moveSpeed}");
|
||||
@@ -313,6 +314,9 @@ public class UnitBase : MonoBehaviour
|
||||
// Attack 状态在上方单独处理,因此不会被这里打断或切换目标。
|
||||
target = FindTarget();
|
||||
|
||||
// 嘲讽强行覆盖目标判定
|
||||
UpdateTaunt();
|
||||
|
||||
// 阵位守护:目标离自己阵位超过寻敌视野(detectionRange)就不追了,留在阵位附近
|
||||
if (target != null && useAnchorLeash && anchorInitialized
|
||||
&& IsBeyondLeash(target.transform.position, detectionRange))
|
||||
@@ -370,6 +374,45 @@ public class UnitBase : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsAlive => worldHealthBar != null && !worldHealthBar.IsDead;
|
||||
public bool IsDead => worldHealthBar != null && worldHealthBar.IsDead;
|
||||
|
||||
public void ApplyTaunt(GameObject taunter, float duration)
|
||||
{
|
||||
if (taunter == null || !taunter.activeInHierarchy || IsDead) return;
|
||||
|
||||
tauntSource = taunter;
|
||||
tauntTimer = Mathf.Max(tauntTimer, duration);
|
||||
target = taunter; // 强行把当前攻击/追踪目标切向嘲讽者
|
||||
if (state == State.Alert)
|
||||
{
|
||||
state = State.Track;
|
||||
}
|
||||
Debug.Log($"<color=orange>{gameObject.name} 被 {taunter.name} 强制嘲讽 {duration:F1} 秒!</color>");
|
||||
}
|
||||
|
||||
private GameObject tauntSource;
|
||||
private float tauntTimer = 0f;
|
||||
|
||||
private void UpdateTaunt()
|
||||
{
|
||||
if (tauntTimer > 0f)
|
||||
{
|
||||
tauntTimer -= Time.deltaTime;
|
||||
if (tauntSource != null && tauntSource.activeInHierarchy)
|
||||
{
|
||||
WorldHealthBar bar = tauntSource.GetComponent<WorldHealthBar>();
|
||||
if (bar != null && !bar.IsDead)
|
||||
{
|
||||
target = tauntSource; // 嘲讽期间锁定目标
|
||||
return;
|
||||
}
|
||||
}
|
||||
tauntTimer = 0f;
|
||||
tauntSource = null;
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject Target => target;
|
||||
|
||||
private bool IsTargetValid(GameObject candidate)
|
||||
|
||||
Reference in new issue
Block a user