From 3426606c42d2e94057e3c682890e26c8b50d9700 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期一, 29 九月 2025 15:24:38 +0800
Subject: [PATCH] 125 战斗 强制结束战斗问题修复

---
 Main/System/Battle/BattleField/BattleField.cs                     |    9 ----
 Main/System/Battle/RecordPlayer/RecordPlayer.cs                   |   10 ++++-
 Main/System/Battle/Skill/SkillBase.cs                             |    8 +++-
 Main/System/Battle/BattleHUDWin.cs                                |   27 +++++++++++++
 Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs |   33 +++++++++-------
 5 files changed, 61 insertions(+), 26 deletions(-)

diff --git a/Main/System/Battle/BattleField/BattleField.cs b/Main/System/Battle/BattleField/BattleField.cs
index 55a4b8b..76f228b 100644
--- a/Main/System/Battle/BattleField/BattleField.cs
+++ b/Main/System/Battle/BattleField/BattleField.cs
@@ -493,10 +493,7 @@
 
 
             //鎻愪緵澶栭儴 鑳滃埄绛夊鍔辨樉绀�
-            if (guid != "")
-                EventBroadcast.Instance.Broadcast<string, JsonData>(EventName.BATTLE_END, guid, turnFightStateData);
-
-
+            EventBroadcast.Instance.Broadcast<string, JsonData>(EventName.BATTLE_END, guid, turnFightStateData);
         });
         recordPlayer.PlayRecord(battleEndAction);
     }
@@ -528,10 +525,6 @@
         if (null != battleObj)
         {
             battleObj.buffMgr.RefreshBuff(vNetData);
-        }
-        else
-        {
-            Debug.LogError($"BattleObject with ID {vNetData.ObjID} not found for buff refresh.");
         }
     }
 
diff --git a/Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs b/Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs
index 288a850..9eade48 100644
--- a/Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs
+++ b/Main/System/Battle/BattleField/RecordActions/DeathRecordAction.cs
@@ -32,22 +32,26 @@
             foreach (var deadPack in deadPackList)
             {
                 BattleObject deadObj = battleField.battleObjMgr.GetBattleObject((int)deadPack.ObjID);
-                deadObj.OnDeath(() =>
+                if (null != deadObj)
                 {
-                    index++;
-
-                    isLastOne = index >= total;
-
-                    OnDeathAnimationEnd(deadObj);
-
-                    if (isLastOne)
+                    deadObj.OnDeath(() =>
                     {
-                        // UniTaskExtension.DelayTime((GameObject)null, 0.3f / battleField.speedRatio, () =>
-                        // {
-                            isFinish = true;
-                        // });
-                    }
-                });
+                        index++;
+
+                        isLastOne = index >= total;
+
+                        OnDeathAnimationEnd(deadObj);
+
+                        if (isLastOne)
+                        {
+                            // UniTaskExtension.DelayTime((GameObject)null, 0.3f / battleField.speedRatio, () =>
+                            // {
+                                isFinish = true;
+                            // });
+                        }
+                    });
+                }
+
             }
             return;
         }
@@ -67,5 +71,6 @@
     {
         //  璁剧疆缁撴潫flag 璁板緱娓呯┖motionBase閲岀殑浜嬩欢
         base.ForceFinish();
+        
     }
 }
\ No newline at end of file
diff --git a/Main/System/Battle/BattleHUDWin.cs b/Main/System/Battle/BattleHUDWin.cs
index 04c867c..c9ab163 100644
--- a/Main/System/Battle/BattleHUDWin.cs
+++ b/Main/System/Battle/BattleHUDWin.cs
@@ -4,6 +4,8 @@
 using UnityEngine.UI;
 using DG.Tweening;
 using Cysharp.Threading.Tasks;
+using System;
+using LitJson;
 
 
 //  杩欎釜鐣岄潰鏄� persistent鐨勭晫闈�
