From 3b2a6bb9047cfce9f501593b3669a9c1af6c5df4 Mon Sep 17 00:00:00 2001
From: lcy <1459594991@qq.com>
Date: 星期三, 05 十一月 2025 17:40:23 +0800
Subject: [PATCH] 130 战斗修改回合样式

---
 Main/System/Battle/BattleObject/BattleObject.cs |  151 ++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 120 insertions(+), 31 deletions(-)

diff --git a/Main/System/Battle/BattleObject/BattleObject.cs b/Main/System/Battle/BattleObject/BattleObject.cs
index c9766a1..24b2e63 100644
--- a/Main/System/Battle/BattleObject/BattleObject.cs
+++ b/Main/System/Battle/BattleObject/BattleObject.cs
@@ -32,13 +32,13 @@
 
     public BattleObjectBuffMgr buffMgr;
 
+    public BattleObjectLayerMgr layerMgr;
+
     public int ObjID { get; set; }
 
     public BattleCamp Camp { get; protected set; }
 
     public TeamHero teamHero { get; protected set; }
-
-    // public BuffMgr buffMgr;
 
     public MotionBase motionBase;
 
@@ -83,10 +83,14 @@
         teamHero = _teamHero;
         Camp = _camp;
         motionBase = new MotionBase();
-        motionBase.Init(heroGo.GetComponentInChildren<SkeletonGraphic>(true));
-        motionBase.onAnimationComplete += OnAnimationComplete;
+        motionBase.Init(heroGo.GetComponentInChildren<SkeletonAnimation>(true));
         buffMgr = new BattleObjectBuffMgr();
         buffMgr.Init(this);
+
+        buffMgr.onIsControlChanged += OnControledChange;
+
+        layerMgr = new BattleObjectLayerMgr();
+        layerMgr.Init(this);
 
         renderers = heroGo.GetComponentsInChildren<Renderer>(true);
 
@@ -97,8 +101,9 @@
         var heroInfoBarScale = heroInfoBar.transform.localScale;
         heroInfoBarScale.x *= Camp == BattleCamp.Red ? 1 : -1;
         heroInfoBar.transform.localScale = heroInfoBarScale;
-        
+
         heroInfoBar.SetActive(true);
+        SetFront();
     }
 
 
@@ -106,6 +111,7 @@
     {
         motionBase.Run();
         heroInfoBar.Run();
+        buffMgr.Run();
     }
 
     public virtual void Pause()
@@ -120,10 +126,12 @@
 
     public virtual void Destroy()
     {
-        motionBase.onAnimationComplete -= OnAnimationComplete;
 
         motionBase.Release();
         motionBase = null;
+        buffMgr.onIsControlChanged -= OnControledChange;
+        buffMgr.Release();
+        buffMgr = null;
         teamHero = null;
         ObjID = 0;
 
@@ -131,6 +139,24 @@
         {
             GameObject.DestroyImmediate(heroGo);
             heroGo = null;
+        }
+    }
+
+    //  鏈夊彉鍖栦簡鎵嶄細璋冪敤杩欎釜鍑芥暟
+    private void OnControledChange(int groupType, bool value)
+    {
+        //  杩欓噷鏄彈鍒扮‖鎺ф椂鍊� 闇�瑕佽〃鐜扮殑鍔ㄧ敾
+        if (groupType == BattleConst.HardControlGroup)
+        {
+            //  浠庢病琚‖鎺у埌琚‖鎺�
+            if (value)
+            {
+                motionBase.SetControledAnimation();
+            }
+            else
+            {
+                motionBase.CancelControledAnimation();
+            }
         }
     }
 
@@ -265,31 +291,89 @@
         return true;
     }
 
-    public virtual void Hurt(List<long> damageValues, long _totalDamage, HB427_tagSCUseSkill.tagSCUseSkillHurt hurt, SkillConfig skillConfig)
+    public virtual void Hurt(List<long> damageValues, long _totalDamage,
+        HB427_tagSCUseSkill.tagSCUseSkillHurt hurt, SkillConfig skillConfig, int hitIndex,
+        BattleDrops battleDrops, HB422_tagMCTurnFightObjDead deadPack,
+        long fromHp, long toHp)
     {
-        PopDamage(damageValues, _totalDamage, hurt, skillConfig);
+        bool isLastHit = hitIndex >= skillConfig.DamageDivide.Length - 1;
+        bool firstHit = hitIndex == 0;
+        BattleDmgInfo dmgInfo = PopDamage(damageValues, _totalDamage, hurt, skillConfig, isLastHit, fromHp, toHp);
 
-        motionBase.PlayAnimation(MotionName.hit, false);
 
-    }       
+        //  杩欓噷
+        if (dmgInfo.IsType(DamageType.Dodge) && !buffMgr.isControled[BattleConst.HardControlGroup])
+        {
+            if (isLastHit)
+            {
+                DodgeFinishAction dodgeFinish = new DodgeFinishAction(battleField, this);
+                battleField.recordPlayer.InsertRecord(dodgeFinish);
+            }
+
+            if (firstHit)
+            {
+                OnDodgeBegin();
+            }
+        }
+
+
+
+        bool isFatalAttack = (null != deadPack) && isLastHit;
+
+        if (isFatalAttack)
+        {
+            if (null != battleDrops)
+            {
+                PushDropItems(battleDrops);
+            }
+            battleField.OnObjsDead(new List<HB422_tagMCTurnFightObjDead>() { deadPack });
+            
+        }
+        else
+        {
+            if (dmgInfo.IsType(DamageType.Block))
+            {
+                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);
     }
 
