From 94ed2a3e8405a9dbd5025ef1c2dbd83c1ccf7305 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期三, 26 十一月 2025 16:54:50 +0800
Subject: [PATCH] 125 战斗 boss血条在最后的时候百分比没有更新的问题

---
 Main/Component/UI/Common/BossLifeBar.cs |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/Main/Component/UI/Common/BossLifeBar.cs b/Main/Component/UI/Common/BossLifeBar.cs
index 9d1ffb6..1e87bd4 100644
--- a/Main/Component/UI/Common/BossLifeBar.cs
+++ b/Main/Component/UI/Common/BossLifeBar.cs
@@ -116,7 +116,11 @@
     static StringBuilder stringBuild = new StringBuilder();
     private void UpdateSurplusSegments(float _targetValue)
     {
-        var currentSurplus = Mathf.CeilToInt(_targetValue);
+        const float eps = 1e-5f;
+        // 娣诲姞杩欎竴琛岋細濡傛灉鍊煎お灏忥紝鐩存帴褰撲綔 0 澶勭悊
+        if (_targetValue < eps) _targetValue = 0f;
+        
+        var currentSurplus = _targetValue < eps ? 0 : Mathf.CeilToInt(_targetValue);
         if (currentSurplus != surplusSegments)
         {
             surplusSegments = currentSurplus;
@@ -131,7 +135,8 @@
             m_BackGround.SetActive(surplusSegments > 1);
 
             m_Surplus.text = "x" + surplusSegments.ToString();
-            float pct = totalSegments > 0 ? Mathf.Clamp01(_targetValue / totalSegments) : 0f;
+            // 淇敼杩欓噷锛氫娇鐢� targetValue锛堟渶缁堢洰鏍囧�硷級鑰屼笉鏄� _targetValue锛堝綋鍓嶈繃娓″�硷級
+            float pct = totalSegments > 0 ? Mathf.Clamp01(targetValue / totalSegments) : 0f;
             // 淇鏍煎紡骞跺鐞嗘帴杩� 100% 鐨勬儏鍐�
             if (1f - pct < 0.00005f) pct = 1f;
             m_SurplusPercent.text = (pct * 100f).ToString("F2") + "%";

--
Gitblit v1.8.0