From f1e5df1fc8eadd0eb27e0a6870501fa25a42b5a1 Mon Sep 17 00:00:00 2001
From: lcy <1459594991@qq.com>
Date: 星期三, 12 十一月 2025 11:13:53 +0800
Subject: [PATCH] 262 修复切换服务器报错

---
 Main/System/Battle/BattleObject/BattleObject.cs |  149 ++++++++++++++++++++++++++++++++-----------------
 1 files changed, 96 insertions(+), 53 deletions(-)

diff --git a/Main/System/Battle/BattleObject/BattleObject.cs b/Main/System/Battle/BattleObject/BattleObject.cs
index 89714c3..723bb12 100644
--- a/Main/System/Battle/BattleObject/BattleObject.cs
+++ b/Main/System/Battle/BattleObject/BattleObject.cs
@@ -48,7 +48,7 @@
         private set;
     }
 
-    protected BattleDrops battleDrops;
+    protected BattleDrops m_battleDrops;
 
     private RectTransform m_heroRectTrans;
 
@@ -87,6 +87,8 @@
         buffMgr = new BattleObjectBuffMgr();
         buffMgr.Init(this);
 
+        buffMgr.onIsControlChanged += OnControledChange;
+
         layerMgr = new BattleObjectLayerMgr();
         layerMgr.Init(this);
 
@@ -99,8 +101,15 @@
         var heroInfoBarScale = heroInfoBar.transform.localScale;
         heroInfoBarScale.x *= Camp == BattleCamp.Red ? 1 : -1;
         heroInfoBar.transform.localScale = heroInfoBarScale;
-
-        heroInfoBar.SetActive(true);
+        if (battleField is StoryBattleField && (battleField as StoryBattleField).battleState == StoryBattleState.Break)
+        {
+            //涓荤嚎鍏冲崱浼戞伅涓殑涓嶆樉绀鸿鏉�
+            heroInfoBar.SetActive(false);
+        }
+        else
+        {
+            heroInfoBar.SetActive(true);
+        }
         SetFront();
     }
 
@@ -127,6 +136,9 @@
 
         motionBase.Release();
         motionBase = null;
+        buffMgr.onIsControlChanged -= OnControledChange;
+        buffMgr.Release();
+        buffMgr = null;
         teamHero = null;
         ObjID = 0;
 
@@ -137,18 +149,40 @@
         }
     }
 
+    //  鏈夊彉鍖栦簡鎵嶄細璋冪敤杩欎釜鍑芥暟
+    private void OnControledChange(int groupType, bool value)
+    {
+        //  杩欓噷鏄彈鍒扮‖鎺ф椂鍊� 闇�瑕佽〃鐜扮殑鍔ㄧ敾
+        if (groupType == BattleConst.HardControlGroup)
+        {
+            //  浠庢病琚‖鎺у埌琚‖鎺�
+            if (value)
+            {
+                motionBase.SetControledAnimation();
+            }
+            else
+            {
+                motionBase.CancelControledAnimation();
+            }
+        }
+    }
+
     public void OnObjInfoRefresh(H0418_tagObjInfoRefresh _refreshInfo)
     {
+        // 澶╁瓙鐨勬寫鎴樻嫤鎴鏉�,涓嶆嫤鎴�掓皵
+        BattleObject boss = battleField.FindBoss();
+        if (boss != null && battleField.MapID == 30020 && boss.ObjID == _refreshInfo.ObjID && _refreshInfo.RefreshType != (ushort)PlayerDataType.XP)
+            return;
         switch ((PlayerDataType)_refreshInfo.RefreshType)
         {
             case PlayerDataType.HP:
                 long toHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
-                heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp);
+                heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp, false);
                 teamHero.curHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
                 break;
             case PlayerDataType.MaxHP:
                 teamHero.maxHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
-                heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp);
+                heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp, false);
                 break;
             case PlayerDataType.XP:
                 long toXp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
