From 5f38a82168cbca71d03822fdcbeaf3f1cd3905dd Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期五, 12 九月 2025 18:13:13 +0800
Subject: [PATCH] Merge branch 'master' of http://mobile.secondworld.net.cn:10010/r/Project_SG_scripts

---
 Main/System/Battle/BattleUtility.cs             |   19 ++-------
 Main/System/Battle/BattleObject/BattleObject.cs |   10 ++++-
 Main/System/Battle/Motion/MotionBase.cs         |   54 ++++++++++++++++++---------
 Main/System/Battle/Define/DamageType.cs         |   13 ++++++
 Main/System/Battle/Define/BattleDmgInfo.cs      |   15 +++++++
 5 files changed, 76 insertions(+), 35 deletions(-)

diff --git a/Main/System/Battle/BattleObject/BattleObject.cs b/Main/System/Battle/BattleObject/BattleObject.cs
index c9766a1..f115a19 100644
--- a/Main/System/Battle/BattleObject/BattleObject.cs
+++ b/Main/System/Battle/BattleObject/BattleObject.cs
@@ -353,8 +353,14 @@
             battleField.recordPlayer.InsertRecord(dodgeFinish);
         }
 
-        heroInfoBar.UpdateHP(teamHero.curHp, Math.Max(0, teamHero.curHp - _totalDamage), teamHero.maxHp);
-        teamHero.curHp = Math.Max(0, teamHero.curHp - _totalDamage);
+        int currentHurtHp = 0;
+        for (int i = 0; i < damageValues.Count; i++)
+        {
+            currentHurtHp += (int)damageValues[i];
+        }
+
+        heroInfoBar.UpdateHP(teamHero.curHp, Math.Max(0, teamHero.curHp - currentHurtHp), teamHero.maxHp);
+        teamHero.curHp = Math.Max(0, teamHero.curHp - currentHurtHp);
 
         // YYL TODO 鏄惁闇�瑕佹寕鍦ㄥ湪鑷韩鐨刦ollow鐐逛笂
         EventBroadcast.Instance.Broadcast(EventName.BATTLE_DAMAGE_TAKEN, battleDmgInfo);
diff --git a/Main/System/Battle/BattleUtility.cs b/Main/System/Battle/BattleUtility.cs
index 32ee908..668ed7f 100644
--- a/Main/System/Battle/BattleUtility.cs
+++ b/Main/System/Battle/BattleUtility.cs
@@ -289,24 +289,13 @@
     public static List<long> DivideDamageToList(int[] damageDivide, long totalDamage)
     {
         List<long> fixedDamageList = new List<long>();
-        long assigned = 0;
-        int count = damageDivide.Length;
 
-        for (int i = 0; i < count; i++)
+        for (int i = 0; i < damageDivide.Length; i++)
         {
-            long damage;
-            if (i == count - 1)
-            {
-                // 鏈�鍚庝竴涓垎閰嶉」淇涓哄墿浣�
-                damage = totalDamage - assigned;
-            }
-            else
-            {
-                damage = (totalDamage * damageDivide[i] + 5000) / 10000; // 鍥涜垗浜斿叆
-                assigned += damage;
-            }
-            fixedDamageList.Add(damage);
+            float fixedDamage = (float)totalDamage * (float)damageDivide[i] / 10000f;
+            fixedDamageList.Add((int)fixedDamage);
         }
+        
         return fixedDamageList;
     }
 
diff --git a/Main/System/Battle/Define/BattleDmgInfo.cs b/Main/System/Battle/Define/BattleDmgInfo.cs
index 44443ad..a299f39 100644
--- a/Main/System/Battle/Define/BattleDmgInfo.cs
+++ b/Main/System/Battle/Define/BattleDmgInfo.cs
@@ -29,9 +29,24 @@
         this.hurtObj = hurtObj;
         this.hurt = hurt;
         this.skillConfig = skillConfig;
+        HandleDamageType();
         HandleAttackTypeAndDamage();
     }
 
