From aa84cb62bebb9c8a4e586bcc1ec28eb7a16a8860 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期一, 26 一月 2026 18:10:34 +0800
Subject: [PATCH] 422 子 【内政】命格系统 / 【内政】命格系统-客户端

---
 Main/System/Battle/BattleObject/BattleObject.cs |  221 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 200 insertions(+), 21 deletions(-)

diff --git a/Main/System/Battle/BattleObject/BattleObject.cs b/Main/System/Battle/BattleObject/BattleObject.cs
index aaa26c9..7e84f50 100644
--- a/Main/System/Battle/BattleObject/BattleObject.cs
+++ b/Main/System/Battle/BattleObject/BattleObject.cs
@@ -72,6 +72,8 @@
     private List<HB405_tagMCAddExp> hB405_tagMCAddExps = new List<HB405_tagMCAddExp>();
     public BattleHeroInfoBar heroInfoBar;
 
+    public bool isReborning = false;
+
     public BattleObject(BattleField _battleField)
     {
         battleField = _battleField;
@@ -177,12 +179,19 @@
         {
             case PlayerDataType.HP:
                 long toHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
-                heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp, false);
+                if (!IsTianziBoss())
+                {
+                    heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp, false);
+                }
                 teamHero.curHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
+                // Debug.LogError("OnObjInfoRefresh " + teamHero.curHp);
                 break;
             case PlayerDataType.MaxHP:
                 teamHero.maxHp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
-                heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp, false);
+                if (!IsTianziBoss())
+                {
+                    heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp, false);
+                }
                 break;
             case PlayerDataType.XP:
                 long toXp = GeneralDefine.GetFactValue(_refreshInfo.Value, _refreshInfo.ValueEx);
@@ -306,19 +315,31 @@
         return true;
     }
 
-    public virtual void Hurt(BattleHurtParam battleHurtParam)
+    public virtual DeathRecordAction Hurt(BattleHurtParam battleHurtParam, RecordAction _causingRecordAction = null)
     {
+        DeathRecordAction recordAction = null;
         bool isLastHit = battleHurtParam.hitIndex >= battleHurtParam.skillConfig.DamageDivide.Length - 1;
         bool firstHit = battleHurtParam.hitIndex == 0;
+        
+        // 娣诲姞璋冭瘯鏃ュ織
+        bool isHealing = BattleUtility.IsHealing(battleHurtParam.hurt);
+    
         BattleDmgInfo dmgInfo = PopDamage(battleHurtParam);
 
 
+        // ============ 搴旂敤鐩爣鐨勮閲忓拰鎶ょ浘鍙樺寲 ============
+        ApplyHurtToTarget(battleHurtParam, isLastHit);
+
         //  杩欓噷
-        if (dmgInfo.IsType(DamageType.Dodge) && !buffMgr.isControled[BattleConst.HardControlGroup])
+        if (dmgInfo.IsType(DamageType.Dodge) /*&& !buffMgr.isControled[BattleConst.HardControlGroup]*/)//濡傛灉琚帶鍒朵簡杩橀棯閬夸簡 瑕佺湅鐪嬫湇鍔″櫒鎬庝箞澶勭悊浜�
         {
             if (isLastHit)
             {
                 DodgeFinishAction dodgeFinish = new DodgeFinishAction(battleField, this);
+                // 銆愪娇鐢� BattleField.recordPlayer銆�
+                // 鍘熷洜锛氶棯閬垮畬鎴愬姩浣滄槸鐩爣瑙掕壊鐨勭嫭绔嬭涓猴紝涓嶆槸鎶�鑳藉唴閮ㄤ骇鐢熺殑
+                // 铏界劧鏄湪Hurt杩囩▼涓Е鍙戯紝浣嗘槸闂伩鍔ㄤ綔鏈韩鏄洰鏍囩殑鍙嶅簲锛屽簲璇ョ敱涓籖ecordPlayer绠$悊
+                // 浣跨敤InsertRecord鍙互鎻掑埌闃熷垪鏈�鍓嶉潰锛屼繚璇侀棯閬胯〃鐜扮殑浼樺厛绾�
                 battleField.recordPlayer.InsertRecord(dodgeFinish);
             }
 
@@ -328,8 +349,6 @@
             }
         }
 
