From 6e7de124e70dd2484d8bfaa126cc1420398e8147 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期一, 20 四月 2026 17:20:08 +0800
Subject: [PATCH] 125 战斗 血量刷新bug修复
---
Main/System/Battle/BattleField/BattleField.cs | 3 +
Main/System/Battle/UIComp/BattleHeroInfoBar.cs | 73 +++++++++++++++++++++++++++++++-----
2 files changed, 66 insertions(+), 10 deletions(-)
diff --git a/Main/System/Battle/BattleField/BattleField.cs b/Main/System/Battle/BattleField/BattleField.cs
index 7de937b..f53eaba 100644
--- a/Main/System/Battle/BattleField/BattleField.cs
+++ b/Main/System/Battle/BattleField/BattleField.cs
@@ -841,6 +841,9 @@
// 娓呯悊姝讳骸澶勭悊璁板綍
processingDeathObjIds.Clear();
+
+ // 娓呯┖褰撳墠鎴樺満鐨勮閲忚褰�
+ BattleHeroInfoBar.ClearStaticBattleData(guid);
}
public bool IsBattleEnd()
diff --git a/Main/System/Battle/UIComp/BattleHeroInfoBar.cs b/Main/System/Battle/UIComp/BattleHeroInfoBar.cs
index f87fe6a..7caf21c 100644
--- a/Main/System/Battle/UIComp/BattleHeroInfoBar.cs
+++ b/Main/System/Battle/UIComp/BattleHeroInfoBar.cs
@@ -71,6 +71,7 @@
public static Dictionary<string, ulong> largestPackUID = new Dictionary<string, ulong>();
public static Dictionary<string, Dictionary<long, long>> largestPackUIDAllObjectsToHp = new Dictionary<string, Dictionary<long, long>>();
public static Dictionary<string, Dictionary<long, long>> largestPackUIDAllObjectsMaxHp = new Dictionary<string, Dictionary<long, long>>();
+ public static Dictionary<string, Dictionary<long, ulong>> objectLargestPackUID = new Dictionary<string, Dictionary<long, ulong>>();
protected void OnDisable()
{
@@ -413,11 +414,11 @@
long objID = battleObject.ObjID;
ulong currentPackUID = dmgInfo.battleHurtParam.packUID;
- // 妫�鏌ユ槸鍚︽槸鏈�鏂扮殑 PackUID锛屽鏋滀笉鏄垯蹇界暐
- if (!largestPackUID.ContainsKey(guid) || currentPackUID < largestPackUID[guid])
+ // 鑾峰彇璇ユ垬鍦虹殑瀵硅薄PackUID瀛楀吀锛堢敤浜庢寜瑙掕壊+瑙掕壊韬唤绮掑害鍒ゆ柇锛�
+ Dictionary<long, ulong> objPackUIDDict = null;
+ if (objectLargestPackUID.ContainsKey(guid))
{
- // Debug.LogWarning($"[ExecuteDamageUpdate] 蹇界暐鏃у寘 - ObjID:{objID}, 褰撳墠PackUID:{currentPackUID} < 鏈�澶ackUID:{largestPackUID[guid]}");
- return;
+ objPackUIDDict = objectLargestPackUID[guid];
}
long maxHp, fromHp, toHp, fromShield, toShield;
@@ -426,6 +427,16 @@
BattleHurtObj hurter = dmgInfo.battleHurtParam.hurter;
if (hurter?.hurtObj != null && hurter.hurtObj.ObjID == objID)
{
+ // 鎸夊璞�+鍙楀嚮鑰呰韩浠芥鏌ackUID锛岄伩鍏嶄笉鍚岃韩浠斤紙hurter/caster锛夌殑鍖呬簰鐩搁樆鎷�
+ long hurterKey = objID * 2; // hurter鐢ㄥ伓鏁発ey
+ if (objPackUIDDict != null
+ && objPackUIDDict.ContainsKey(hurterKey)
+ && currentPackUID < objPackUIDDict[hurterKey])
+ {
+ // Debug.LogWarning($"[ExecuteDamageUpdate] 蹇界暐鏃у寘(鍙楀嚮鑰�) - ObjID:{objID}, 褰撳墠PackUID:{currentPackUID} < 瀵硅薄鍙楀嚮鏈�澶ackUID:{objPackUIDDict[hurterKey]}");
+ return;
+ }
+
// 褰撳墠InfoBar鏄彈鍑昏�咃紙鍖呮嫭缁欒嚜宸辨不鐤椼�佺粰鑷繁閫犳垚浼ゅ鐨勬儏鍐碉級
if (hurter.hurtObj.IsTianziBoss())
{
@@ -439,6 +450,12 @@
fromShield = hurter.fromShieldValue;
toShield = hurter.toShieldValue;
+ // 鏇存柊璇ュ璞′綔涓哄彈鍑昏�呯殑鏈�澶ackUID
+ if (objPackUIDDict != null)
+ {
+ objPackUIDDict[hurterKey] = currentPackUID;
+ }
+
// Debug.LogError($"[ExecuteDamageUpdate] 鍙楀嚮鑰� - ObjID:{objID}, fromHp:{fromHp}, toHp:{toHp}, maxHp:{maxHp} (PackUID:{currentPackUID})");
}
// 鍏舵鍒ゆ柇鏄惁涓烘柦娉曡�咃紙鏂芥硶娑堣�楃敓鍛界瓑鎯呭喌锛�
@@ -448,6 +465,16 @@
if (caster?.casterObj == null || caster.casterObj.ObjID != objID)
{
// Debug.LogWarning($"[ExecuteDamageUpdate] 褰撳墠瀵硅薄 {objID} 鏃笉鏄柦娉曡�呬篃涓嶆槸鍙楀嚮鑰�");
+ return;
+ }
+
+ // 鎸夊璞�+鏂芥硶鑰呰韩浠芥鏌ackUID
+ long casterKey = objID * 2 + 1; // caster鐢ㄥ鏁発ey
+ if (objPackUIDDict != null
+ && objPackUIDDict.ContainsKey(casterKey)
+ && currentPackUID < objPackUIDDict[casterKey])
+ {
+ // Debug.LogWarning($"[ExecuteDamageUpdate] 蹇界暐鏃у寘(鏂芥硶鑰�) - ObjID:{objID}, 褰撳墠PackUID:{currentPackUID} < 瀵硅薄鏂芥硶鏈�澶ackUID:{objPackUIDDict[casterKey]}");
return;
}
@@ -462,6 +489,12 @@
toHp = caster.toHp;
fromShield = caster.fromShieldValue;
toShield = caster.toShieldValue;
+
+ // 鏇存柊璇ュ璞′綔涓烘柦娉曡�呯殑鏈�澶ackUID
+ if (objPackUIDDict != null)
+ {
+ objPackUIDDict[casterKey] = currentPackUID;
+ }
// Debug.LogError($"[ExecuteDamageUpdate] 鏂芥硶鑰� - ObjID:{objID}, fromHp:{fromHp}, toHp:{toHp}, maxHp:{maxHp} (PackUID:{currentPackUID})");
}
@@ -583,10 +616,15 @@
{
largestPackUIDAllObjectsMaxHp[guid] = new Dictionary<long, long>();
}
+ if (!objectLargestPackUID.ContainsKey(guid))
+ {
+ objectLargestPackUID[guid] = new Dictionary<long, ulong>();
+ }
ulong currentLargestPackUID = largestPackUID[guid];
Dictionary<long, long> hpDict = largestPackUIDAllObjectsToHp[guid];
Dictionary<long, long> maxHpDict = largestPackUIDAllObjectsMaxHp[guid];
+ Dictionary<long, ulong> objPackUIDDict = objectLargestPackUID[guid];
// 濡傛灉閬囧埌鏇村ぇ鐨刾ackUID锛屾洿鏂版爣璁帮紙涓嶆竻绌烘暟鎹紝淇濈暀鎵�鏈夎瘉鎹級
if (currentPackUID > currentLargestPackUID)
@@ -609,11 +647,13 @@
long maxHp = battleCastObj.maxHp;
long hpChange = newHp - oldHp;
- // 鍙湁褰撳墠packUID绛変簬鏈�澶ackUID鏃舵墠鏇存柊璁板綍
- if (currentPackUID == currentLargestPackUID)
+ // 鍙湁褰撳墠packUID涓嶅皬浜庤瀵硅薄鐨勬渶澶ackUID鏃舵墠鏇存柊璁板綍
+ ulong casterLastPackUID = objPackUIDDict.ContainsKey(casterID) ? objPackUIDDict[casterID] : 0ul;
+ if (currentPackUID >= casterLastPackUID)
{
hpDict[casterID] = newHp;
maxHpDict[casterID] = maxHp;
+ objPackUIDDict[casterID] = currentPackUID;
// 鎵撳嵃琛�閲忓彉鍖栨棩蹇楋紙鏂芥硶鑰呴�氬父鏄仮澶嶇敓鍛斤級
// string casterName = caster.casterObj.teamHero?.heroConfig.Name ?? "鏈煡姝﹀皢";
@@ -625,7 +665,7 @@
}
else
{
- // Debug.LogWarning($"[琛�閲忚褰昡 蹇界暐鏃у寘鏁版嵁 - 鏂芥硶鑰厈casterID}, 褰撳墠PackUID:{currentPackUID} < 鏈�澶ackUID:{currentLargestPackUID}");
+ // Debug.LogWarning($"[琛�閲忚褰昡 蹇界暐鏃у寘鏁版嵁 - 鏂芥硶鑰厈casterID}, 褰撳墠PackUID:{currentPackUID} < 瀵硅薄鏈�澶ackUID:{casterLastPackUID}");
}
}
@@ -642,11 +682,13 @@
long maxHp = battleHurtObj.maxHp;
long damage = oldHp - newHp;
- // 鍙湁褰撳墠packUID绛変簬鏈�澶ackUID鏃舵墠鏇存柊璁板綍
- if (currentPackUID == currentLargestPackUID)
+ // 鍙湁褰撳墠packUID涓嶅皬浜庤瀵硅薄鐨勬渶澶ackUID鏃舵墠鏇存柊璁板綍
+ ulong hurterLastPackUID = objPackUIDDict.ContainsKey(hurterID) ? objPackUIDDict[hurterID] : 0ul;
+ if (currentPackUID >= hurterLastPackUID)
{
hpDict[hurterID] = newHp;
maxHpDict[hurterID] = maxHp;
+ objPackUIDDict[hurterID] = currentPackUID;
// 鎵撳嵃琛�閲忓彉鍖栨棩蹇�
// string hurterName = hurter.hurtObj.teamHero?.heroConfig.Name ?? "鏈煡姝﹀皢";
@@ -657,7 +699,7 @@
}
else
{
- // Debug.LogWarning($"[琛�閲忚褰昡 蹇界暐鏃у寘鏁版嵁 - 鍙楀嚮鑰厈hurterID}, 褰撳墠PackUID:{currentPackUID} < 鏈�澶ackUID:{currentLargestPackUID}");
+ // Debug.LogWarning($"[琛�閲忚褰昡 蹇界暐鏃у寘鏁版嵁 - 鍙楀嚮鑰厈hurterID}, 褰撳墠PackUID:{currentPackUID} < 瀵硅薄鏈�澶ackUID:{hurterLastPackUID}");
}
}
}
@@ -893,6 +935,17 @@
// TODO: 鏄剧ずbuff鎻忚堪/褰撳墠韬笂鎵�鏈塨uff
}
+ /// <summary>
+ /// 娓呯悊鎸囧畾鎴樺満鐨勯潤鎬丳ackUID鍜岃閲忚褰�
+ /// </summary>
+ public static void ClearStaticBattleData(string guid)
+ {
+ largestPackUID.Remove(guid);
+ largestPackUIDAllObjectsToHp.Remove(guid);
+ largestPackUIDAllObjectsMaxHp.Remove(guid);
+ objectLargestPackUID.Remove(guid);
+ }
+
public void HaveRest()
{
CleanupTips();
--
Gitblit v1.8.0