@@ -163,16 +197,20 @@
 
     public void ObjPropertyRefreshView(HB418_tagSCObjPropertyRefreshView vNetData)
     {
+        // 澶╁瓙鐨勬寫鎴樻嫤鎴鏉�,涓嶆嫤鎴�掓皵
+        BattleObject boss = battleField.FindBoss();
+        if (boss != null && battleField.MapID == 30020 && boss.ObjID == vNetData.ObjID && vNetData.RefreshType != (ushort)PlayerDataType.XP)
+            return;
         switch ((PlayerDataType)vNetData.RefreshType)
         {
             case PlayerDataType.HP:
                 long toHp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx);
-                heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp);
+                heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp, false);
                 teamHero.curHp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx);
                 break;
             case PlayerDataType.MaxHP:
                 teamHero.maxHp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx);
-                heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp);
+                heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp, false);
                 break;
             case PlayerDataType.XP:
                 long toXp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx);
@@ -268,17 +306,15 @@
         return true;
     }
 
-    public virtual void Hurt(List<long> damageValues, long _totalDamage,
-        HB427_tagSCUseSkill.tagSCUseSkillHurt hurt, SkillConfig skillConfig, int hitIndex,
-        BattleDrops battleDrops, HB422_tagMCTurnFightObjDead deadPack)
+    public virtual void Hurt(BattleHurtParam battleHurtParam)
     {
-        bool isLastHit = hitIndex >= skillConfig.DamageDivide.Length - 1;
-        bool firstHit = hitIndex == 0;
-        BattleDmgInfo dmgInfo = PopDamage(damageValues, _totalDamage, hurt, skillConfig, isLastHit);
+        bool isLastHit = battleHurtParam.hitIndex >= battleHurtParam.skillConfig.DamageDivide.Length - 1;
+        bool firstHit = battleHurtParam.hitIndex == 0;
+        BattleDmgInfo dmgInfo = PopDamage(battleHurtParam);
 
 
         //  杩欓噷
-        if (dmgInfo.IsType(DamageType.Dodge))
+        if (dmgInfo.IsType(DamageType.Dodge) && !buffMgr.isControled[BattleConst.HardControlGroup])
         {
             if (isLastHit)
             {
@@ -292,36 +328,37 @@
             }
         }
 
-        bool isFatalAttack = (null != deadPack) && isLastHit;
+
+
+        bool isFatalAttack = (null != battleHurtParam.deadPack) && isLastHit;
 
         if (isFatalAttack)
         {
-            if (null != battleDrops)
+            if (null != battleHurtParam.battleDrops)
             {
-                PushDropItems(battleDrops);
+                PushDropItems(battleHurtParam.battleDrops);
             }
-            battleField.OnObjsDead(new List<HB422_tagMCTurnFightObjDead>() { deadPack });
-            
+            battleField.OnObjsDead(new List<HB422_tagMCTurnFightObjDead>() { battleHurtParam.deadPack });
+
         }
         else
         {
-            if ((dmgInfo.IsType(DamageType.Damage) || dmgInfo.IsRealdamage()))
+            if (dmgInfo.IsType(DamageType.Block))
             {
-                motionBase.PlayAnimation(MotionName.hit, false);
+                battleField.battleEffectMgr.PlayEffect(this, 19999, heroRectTrans, Camp);
             }
+            else
+            {
+                if ((dmgInfo.IsType(DamageType.Damage) || dmgInfo.IsRealdamage()))
+                {
+                    if (!buffMgr.isControled[BattleConst.HardControlGroup])
+                    {
+                        motionBase.PlayAnimation(MotionName.hit, false);
+                    }
+                }
+            }
+
         }
-
-
-    }
-
-    public void SuckHp(uint suckHP, SkillConfig skillConfig)
-    {
-        teamHero.curHp = Math.Min(teamHero.maxHp, teamHero.curHp + (int)suckHP);
-    }
-
-    public void HurtByReflect(uint bounceHP, SkillConfig skillConfig)
-    {
-        teamHero.curHp = Math.Max(0, teamHero.curHp - (int)bounceHP);
     }
 
 
