```
feat(player): 添加玩家阵型保存功能 新增savedFormation字段用于存储玩家的阵型配置, 包括角色ID列表和对应的格子索引位置信息。 ```
This commit is contained in:
1 parent
e127da5416
commit
1abd0de32f
16 files changed
+432
-2930
No files matched your search
@@ -195,16 +195,43 @@ public class HeroCardUI : MonoBehaviour
|
||||
var navAgent = heroUnit.GetComponent<UnityEngine.AI.NavMeshAgent>();
|
||||
if (navAgent != null)
|
||||
{
|
||||
navAgent.enabled = true; // 确保启用
|
||||
if (!navAgent.isOnNavMesh)
|
||||
{
|
||||
navAgent.enabled = false;
|
||||
navAgent.enabled = true;
|
||||
}
|
||||
navAgent.ResetPath(); // 清空旧路径
|
||||
}
|
||||
|
||||
// 重置 UnitBase 状态(关键修复:清空目标让单位重新寻敌)
|
||||
UnitBase unitBase = heroUnit.GetComponent<UnitBase>();
|
||||
if (unitBase != null)
|
||||
{
|
||||
unitBase.enabled = true; // 确保脚本启用
|
||||
unitBase.target = null; // 清空目标
|
||||
unitBase.ResetAnchorPosition(); // 重置锚点位置到复活位置(修复一直尝试返回旧锚点的问题)
|
||||
}
|
||||
|
||||
// 重置 Animator
|
||||
Animator animator = heroUnit.GetComponent<Animator>();
|
||||
if (animator != null)
|
||||
{
|
||||
animator.enabled = true;
|
||||
animator.Rebind(); // 重置动画状态
|
||||
animator.Update(0f);
|
||||
}
|
||||
|
||||
// 使用WorldHealthBar的Revive方法(会重置isDead并恢复生命)
|
||||
heroHealthBar.Revive(heroHealthBar.maxHealth);
|
||||
|
||||
// 重新显示血条(修复复活后没有血条的问题)
|
||||
Transform barTransform = heroHealthBar.transform.Find("WorldHealthBar");
|
||||
if (barTransform != null)
|
||||
{
|
||||
barTransform.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
// 重置UI状态
|
||||
isDead = false;
|
||||
if (deathPanel != null)
|
||||
|
||||
Reference in new issue
Block a user