-
-
         bool isFatalAttack = (null != battleHurtParam.deadPack) && isLastHit;
 
         if (isFatalAttack)
@@ -338,14 +357,14 @@
             {
                 PushDropItems(battleHurtParam.battleDrops);
             }
-            battleField.OnObjsDead(new List<HB422_tagMCTurnFightObjDead>() { battleHurtParam.deadPack });
+            recordAction = battleField.OnObjsDead(new List<BattleDeadPack>() { battleHurtParam.deadPack }, _causingRecordAction);
 
         }
         else
         {
             if (dmgInfo.IsType(DamageType.Block))
             {
-                battleField.battleEffectMgr.PlayEffect(this, 19999, heroRectTrans, Camp);
+                battleField.battleEffectMgr.PlayEffect(this, BattleConst.BlockEffectID, heroRectTrans, Camp, teamHero.modelScale);
             }
             // else
             // {
@@ -353,14 +372,41 @@
             {
                 if (!buffMgr.isControled[BattleConst.HardControlGroup])
                 {
+                    battleField.soundManager.PlayEffectSound(teamHero.heroConfig.HitSFX, false);
                     motionBase.PlayAnimation(MotionName.hit, false);
                 }
             }
             // }
 
         }
+
+        return recordAction;
     }
 
+    /// <summary>
+    /// 搴旂敤鐩爣鐨勮閲忓拰鎶ょ浘鍙樺寲
+    /// </summary>
+    private void ApplyHurtToTarget(BattleHurtParam battleHurtParam, bool isLastHit)
+    {
+        BattleHurtObj hurter = battleHurtParam.hurter;
+        
+        // 搴旂敤琛�閲忓彉鍖�
+        teamHero.curHp = hurter.toHp;
+        
+        // foreach (var obj in battleField.battleObjMgr.allBattleObjDict.Values)
+        // {
+        //     Debug.LogError($"[ApplyHurtToTarget] ObjID: {obj.ObjID}, Name: {obj.teamHero.heroConfig.Name}, CurHp: {obj.teamHero.curHp}, MaxHp: {obj.teamHero.maxHp} Skill {battleHurtParam.hB427_TagSCUseSkill.packUID} ");
+        // }
+
+
+#if UNITY_EDITOR
+        // 鏈�鍚庝竴鍑绘椂楠岃瘉琛�閲忔槸鍚︿笌鏈嶅姟鍣ㄤ竴鑷�
+        if (isLastHit)
+        {
+            BattleUtility.ValidateHpConsistency(battleHurtParam, "鐩爣鍙椾激");
+        }
+#endif
+    }
 
     const float pingpongTime = 0.4f;
     //  闂伩寮�濮�
@@ -383,6 +429,9 @@
             motionBase.ShowIllusionShadow(false);
         };
 
+
+        battleField.soundManager.PlayEffectSound(BattleConst.DodgeSoundID);
+
         battleField.battleTweenMgr.OnPlayTween(tween);
     }
 
@@ -402,15 +451,29 @@
         battleField.battleTweenMgr.OnPlayTween(tween);
     }
 
-    public virtual void OnDeath(Action _onDeathAnimationComplete)
+    public virtual void OnDeath(Action _onDeathAnimationComplete, bool withoutAnime = false)
     {
         buffMgr.RemoveAllBuff();
-        motionBase.PlayAnimation(MotionName.dead, false, () =>
+        battleField.soundManager.PlayEffectSound(teamHero.heroConfig.DeathSFX, false);
+        if (withoutAnime)
         {
-            teamHero.isDead = true;
-            OnDeadAnimationComplete();
+            SetDeath();
             _onDeathAnimationComplete?.Invoke();
-        });
+        }
+        else
+        {
+            motionBase.PlayDeadAnimation(() =>
+            {
+                SetDeath();
+                _onDeathAnimationComplete?.Invoke();
+            });
+        }
+    }
+
+    public void SetDeath()
+    {
+        teamHero.isDead = true;
+        OnDeadAnimationComplete();
     }
 
     protected virtual void OnDeadAnimationComplete()
@@ -422,13 +485,35 @@
         buffMgr.RemoveAllBuff();
     }
 