+    private void HandleDamageType()
+    {
+        int attackTypes = 0;
+        foreach (ServerDamageType serverDamageType in System.Enum.GetValues(typeof(ServerDamageType)))
+        {
+            int nsdt = (int)serverDamageType;
+            if ((hurt.AttackTypes & nsdt) == nsdt)
+            {
+                attackTypes += nsdt;
+            }
+        }
+        hurt.AttackTypes = (uint)attackTypes;
+    }
+
     private void HandleAttackTypeAndDamage()
     {
         isBlocked = HaveBlockDamage();
diff --git a/Main/System/Battle/Define/DamageType.cs b/Main/System/Battle/Define/DamageType.cs
index 3f029ed..cf04cb2 100644
--- a/Main/System/Battle/Define/DamageType.cs
+++ b/Main/System/Battle/Define/DamageType.cs
@@ -9,6 +9,19 @@
 //
 // 101011111
 
+
+//	鏈嶅姟鍣ㄦ嫢鏈夌殑DamageType
+public enum ServerDamageType
+{
+	Damage = 2,
+	Recovery = 4,
+	Reflect = 8,
+	Bloody = 16,
+	Block = 32,
+	Crit = 128,
+	Dodge = 512
+}
+
 public enum DamageType
 {
 	Damage = 2,         //鏅�氫激瀹� (2^1)
diff --git a/Main/System/Battle/Motion/MotionBase.cs b/Main/System/Battle/Motion/MotionBase.cs
index 3f81ccf..7a35dd2 100644
--- a/Main/System/Battle/Motion/MotionBase.cs
+++ b/Main/System/Battle/Motion/MotionBase.cs
@@ -25,9 +25,11 @@
     public Action OnAttackAnimationComplete;
     public Action OnHitAnimationComplete;
     public Action<string> onAnimationComplete;
+    
+    private List<Action> runActionList = new List<Action>();
 
     #region 缁勪欢寮曠敤
-    
+
     protected SkeletonGraphic skeletonGraphic;
     protected Spine.AnimationState spineAnimationState;
     protected Spine.Skeleton skeleton;
@@ -42,6 +44,7 @@
     #endregion
 
     private Spine.TrackEntry currentTrackEntry;
+    
 
     #region 鍒濆鍖栨柟娉�
 
@@ -134,6 +137,16 @@
         return currentTrackEntry;
     }
 
+    private void RunAction(Action _action)
+    {
+        runActionList.Add(_action);
+    }
+
+    private void RemoveRunAction(Action _action)
+    {
+        runActionList.Remove(_action);
+    }
+
     public Spine.TrackEntry PlaySkillAnimation(SkillConfig skillConfig, SkillBase skillBase, Action _onComplete = null)
     {
         // 鍙傛暟鏍¢獙
@@ -174,12 +187,10 @@
         }
 
         // 鍏抽敭甯у弬鏁�
-        float fps = BattleConst.skillMotionFps;
-        float middleBeginTime = skillConfig.StartupFrames / fps;
         int loopCount = skillConfig.LoopCount;
         int[] activeFrames = skillConfig.ActiveFrames;
         int activeFrameCount = activeFrames.Length;
-        float recoveryFrameTime = skillConfig.RecoveryFrames / fps;
+        float recoveryFrame = skillConfig.RecoveryFrames;
 
         // 鎾斁鍔ㄧ敾
         var skillTrackEntry = spineAnimationState.SetAnimation(0, anim, false);
@@ -198,21 +209,23 @@
         skillBase.OnSkillStart();
 
         // 鍔ㄧ敾甯ф洿鏂板鐞�
-        Spine.Unity.UpdateBonesDelegate updateLocalHandler = null;
-        updateLocalHandler = (ISkeletonAnimation animated) =>
+        int triggerMFEndCount = 0;
+        Action updateLocalHandler = null;
+        updateLocalHandler = () =>
         {
             if (isFinish) return;
-            float trackTime = skillTrackEntry.TrackTime;
+
+            float frame = (skillTrackEntry.TrackTime * (float)BattleConst.skillMotionFps);
 
             // 鍓嶆憞缁撴潫锛堝彧瑙﹀彂涓�娆★級
-            if (!beginPhaseTriggered && trackTime >= middleBeginTime && curLoop == 0)
+            if (!beginPhaseTriggered && frame >= skillConfig.StartupFrames && curLoop == 0)
             {
                 beginPhaseTriggered = true;
                 skillBase.OnStartSkillFrameEnd();
             }
 
             // 涓憞寮�濮嬶紙姣忚疆loop鐨勫紑濮嬶紝鍙Е鍙戜竴娆★級
-            if (!middleFrameStarted && trackTime >= middleBeginTime && curLoop <= loopCount)
+            if (!middleFrameStarted && frame >= skillConfig.StartupFrames && curLoop <= loopCount)
             {
                 middleFrameStarted = true;
                 skillBase.OnMiddleFrameStart(curLoop);
@@ -221,10 +234,10 @@
             // 澶氭鏀诲嚮甯цЕ鍙�
             for (int hitIndex = 0; hitIndex < activeFrameCount; hitIndex++)
             {
-                float activeFrameTime = activeFrames[hitIndex] / fps;
-                if (!triggeredActiveFrame[hitIndex] && trackTime >= activeFrameTime)
+                float activeFrame = activeFrames[hitIndex];
+                if (!triggeredActiveFrame[hitIndex] && frame >= activeFrame)
                 {
-                    skillBase.OnMiddleFrameEnd(curLoop, hitIndex);
+                    skillBase.OnMiddleFrameEnd(curLoop, triggerMFEndCount++);
                     triggeredActiveFrame[hitIndex] = true;
                 }
             }
@@ -250,7 +263,7 @@
                 if (curLoop < loopCount)
                 {
                     // 閲嶆柊璁剧疆鍒扮涓�娆$殑涓憞鏃堕棿
-                    skillTrackEntry.TrackTime = middleBeginTime;
+                    skillTrackEntry.TrackTime = skillConfig.StartupFrames / BattleConst.skillMotionFps;
                     beginPhaseTriggered = false;
                 }
                 else
@@ -264,16 +277,16 @@
             // 鏀跺熬闃舵锛歄nFinalFrameStart 鍜� OnFinalFrameEnd
             if (curLoop >= loopCount)
             {
-                if (!finalFrameStarted && trackTime >= recoveryFrameTime)
+                if (!finalFrameStarted && frame >= recoveryFrame)
                 {
                     finalFrameStarted = true;
                     skillBase.OnFinalFrameStart();
                 }
-                if (finalFrameStarted && !finalFrameEnded && trackTime >= recoveryFrameTime)
+                if (finalFrameStarted && !finalFrameEnded && frame >= recoveryFrame)
                 {
                     finalFrameEnded = true;
                     skillBase.OnFinalFrameEnd();
-                    skeletonGraphic.UpdateLocal -= updateLocalHandler;
+                    RemoveRunAction(updateLocalHandler);
                     isFinish = true;
                 }
             }
@@ -284,7 +297,8 @@
             trackEntryCompleteDict[currentTrackEntry] = _onComplete;
         }
 
-        skeletonGraphic.UpdateLocal += updateLocalHandler;
+        RunAction(updateLocalHandler);
+
         return skillTrackEntry;
     }
 
@@ -334,7 +348,10 @@
 
     public virtual void Run()
     {
-
+        for (int i = runActionList.Count - 1; i >= 0; i--)
+        {
+            runActionList[i]?.Invoke();
+        }
     }
 
     public virtual void Pause()
@@ -352,6 +369,7 @@
     public void HaveRest()
     {
         trackEntryCompleteDict.Clear();
+        runActionList.Clear();
         PlayAnimation(MotionName.idle, true);
     }
 

--
Gitblit v1.8.0