From ff0163176f59bdd935543b23fabd2ea777603f4a Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期二, 16 十二月 2025 11:19:26 +0800
Subject: [PATCH] 125 战斗 修复血量溢出时有护盾的问题

---
 Main/System/Battle/BattleUtility.cs            |    5 ++++-
 Main/System/Battle/UIComp/BattleHeroInfoBar.cs |   25 +++++++++++++++++++++----
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/Main/System/Battle/BattleUtility.cs b/Main/System/Battle/BattleUtility.cs
index 2b0d59d..97a7046 100644
--- a/Main/System/Battle/BattleUtility.cs
+++ b/Main/System/Battle/BattleUtility.cs
@@ -399,11 +399,13 @@
                 if (hurter.fromShieldValue >= currentHitDamage)
                 {
                     hurter.toHp = hurter.fromHp;
+                    target.teamHero.curHp = hurter.toHp; // 淇濇寔涓�鑷存��
                 }
                 else
                 {
                     long remainingDamage = currentHitDamage - hurter.fromShieldValue;
                     hurter.toHp = Math.Max(0, hurter.fromHp - remainingDamage);
+                    target.teamHero.curHp = hurter.toHp; // 淇濇寔涓�鑷存��
                 }
             }
         }
@@ -472,7 +474,8 @@
 
         caster.toHp = casterToHp;
         caster.toShieldValue = casterToShield;
-
+        skillBase.caster.teamHero.curHp = caster.toHp; // 淇濇寔涓�鑷存��
+        
         return caster;
     }
     
diff --git a/Main/System/Battle/UIComp/BattleHeroInfoBar.cs b/Main/System/Battle/UIComp/BattleHeroInfoBar.cs
index 0fa6f19..95cdf7f 100644
--- a/Main/System/Battle/UIComp/BattleHeroInfoBar.cs
+++ b/Main/System/Battle/UIComp/BattleHeroInfoBar.cs
@@ -94,13 +94,20 @@
         long curHp = battleObject.teamHero.curHp;
         long maxHp = battleObject.teamHero.maxHp;
         
+        // 璁板綍璁剧疆鍓嶇殑鎶ょ浘鍊�
+        float oldShield1Value = sliderShield1.value;
+        float oldShield2Value = sliderShield2.value;
+        
         // 鎶ょ浘1鐨勫�� = min(褰撳墠琛�閲� + 鎶ょ浘鍊�, maxHp) / maxHp
         float shield1Value = maxHp > 0 ? Mathf.Min((float)(curHp + shieldValue), (float)maxHp) / (float)maxHp : 0;
         // 鎶ょ浘2鐨勫�� = max(褰撳墠琛�閲� + 鎶ょ浘鍊� - maxHp, 0) / maxHp
         float shield2Value = maxHp > 0 ? Mathf.Max((float)(curHp + shieldValue - maxHp), 0f) / (float)maxHp : 0;
         
-        sliderShield1.value = shield1Value;
-        sliderShield2.value = shield2Value;
+        sliderShield1.value = shieldValue > 0 ? shield1Value : 0;
+        sliderShield2.value = shieldValue > maxHp ? shield2Value : 0;
+        
+        // 鎵撳嵃璁剧疆鎶ょ浘鏃剁殑鐘舵��
+        // Debug.LogError($"[BattleHeroInfoBar.SetBattleObject] 璁剧疆鎶ょ浘 - curHp: {curHp}, shieldValue: {shieldValue}, maxHp: {maxHp}, shield1鍓�: {oldShield1Value}, shield1鍚�: {shield1Value}, shield2鍓�: {oldShield2Value}, shield2鍚�: {shield2Value}");
     }
     
     public void SetActive(bool active)
@@ -131,13 +138,23 @@
         long curHp = battleObject.teamHero.curHp;
         long maxHp = battleObject.teamHero.maxHp;
         
+        // 璁板綍璁剧疆鍓嶇殑鎶ょ浘鍊�
+        float oldShield1Value = sliderShield1.value;
+        float oldShield2Value = sliderShield2.value;
+    
         // 鎶ょ浘1鐨勫�� = min(褰撳墠琛�閲� + 鎶ょ浘鍊�, maxHp) / maxHp
         float shield1Value = maxHp > 0 ? Mathf.Min((float)(curHp + shieldValue), (float)maxHp) / (float)maxHp : 0;
         // 鎶ょ浘2鐨勫�� = max(褰撳墠琛�閲� + 鎶ょ浘鍊� - maxHp, 0) / maxHp
         float shield2Value = maxHp > 0 ? Mathf.Max((float)(curHp + shieldValue - maxHp), 0f) / (float)maxHp : 0;
         
-        sliderShield1.value = shield1Value;
-        sliderShield2.value = shield2Value;
+        sliderShield1.value = shieldValue > 0 ? shield1Value : 0;
+        sliderShield2.value = shieldValue > maxHp ? shield2Value : 0;
+
+        UpdateHP(curHp, curHp, maxHp, false);
+        
+    
+        // 鎵撳嵃鍒锋柊鎶ょ浘鏃剁殑鐘舵��
+        // Debug.LogError($"[BattleHeroInfoBar.RefreshBuff] 璁剧疆鎶ょ浘 - curHp: {curHp}, shieldValue: {shieldValue}, maxHp: {maxHp}, shield1鍓�: {oldShield1Value}, shield1鍚�: {shield1Value}, shield2鍓�: {oldShield2Value}, shield2鍚�: {shield2Value}");
     }
     
     /// <summary>

--
Gitblit v1.8.0