-    public void OnReborn(HB423_tagMCTurnFightObjReborn vNetData)
+    //  閲婃斁鑰呭氨鏄娲昏�呮椂璋冪敤
+    public void PreReborn(bool reviveSelf = false)
     {
-        // 澶勭悊澶嶆椿閫昏緫
-        teamHero.curHp = GeneralDefine.GetFactValue(vNetData.HP, vNetData.HPEx);
         heroGo.SetActive(true);
-        motionBase.PlayAnimation(MotionName.idle, true);
+        motionBase.skeletonAnim.skeleton.A = 0f;
+        motionBase.skeletonAnim.LateUpdate();
+        heroRectTrans.anchoredPosition = Vector2.zero;
+        motionBase.ResetForReborn(reviveSelf);
     }
+
+    //  澶嶆椿action
+    public void OnReborn(HB427_tagSCUseSkill.tagSCUseSkillHurt vNetData, bool reviveSelf = false, RecordAction parentAction = null)
+    {
+        isReborning = true;
+        heroGo.SetActive(true);
+        motionBase.ResetForReborn(reviveSelf);
+        heroRectTrans.anchoredPosition = Vector2.zero;
+        motionBase.skeletonAnim.skeleton.A = 0f;
+        motionBase.skeletonAnim.LateUpdate();
+
+    }
+
+    public void AfterReborn()
+    {
+        //  娓呯┖鎵�鏈�
+        motionBase.ResetForReborn(false);
+        isReborning = false;
+    }
+
 
     // 浼ゅ杩樿鐪� 鏄惁闂伩 鏆村嚮 and so on 闇�瑕佹湁涓�涓狣amageType 鏈嶅姟鍣ㄥ簲璇ヤ細缁�
     protected virtual BattleDmgInfo PopDamage(BattleHurtParam battleHurtParam)
@@ -436,7 +521,8 @@
         BattleDmgInfo battleDmgInfo = new BattleDmgInfo(battleField.guid, battleHurtParam);
         // 澶╁瓙鐨勬寫鎴樻嫤鎴鏉¢�昏緫
         BattleObject boss = battleField.FindBoss();
-        if (boss != null && battleField.MapID == 30020 && boss.ObjID == battleHurtParam.hurtObj.ObjID)
+        // 淇锛歜attleHurtParam.hurtObj.ObjID -> battleHurtParam.hurter.hurtObj.ObjID
+        if (boss != null && battleField.MapID == 30020 && boss.ObjID == battleHurtParam.hurter.hurtObj.ObjID)
         {
             EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo);
             return battleDmgInfo;
@@ -450,6 +536,28 @@
             return battleDmgInfo;
         }
 
+    }
+
+    /// <summary>
+    /// 涓烘柦娉曡�呭垱寤轰激瀹充俊鎭紙鍚歌/鍙嶄激锛�
+    /// </summary>
+    protected virtual BattleDmgInfo PopDamageForCaster(BattleHurtParam battleHurtParam)
+    {
+        // 浼犲叆 isCasterView=true 琛ㄧず杩欐槸鏂芥硶鑰呰瑙�
+        BattleDmgInfo battleDmgInfo = new BattleDmgInfo(battleField.guid, battleHurtParam, _isCasterView: true);
+        
+        BattleObject boss = battleField.FindBoss();
+        if (boss != null && battleField.MapID == 30020 && boss.ObjID == this.ObjID)
+        {
+            EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo);
+            return battleDmgInfo;
+        }
+        else
+        {
+            heroInfoBar.UpdateDamage(battleDmgInfo);
+            EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo);
+            return battleDmgInfo;
+        }
     }
 
     public RectTransform GetAliasTeamNode()
@@ -475,8 +583,9 @@
         heroGo.SetActive(true);
         motionBase.HaveRest();
         heroRectTrans.anchoredPosition = Vector2.zero;
+        heroInfoBar.HaveRest();
+        isReborning = false;
 
-        heroInfoBar.SetActive(false);
         SetFront();
     }
 
@@ -543,12 +652,20 @@
         {
             case PlayerDataType.HP:
                 long toHp = GeneralDefine.GetFactValue(vNetData.Value, vNetData.ValueEx);
-                heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp, true);
+                bool isMinus = teamHero.curHp > toHp;
+                if (!IsTianziBoss())
+                {
+                    heroInfoBar.UpdateHP(teamHero.curHp, toHp, teamHero.maxHp, false);
+                }
                 teamHero.curHp = newValue;