@@ -334,6 +371,12 @@
             .SetEase(Ease.OutCubic);
 
         motionBase.ShowIllusionShadow(true);
+
+        DamageNumConfig damageNumConfig = DamageNumConfig.Get((int)DamageType.Dodge);
+
+        string dodgeStr = ((char)damageNumConfig.prefix).ToString();
+
+        heroInfoBar.ShowTips(dodgeStr, true, false);
 
         tween.onComplete += () =>
         {
@@ -386,26 +429,25 @@
     }
 
     // 浼ゅ杩樿鐪� 鏄惁闂伩 鏆村嚮 and so on 闇�瑕佹湁涓�涓狣amageType 鏈嶅姟鍣ㄥ簲璇ヤ細缁�
-    protected virtual BattleDmgInfo PopDamage(List<long> damageValues, long _totalDamage, HB427_tagSCUseSkill.tagSCUseSkillHurt hurt, SkillConfig skillConfig, bool isLastHit)
+    protected virtual BattleDmgInfo PopDamage(BattleHurtParam battleHurtParam)
     {
-        BattleDmgInfo battleDmgInfo = new BattleDmgInfo(battleField.guid, damageValues, this, hurt, skillConfig, isLastHit);
-
-        int currentHurtHp = 0;
-        for (int i = 0; i < damageValues.Count; i++)
+        BattleDmgInfo battleDmgInfo = new BattleDmgInfo(battleField.guid, battleHurtParam);
+        // 澶╁瓙鐨勬寫鎴樻嫤鎴鏉¢�昏緫
+        BattleObject boss = battleField.FindBoss();
+        if (boss != null && battleField.MapID == 30020 && boss.ObjID == battleHurtParam.hurtObj.ObjID)
         {
-            currentHurtHp += (int)damageValues[i];
+            EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo);
+            return battleDmgInfo;
+        }
+        else
+        {
+            heroInfoBar.UpdateDamage(battleDmgInfo);
+
+            // YYL TODO 鏄惁闇�瑕佹寕鍦ㄥ湪鑷韩鐨刦ollow鐐逛笂
+            EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo);
+            return battleDmgInfo;
         }
 
-        bool isRecovery = battleDmgInfo.IsType(DamageType.Recovery);
-
-        long toHp = Math.Max(0, teamHero.curHp + (isRecovery ? currentHurtHp : -currentHurtHp));
-
-        heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp);
-        teamHero.curHp = toHp;
-
-        // YYL TODO 鏄惁闇�瑕佹寕鍦ㄥ湪鑷韩鐨刦ollow鐐逛笂
-        EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo);
-        return battleDmgInfo;
     }
 
     public RectTransform GetAliasTeamNode()
@@ -438,21 +480,21 @@
 
     public void PushDropItems(BattleDrops _battleDrops)
     {
-        battleDrops = _battleDrops;
+        m_battleDrops = _battleDrops;
     }
 
     public void PerformDrop()
     {
-        if (null == battleDrops || battleDrops.dropItemPackIndex.Count == 0)
+        if (null == m_battleDrops)
             return;
 
         EventBroadcast.Instance.Broadcast<string, BattleDrops, Action>(
-            EventName.BATTLE_DROP_ITEMS, battleField.guid, battleDrops, OnPerformDropFinish);
+            EventName.BATTLE_DROP_ITEMS, battleField.guid, m_battleDrops, OnPerformDropFinish);
     }
 
     protected void OnPerformDropFinish()
     {
-        battleDrops = null;
+        m_battleDrops = null;
     }
 
     public void SetBack()
@@ -468,6 +510,7 @@
     public void SetSpeedRatio(float ratio)
     {
         motionBase.SetSpeedRatio(ratio);
+        heroInfoBar.SetSpeedRatio(ratio);
     }
 
 

--
Gitblit v1.8.0