+
+    const float pingpongTime = 0.4f;
     //  闂伩寮�濮�
     public virtual void OnDodgeBegin()
     {
-        float pingpongTime = 0.2f;
         RectTransform rectTrans = heroRectTrans;
         var tween = rectTrans.DOAnchorPos(new Vector3(-30, 0, 0), pingpongTime)
             .SetEase(Ease.OutCubic);
+
+        motionBase.ShowIllusionShadow(true);
+
+        tween.onComplete += () =>
+        {
+            motionBase.ShowIllusionShadow(false);
+        };
 
         battleField.battleTweenMgr.OnPlayTween(tween);
     }
@@ -297,7 +381,6 @@
     //  闂伩缁撴潫
     public virtual void OnDodgeEnd(Action _complete = null)
     {
-        float pingpongTime = 0.2f;
         RectTransform rectTrans = heroRectTrans;
 
         var tween = rectTrans.DOAnchorPos(Vector3.zero, pingpongTime)
@@ -321,16 +404,12 @@
         });
     }
 
-    //  涓嶄竴瀹氬彲闈� 鏈夋椂鍊欎細鎻掑叆鍏朵粬鍔ㄤ綔灏卞畬浜�
-    protected virtual void OnAnimationComplete(string motionName)
-    {
-
-    }
-
     protected virtual void OnDeadAnimationComplete()
     {
         //  鎴栬鐪嬬湅婧惰В鐗规晥锛� YYL TODO
         heroGo.SetActive(false);
+
+        buffMgr.RemoveAllBuff();
     }
 
     public void OnReborn(HB423_tagMCTurnFightObjReborn vNetData)
@@ -342,22 +421,18 @@
     }
 
     // 浼ゅ杩樿鐪� 鏄惁闂伩 鏆村嚮 and so on 闇�瑕佹湁涓�涓狣amageType 鏈嶅姟鍣ㄥ簲璇ヤ細缁�
-    protected virtual void PopDamage(List<long> damageValues, long _totalDamage, HB427_tagSCUseSkill.tagSCUseSkillHurt hurt, SkillConfig skillConfig)
+    protected virtual BattleDmgInfo PopDamage(List<long> damageValues, long _totalDamage, 
+        HB427_tagSCUseSkill.tagSCUseSkillHurt hurt, SkillConfig skillConfig, bool isLastHit,
+        long fromHp, long toHp)
     {
-        BattleDmgInfo battleDmgInfo = new BattleDmgInfo(battleField.guid, damageValues, this, hurt, skillConfig);
+        BattleDmgInfo battleDmgInfo = new BattleDmgInfo(battleField.guid, damageValues, this, hurt, skillConfig, isLastHit);
 
-        if (battleDmgInfo.IsType(DamageType.Dodge))
-        {
-            OnDodgeBegin();
-            DodgeFinishAction dodgeFinish = new DodgeFinishAction(battleField, this);
-            battleField.recordPlayer.InsertRecord(dodgeFinish);
-        }
-
-        heroInfoBar.UpdateHP(teamHero.curHp, Math.Max(0, teamHero.curHp - _totalDamage), teamHero.maxHp);
-        teamHero.curHp = Math.Max(0, teamHero.curHp - _totalDamage);
+        // 浣跨敤浼犲叆鐨� fromHp 鍜� toHp 鏇存柊琛�鏉℃樉绀�
+        heroInfoBar.UpdateHP(fromHp, toHp, teamHero.maxHp);
 
         // YYL TODO 鏄惁闇�瑕佹寕鍦ㄥ湪鑷韩鐨刦ollow鐐逛笂
         EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo);
+        return battleDmgInfo;
     }
 
     public RectTransform GetAliasTeamNode()
@@ -385,6 +460,7 @@
         heroRectTrans.anchoredPosition = Vector2.zero;
 
         heroInfoBar.SetActive(false);
+        SetFront();
     }
 
     public void PushDropItems(BattleDrops _battleDrops)
@@ -406,8 +482,21 @@
         battleDrops = null;
     }
 
+    public void SetBack()
+    {
+        layerMgr.SetBack();
+    }
 
+    public void SetFront()
+    {
+        layerMgr.SetFront();
+    }
 
+    public void SetSpeedRatio(float ratio)
+    {
+        motionBase.SetSpeedRatio(ratio);
+        heroInfoBar.SetSpeedRatio(ratio);
+    }
 
 
 #if UNITY_EDITOR_STOP_USING

--
Gitblit v1.8.0