From 30ba2ef747ced774bef177d5273cb5a3429cff49 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期二, 01 七月 2025 17:38:55 +0800
Subject: [PATCH] 130 子 【战斗】战斗系统 / 【战斗】战斗系统-客户端 部分战斗逻辑

---
 Main/System/Battle/Motion/MotionBase.cs |   99 ++++++++++++++++++++++++-------------------------
 1 files changed, 48 insertions(+), 51 deletions(-)

diff --git a/Main/System/Battle/Motion/MotionBase.cs b/Main/System/Battle/Motion/MotionBase.cs
index 9c2fddb..e59f90a 100644
--- a/Main/System/Battle/Motion/MotionBase.cs
+++ b/Main/System/Battle/Motion/MotionBase.cs
@@ -19,7 +19,7 @@
 
         public WaitingTask(List<int> triggerFrame, MotionName motionName, Action<MotionName, int> _callback)
         {
-            this.triggerFrame = triggerFrame;
+            this.triggerFrame = new List<int>(triggerFrame);
             this.motionName = motionName;
             this.currentFrame = 0;
             this.callback = _callback;
@@ -38,8 +38,9 @@
                 
                 if (currentFrame >= triggerFrame[0])
                 {
+                    int frame = triggerFrame[0];
                     triggerFrame.RemoveAt(0);
-                    callback?.Invoke(motionName, currentFrame);
+                    callback?.Invoke(motionName, frame);
                 }
             }
         }
@@ -48,6 +49,7 @@
     // 鍔ㄧ敾浜嬩欢
     public Action OnAttackAnimationComplete;
     public Action OnHitAnimationComplete;
+    public Action<MotionName> OnOtherAnimationComplete;
     public Action<int> OnAttackHitEvent; //trigger index
 
     #region 缁勪欢寮曠敤
@@ -61,12 +63,14 @@
     #region 鍔ㄧ敾璁剧疆
     
     // 鍔ㄧ敾娣峰悎鏃堕棿
-    protected float defaultMixDuration = 0.2f;
+    protected float defaultMixDuration = 0f;
     
     #endregion
     
     protected List<WaitingTask> waitingTaskList = new List<WaitingTask>();
     protected List<WaitingTask> removeList = new List<WaitingTask>();
+
+    private Spine.TrackEntry currentTrackEntry;
 
     #region 鍒濆鍖栨柟娉�
     
@@ -101,10 +105,27 @@
         }
     }
     
+    public virtual void Release()
+    {
+        if (spineAnimationState != null)
+        {
+            spineAnimationState.Complete -= OnAnimationComplete;
+            spineAnimationState.ClearTracks();
+            spineAnimationState = null;
+        }
+        
+        skeletonGraphic = null;
+        skeleton = null;
+        currentTrackEntry = null;
+        
+        waitingTaskList.Clear();
+        removeList.Clear();
+    }
+    
     #endregion
-    
+
     #region 鍔ㄧ敾鎺у埗
-    
+
     /// <summary>
     /// 鎾斁鎸囧畾鍔ㄧ敾
     /// </summary>
@@ -114,51 +135,10 @@
     public virtual Spine.TrackEntry PlayAnimation(MotionName motionName, bool loop)
     {
         if (spineAnimationState == null) return null;
-        
+
         // 鐩存帴浣跨敤 ToString() 鑰屼笉鏄皟鐢� GetAnimationName
-        return spineAnimationState.SetAnimation(0, motionName.ToString(), loop);
-    }
-    
-    /// <summary>
-    /// 鎾斁鎸囧畾鍔ㄧ敾锛堜娇鐢ㄥ瓧绗︿覆鍚嶇О锛�
-    /// </summary>
-    /// <param name="animationName">鍔ㄧ敾鍚嶇О</param>
-    /// <param name="loop">鏄惁寰幆</param>
-    /// <returns>鍔ㄧ敾杞ㄩ亾鏉$洰</returns>
-    public virtual Spine.TrackEntry PlayAnimation(string animationName, bool loop)
-    {
-        if (spineAnimationState == null) return null;
-        
-        return spineAnimationState.SetAnimation(0, animationName, loop);
-    }
-    
-    /// <summary>
-    /// 娣诲姞鍔ㄧ敾鍒伴槦鍒�
-    /// </summary>
-    /// <param name="motionName">鍔ㄧ敾鏋氫妇</param>
-    /// <param name="loop">鏄惁寰幆</param>
-    /// <param name="delay">寤惰繜鏃堕棿</param>
-    /// <returns>鍔ㄧ敾杞ㄩ亾鏉$洰</returns>
-    public virtual Spine.TrackEntry AddAnimation(MotionName motionName, bool loop, float delay)
-    {
-        if (spineAnimationState == null) return null;
-        
-        // 鐩存帴浣跨敤 ToString() 鑰屼笉鏄皟鐢� GetAnimationName
-        return spineAnimationState.AddAnimation(0, motionName.ToString(), loop, delay);
-    }
-    
-    /// <summary>
-    /// 娣诲姞鍔ㄧ敾鍒伴槦鍒楋紙浣跨敤瀛楃涓插悕绉帮級
-    /// </summary>
-    /// <param name="animationName">鍔ㄧ敾鍚嶇О</param>
-    /// <param name="loop">鏄惁寰幆</param>
-    /// <param name="delay">寤惰繜鏃堕棿</param>
-    /// <returns>鍔ㄧ敾杞ㄩ亾鏉$洰</returns>
-    public virtual Spine.TrackEntry AddAnimation(string animationName, bool loop, float delay)
-    {
-        if (spineAnimationState == null) return null;
-        
-        return spineAnimationState.AddAnimation(0, animationName, loop, delay);
+        currentTrackEntry = spineAnimationState.SetAnimation(0, motionName.ToString(), loop);
+        return currentTrackEntry;
     }
     
     /// <summary>
@@ -180,8 +160,8 @@
         string animation = trackEntry.Animation.Name;
         
         // 鏀诲嚮鍔ㄧ敾瀹屾垚鍚庢仮澶嶅埌寰呮満鐘舵��
-        if (animation == MotionName.atk1.ToString() || 
-            animation == MotionName.atk2.ToString())
+        if (animation == MotionName.attack.ToString() || 
+            animation == MotionName.angerSkill.ToString())
         {
             OnAttackAnimationComplete?.Invoke();
             PlayAnimation(MotionName.idle, true);
@@ -191,6 +171,10 @@
         {
             OnHitAnimationComplete?.Invoke();
             PlayAnimation(MotionName.idle, true);
+        }
+        else
+        {
+            OnOtherAnimationComplete?.Invoke((MotionName)Enum.Parse(typeof(MotionName), animation));
         }
     }
     
@@ -242,6 +226,19 @@
 
         removeList.Clear();
     }
+
+    public virtual void Pause()
+    {
+        if (currentTrackEntry != null)
+            currentTrackEntry.TimeScale = 0f;
+    }
+
+    public virtual void Resume()
+    {
+        if (currentTrackEntry != null)
+            currentTrackEntry.TimeScale = 1f;
+    }
+
     #endregion
     
 }
\ No newline at end of file

--
Gitblit v1.8.0