From 27874500782d2b516ad8eacbbc22db81bfac7bb0 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期一, 22 十二月 2025 19:34:07 +0800
Subject: [PATCH] 125 战斗 血量回弹问题处理
---
Main/System/Battle/BattleObject/BattleObject.cs | 6 +-
Main/System/Battle/UIComp/BattleHeroInfoBar.cs | 60 +++++++-----------------------
2 files changed, 17 insertions(+), 49 deletions(-)
diff --git a/Main/System/Battle/BattleObject/BattleObject.cs b/Main/System/Battle/BattleObject/BattleObject.cs
index ba7f7e0..bc79bbf 100644
--- a/Main/System/Battle/BattleObject/BattleObject.cs
+++ b/Main/System/Battle/BattleObject/BattleObject.cs
@@ -654,10 +654,10 @@
{
case PlayerDataType.HP:
long toHp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx);
-
+ bool isMinus = teamHero.curHp > toHp;
if (!IsTianziBoss())
{
- heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp, true);
+ heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp, false);
}
teamHero.curHp = newValue;
// Debug.LogError("OnObjPropertyRefreshView " + teamHero.curHp);
@@ -666,7 +666,7 @@
teamHero.maxHp = newValue;
if (!IsTianziBoss())
{
- heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp, true);
+ heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp, false);
}
break;
case PlayerDataType.XP:
diff --git a/Main/System/Battle/UIComp/BattleHeroInfoBar.cs b/Main/System/Battle/UIComp/BattleHeroInfoBar.cs
index 5ccd517..83fbfa1 100644
--- a/Main/System/Battle/UIComp/BattleHeroInfoBar.cs
+++ b/Main/System/Battle/UIComp/BattleHeroInfoBar.cs
@@ -26,16 +26,6 @@
public bool isRage = false;
}
- /// <summary>
- /// 琛�鏉℃洿鏂拌姹�
- /// </summary>
- private class HpUpdateRequest
- {
- public long fromHp;
- public long toHp;
- public long maxHp;
- public bool tween;
- }
[Header("UI Components")]
public Slider sliderHp;
@@ -70,7 +60,6 @@
protected Tween shieldTween2;
protected Sequence damageSequence;
- private Queue<HpUpdateRequest> hpUpdateQueue = new Queue<HpUpdateRequest>();
private Queue<BattleDmgInfo> damageUpdateQueue = new Queue<BattleDmgInfo>();
// 椋樺瓧GCD鐩稿叧
@@ -162,10 +151,10 @@
sliderShield1.value = shield1Value;
sliderShield2.value = shield2Value;
- if (!battleObject.IsTianziBoss())
- {
- UpdateHP(curHp, curHp, maxHp, false);
- }
+ // if (!battleObject.IsTianziBoss())
+ // {
+ // UpdateHP(curHp, curHp, maxHp, false);
+ // }
// 鎵撳嵃鍒锋柊鎶ょ浘鏃剁殑鐘舵��
@@ -199,27 +188,12 @@
/// </summary>
public void UpdateHP(long fromHp, long toHp, long maxHp, bool tween = true)
{
- // 鍔犲叆闃熷垪
- hpUpdateQueue.Enqueue(new HpUpdateRequest
- {
- fromHp = fromHp,
- toHp = toHp,
- maxHp = maxHp,
- tween = tween
- });
- }
-
- /// <summary>
- /// 瀹為檯鎵ц琛�閲忔洿鏂�
- /// </summary>
- private void ExecuteHpUpdate(HpUpdateRequest request)
- {
KillTween(ref hpTween);
- float fromValue = (float)request.fromHp / (float)request.maxHp;
- float targetValue = (float)request.toHp / (float)request.maxHp;
+ float fromValue = (float)fromHp / (float)maxHp;
+ float targetValue = (float)toHp / (float)maxHp;
- if (request.tween)
+ if (tween)
{
sliderHp.value = fromValue;
hpTween = sliderHp.DOValue(targetValue, 0.3f).SetAutoKill(false);
@@ -230,6 +204,7 @@
sliderHp.value = targetValue;
}
}
+
/// <summary>
/// !!!涓存椂鐨勭敤浜庡ぉ瀛愭洿鏂拌閲忔樉绀�,绛夋帴鍙e畬鍠勫悗鍒犻櫎
@@ -479,15 +454,15 @@
// 璁板綍鎵�鏈塸ackUID鐨勬暟鎹紙鍖呮嫭鏃╄Е鍙戠殑鍖咃級锛屼絾鍙噰鐢ㄦ渶澶ackUID鐨勬暟鎹�
// 璁板綍鏂芥硶鑰呯殑琛�閲忓彉鍖�
- if (dmgInfo.battleHurtParam.caster?.casterObj != null)
+ BattleCastObj battleCastObj = dmgInfo.battleHurtParam.caster;
+ if (battleCastObj != null && battleCastObj.casterObj != null)
{
- BattleCastObj caster = dmgInfo.battleHurtParam.caster;
- long casterID = caster.casterObj.ObjID;
+ long casterID = battleCastObj.casterObj.ObjID;
// 鑾峰彇鏃ц閲忕敤浜庤绠楀彉鍖�
- long oldHp = hpDict.ContainsKey(casterID) ? hpDict[casterID] : caster.fromHp;
- long newHp = caster.toHp;
- long maxHp = caster.maxHp;
+ long oldHp = hpDict.ContainsKey(casterID) ? hpDict[casterID] : battleCastObj.fromHp;
+ long newHp = battleCastObj.toHp;
+ long maxHp = battleCastObj.maxHp;
long hpChange = newHp - oldHp;
// 鍙湁褰撳墠packUID绛変簬鏈�澶ackUID鏃舵墠鏇存柊璁板綍
@@ -553,13 +528,6 @@
BattleDmgInfo dmgInfo = damageUpdateQueue.Dequeue();
CompareAndExchangeLargestPackUIDHp(dmgInfo);
ExecuteDamageUpdate(dmgInfo);
- return;
- }
- // 鍏舵澶勭悊UpdateHP
- else if (hpUpdateQueue.Count > 0)
- {
- HpUpdateRequest request = hpUpdateQueue.Dequeue();
- ExecuteHpUpdate(request);
return;
}
}
--
Gitblit v1.8.0