根据提供的code differences信息,由于没有具体的代码变更内容,我将生成一个通用的commit message模板:
``` docs(changelog): 更新项目变更日志 - 添加新的版本记录 - 修正已知问题描述 - 更新功能特性说明 ``` 注意:由于您提供的code differences部分为空,以上是一个示例模板。实际使用时请根据具体的代码变更内容来填写相应的type、scope、subject和body信息。
This commit is contained in:
1 parent
69f33d8637
commit
951ba49c79
26 files changed
+942
-455
No files matched your search
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(StatusEffectController))]
|
||||
public class MainCharacterCombat : MonoBehaviour
|
||||
{
|
||||
[Header("自动攻击")]
|
||||
@@ -42,6 +43,7 @@ public class MainCharacterCombat : MonoBehaviour
|
||||
[Min(0f)]
|
||||
public float projectileLifetime = 5f;
|
||||
|
||||
private StatusEffectController statusEffectController;
|
||||
private Animator animator;
|
||||
private MainCharacterDebugMovement movement;
|
||||
private GameObject target;
|
||||
@@ -56,10 +58,18 @@ public class MainCharacterCombat : MonoBehaviour
|
||||
private bool summonSpawned;
|
||||
private bool summoning;
|
||||
|
||||
public bool IsStunned => statusEffectController != null && statusEffectController.IsStunned;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
animator = GetComponent<Animator>();
|
||||
movement = GetComponent<MainCharacterDebugMovement>();
|
||||
statusEffectController = GetComponent<StatusEffectController>();
|
||||
|
||||
if (statusEffectController == null)
|
||||
{
|
||||
statusEffectController = gameObject.AddComponent<StatusEffectController>();
|
||||
}
|
||||
|
||||
if (animator != null)
|
||||
{
|
||||
@@ -69,6 +79,16 @@ public class MainCharacterCombat : MonoBehaviour
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// 眩晕时停止所有行动
|
||||
if (IsStunned)
|
||||
{
|
||||
if (animator != null)
|
||||
{
|
||||
animator.SetInteger("speed", 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (attackCooldown > 0f)
|
||||
{
|
||||
attackCooldown -= Time.deltaTime;
|
||||
@@ -230,11 +250,12 @@ public class MainCharacterCombat : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
// 立即停止移动
|
||||
// 立即停止移动,并禁用移动脚本(防止干扰动画)
|
||||
SummonerClickMovement clickMovement = GetComponent<SummonerClickMovement>();
|
||||
if (clickMovement != null)
|
||||
{
|
||||
clickMovement.ClearTarget();
|
||||
clickMovement.enabled = false; // 禁用移动脚本,避免它设置 speed 参数
|
||||
}
|
||||
|
||||
pendingSummonPrefab = prefab;
|
||||
@@ -244,9 +265,17 @@ public class MainCharacterCombat : MonoBehaviour
|
||||
summonSpawned = false;
|
||||
summoning = true;
|
||||
animator.speed = 1f;
|
||||
|
||||
// 强制重置动画状态,避免状态过渡冲突
|
||||
animator.SetInteger("speed", 0);
|
||||
animator.ResetTrigger("skill");
|
||||
animator.ResetTrigger("attack");
|
||||
|
||||
// 直接强制播放 skill 动画,绕过状态机的所有过渡条件
|
||||
// Play() 会立即切换,不管当前状态是什么
|
||||
animator.Play("skill", 0, 0f);
|
||||
|
||||
Debug.Log("强制播放 skill 动画");
|
||||
}
|
||||
|
||||
public void OnSkillHit1()
|
||||
@@ -272,7 +301,22 @@ public class MainCharacterCombat : MonoBehaviour
|
||||
pendingSummonPrefab,
|
||||
spawnPosition,
|
||||
Quaternion.LookRotation(direction, Vector3.up));
|
||||
summoned.tag = "Friend";
|
||||
|
||||
// 召唤的单位继承召唤师的阵营(不再硬编码为 Friend)
|
||||
UnitTeam summonerTeam = GetComponent<UnitTeam>();
|
||||
UnitTeam summonedTeam = summoned.GetComponent<UnitTeam>();
|
||||
|
||||
if (summonerTeam != null && summonedTeam != null)
|
||||
{
|
||||
summonedTeam.teamId = summonerTeam.teamId;
|
||||
// 根据阵营设置 tag(向后兼容旧系统)
|
||||
summoned.tag = summonerTeam.teamId == 0 ? "Friend" : "Enemy";
|
||||
}
|
||||
else
|
||||
{
|
||||
// 降级:没有 UnitTeam 时保持原逻辑
|
||||
summoned.tag = "Friend";
|
||||
}
|
||||
|
||||
UnitBase unitBase = summoned.GetComponent<UnitBase>();
|
||||
if (unitBase != null && pendingSummonCharacterData != null && pendingSummonPlayerData != null)
|
||||
@@ -404,16 +448,25 @@ public class MainCharacterCombat : MonoBehaviour
|
||||
private void CheckSummonFinished()
|
||||
{
|
||||
AnimatorStateInfo state = animator.GetCurrentAnimatorStateInfo(0);
|
||||
|
||||
// 正常完成:skill 动画播放完毕
|
||||
if (state.IsName("skill") && state.normalizedTime >= 1f)
|
||||
{
|
||||
FinishSummon();
|
||||
return;
|
||||
}
|
||||
|
||||
// skill 状态意外被其他动画打断时,才使用超时兜底,避免永久锁定召唤。
|
||||
// 超时检测:添加调试信息
|
||||
if (summonElapsed >= summonAnimationTimeout)
|
||||
{
|
||||
Debug.LogWarning("主角召唤动画超时,已解除召唤状态");
|
||||
// 输出当前动画状态,帮助诊断问题
|
||||
string currentState = "unknown";
|
||||
if (state.IsName("skill")) currentState = "skill";
|
||||
else if (state.IsName("idle")) currentState = "idle";
|
||||
else if (state.IsName("run")) currentState = "run";
|
||||
else if (state.IsName("attack")) currentState = "attack";
|
||||
|
||||
Debug.LogWarning($"主角召唤动画超时,已解除召唤状态。当前动画状态: {currentState}, normalizedTime: {state.normalizedTime:F2}");
|
||||
FinishSummon();
|
||||
}
|
||||
}
|
||||
@@ -427,6 +480,15 @@ public class MainCharacterCombat : MonoBehaviour
|
||||
animator.speed = 1f;
|
||||
animator.SetInteger("speed", 0);
|
||||
animator.Play("idle", 0, 0f);
|
||||
|
||||
// 重新启用移动脚本
|
||||
SummonerClickMovement clickMovement = GetComponent<SummonerClickMovement>();
|
||||
if (clickMovement != null)
|
||||
{
|
||||
clickMovement.enabled = true;
|
||||
}
|
||||
|
||||
Debug.Log("召唤完成,恢复移动脚本");
|
||||
}
|
||||
|
||||
private void CheckAttackFinished()
|
||||
@@ -535,18 +597,38 @@ public class MainCharacterCombat : MonoBehaviour
|
||||
private GameObject FindNearestEnemy()
|
||||
{
|
||||
// 索敌范围使用较小的 detectRange,主角不主动远离基地寻找敌人
|
||||
UnitTeam myTeam = GetComponent<UnitTeam>();
|
||||
if (myTeam == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
GameObject nearest = null;
|
||||
float nearestDistance = detectRange * detectRange;
|
||||
|
||||
foreach (GameObject enemy in GameObject.FindGameObjectsWithTag("Enemy"))
|
||||
// 查找所有带 UnitTeam 的对象(包括单位和召唤师)
|
||||
UnitTeam[] allTeams = FindObjectsOfType<UnitTeam>();
|
||||
|
||||
foreach (UnitTeam targetTeam in allTeams)
|
||||
{
|
||||
if (enemy == null || enemy.transform.root == transform.root)
|
||||
GameObject enemy = targetTeam.gameObject;
|
||||
|
||||
if (enemy == null || enemy == gameObject || enemy.transform.root == transform.root)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// 检查是否是敌人(使用阵营 ID)
|
||||
if (!myTeam.IsEnemy(enemy))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// 检查是否有 UnitBase 或 WorldHealthBar(召唤师)
|
||||
UnitBase enemyUnit = enemy.GetComponentInParent<UnitBase>();
|
||||
if (enemyUnit == null)
|
||||
WorldHealthBar enemyHealth = enemy.GetComponentInParent<WorldHealthBar>();
|
||||
|
||||
if (enemyUnit == null && enemyHealth == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user