+                // Debug.LogError("OnObjPropertyRefreshView " + teamHero.curHp);
                 break;
             case PlayerDataType.MaxHP:
                 teamHero.maxHp = newValue;
-                heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp, true);
+                if (!IsTianziBoss())
+                {
+                    heroInfoBar.UpdateHP(teamHero.curHp, teamHero.curHp, teamHero.maxHp, false);
+                }
                 break;
             case PlayerDataType.XP:
                 long toXp = newValue;
@@ -601,4 +718,66 @@
     }
 #endif
 
+    // BattleObject.cs
+
+    public virtual void OnHurtTarget(BattleHurtParam battleHurtParam)
+    {
+        // 妫�鏌ユ槸鍚︽湁鍚歌鎴栧弽浼�
+        bool hasSuckHp = battleHurtParam.caster.suckHpList != null && battleHurtParam.caster.suckHpList.Count > 0;
+        bool hasReflectHp = battleHurtParam.caster.reflectHpList != null && battleHurtParam.caster.reflectHpList.Count > 0;
+        
+        if (!hasSuckHp && !hasReflectHp)
+        {
+            return;
+        }
+
+        // ============ 搴旂敤鏂芥硶鑰呯殑琛�閲忓拰鎶ょ浘鍙樺寲 ============
+        bool isLastHit = battleHurtParam.hitIndex >= battleHurtParam.skillConfig.DamageDivide.Length - 1;
+        ApplyHurtToCaster(battleHurtParam, isLastHit);
+
+        // 鍜孒urt涓�鏍凤紝璋冪敤PopDamage澶勭悊鍚歌/鍙嶄激鐨勬樉绀�
+        BattleDmgInfo casterDmgInfo = PopDamageForCaster(battleHurtParam);
+        
+        // 濡傛灉鏈夊弽浼わ紝鏂芥硶鑰呮挱鏀惧彈鍑诲姩鐢�
+        if (hasReflectHp && casterDmgInfo.casterDamageList != null && casterDmgInfo.casterDamageList.Count > 0)
+        {
+            long totalReflect = casterDmgInfo.casterDamageList.Sum(d => d.damage);
+            if (totalReflect > 0 && !buffMgr.isControled[BattleConst.HardControlGroup])
+            {
+                motionBase.PlayAnimation(MotionName.hit, false);
+            }
+        }
+    }
+
+    /// <summary>
+    /// 搴旂敤鏂芥硶鑰呯殑琛�閲忓拰鎶ょ浘鍙樺寲锛堝惛琛�鍜屽弽浼わ級
+    /// </summary>
+    private void ApplyHurtToCaster(BattleHurtParam battleHurtParam, bool isLastHit)
+    {
+        BattleCastObj caster = battleHurtParam.caster;
+        
+        // 搴旂敤琛�閲忓彉鍖�
+        teamHero.curHp = caster.toHp;
+
+        //  鎵撳嵃鎵�鏈夎鑹茬殑鍚嶅瓧鍜屽綋鍓嶈閲忚窡鎬昏閲�
+        // foreach (var obj in battleField.battleObjMgr.allBattleObjDict.Values)
+        // {
+        //     Debug.LogError($"[ApplyHurtToCaster] ObjID: {obj.ObjID}, Name: {obj.teamHero.heroConfig.Name}, CurHp: {obj.teamHero.curHp}, MaxHp: {obj.teamHero.maxHp} Skill {battleHurtParam.hB427_TagSCUseSkill.packUID} " );
+        // }
+        
+        // 鎶ょ浘鍊肩敱buff绯荤粺鑷姩绠$悊锛屼笉闇�瑕佹墜鍔ㄨ缃�
+        
+#if UNITY_EDITOR
+        // 鏈�鍚庝竴鍑绘椂楠岃瘉琛�閲忔槸鍚︿笌鏈嶅姟鍣ㄤ竴鑷�
+        if (isLastHit)
+        {
+            BattleUtility.ValidateHpConsistencyForCaster(battleHurtParam, "鏂芥硶鑰呭惛琛�/鍙嶄激");
+        }
+#endif
+    }
+
+    public bool IsTianziBoss()
+    {
+        return battleField.MapID == 30020 && battleField.FindBoss() == this;
+    }
 }
\ No newline at end of file

--
Gitblit v1.8.0