@@ -41,15 +43,36 @@
     {
         base.OnPreOpen();
         EventBroadcast.Instance.AddListener<BattleDmgInfo>(EventName.BATTLE_DAMAGE_TAKEN, OnDamageTaken);
+        EventBroadcast.Instance.AddListener<string, JsonData>(EventName.BATTLE_END, OnBattleEnd);
         damagePrefabPool = GameObjectPoolManager.Instance.RequestPool(UILoader.LoadPrefab("DamageContent"));
         // buffIconPrefabPool = GameObjectPoolManager.Instance.RequestPool();
         // buffLabelPrefabPool = GameObjectPoolManager.Instance.RequestPool(ResManager.Instance.LoadAsset<GameObject>("UIComp", "BuffContent"));
+    }
+
+    private void OnBattleEnd(string guid, JsonData data)
+    {
+        ClearContent();
+    }
+
+    private void ClearContent()
+    {
+        // if (battleField.guid == guid)
+        {
+            for (int i = damageContentList.Count - 1; i >= 0; i--)
+            {
+                var content = damageContentList[i];
+                content.Stop();
+                RemoveDamageContent(content);
+            }
+            damageContentList.Clear();
+        }
     }
 
     protected override void OnPreClose()
     {
         base.OnPreClose();
         EventBroadcast.Instance.RemoveListener<BattleDmgInfo>(EventName.BATTLE_DAMAGE_TAKEN, OnDamageTaken);
+        EventBroadcast.Instance.RemoveListener<string, JsonData>(EventName.BATTLE_END, OnBattleEnd);
     }
 
     protected override void OnOpen()
@@ -82,6 +105,9 @@
 
     private void OnDamageTaken(BattleDmgInfo damageInfo)
     {
+        if (battleField.IsBattleEnd())
+            return;
+
         GameObject damageContent = damagePrefabPool.Request();
         DamageContent content = damageContent.GetComponent<DamageContent>();
         damageContent.transform.SetParent(damageNode, false);
@@ -115,6 +141,7 @@
         if (battleField != null)
         {
             battleField.OnBattlePause -= OnBattlePause;
+            ClearContent();
         }
 
         battleField = _battleField;
diff --git a/Main/System/Battle/RecordPlayer/RecordPlayer.cs b/Main/System/Battle/RecordPlayer/RecordPlayer.cs
index d0c1c33..8d1ca4b 100644
--- a/Main/System/Battle/RecordPlayer/RecordPlayer.cs
+++ b/Main/System/Battle/RecordPlayer/RecordPlayer.cs
@@ -88,7 +88,10 @@
 
             for (int i = removeIndexList.Count - 1; i >= 0; i--)
             {
-                immediatelyActionList.RemoveAt(removeIndexList[i]);
+                int index = removeIndexList[i];
+                if (index < 0 || index >= immediatelyActionList.Count)
+                    continue;
+                immediatelyActionList.RemoveAt(index);
             }
         }
     }
@@ -158,7 +161,10 @@
 
     public void HaveRest()
     {
-        ForceFinish();
+        while (IsPlaying())
+        {
+            ForceFinish();
+        }
     }
 
     public void ForceFinish()
diff --git a/Main/System/Battle/Skill/SkillBase.cs b/Main/System/Battle/Skill/SkillBase.cs
index ed22592..1d1ae26 100644
--- a/Main/System/Battle/Skill/SkillBase.cs
+++ b/Main/System/Battle/Skill/SkillBase.cs
@@ -681,6 +681,11 @@
 	public virtual void ForceFinished()
 	{
 		skillEffect?.ForceFinished();
+		if (otherSkillAction != null)
+		{
+			otherSkillAction.ForceFinish();
+			otherSkillAction = null;
+		}
 		isFinished = true;
 		moveFinished = true;
 		isPlay = true;
@@ -694,12 +699,11 @@
 			{
 				if (combinePack.startTag.Tag.StartsWith("Skill_"))
 				{
-					BattleDebug.LogError("other skill casting " + combinePack.startTag.Tag);
 					otherSkillAction = combinePack.CreateSkillAction();
 					otherSkillAction.fromSkillId = skillConfig.SkillID;
 					//	寮哄埗缁撴潫鍏朵粬鎶�鑳�
 					otherSkillAction.ForceFinish();
-					return;
+					continue;
 				}
 			}
 			else if (pack is CustomB421ActionPack actionPack)

--
Gitblit v1.8.0