From 6a10188f3eddc740b9b8b1e7eefb0e2fdb3850e3 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期一, 15 九月 2025 19:41:19 +0800
Subject: [PATCH] 125 【战斗】战斗系统 角色层级&战斗速度调整

---
 Main/Component/UI/Effect/BattleEffectPlayer.cs |   99 +++++++++++++++++++++++++------------------------
 1 files changed, 50 insertions(+), 49 deletions(-)

diff --git a/Main/Component/UI/Effect/BattleEffectPlayer.cs b/Main/Component/UI/Effect/BattleEffectPlayer.cs
index 3be7521..f9f4f4e 100644
--- a/Main/Component/UI/Effect/BattleEffectPlayer.cs
+++ b/Main/Component/UI/Effect/BattleEffectPlayer.cs
@@ -33,7 +33,7 @@
     public bool isRedCamp = true;
     public EffectConfig effectConfig;
 
-    public float speedRate = 1f;
+    public float speedRate = 1.5f;
 
 
 
@@ -43,11 +43,9 @@
 
     public Action<BattleEffectPlayer> onDestroy;
 
-    [HideInInspector] public Canvas canvas = null;
-
     [HideInInspector] public GameObject effectTarget = null;
 
-    protected EffectPenetrationBlocker blocker = null;
+    protected RendererAdjuster blocker = null;
 
     protected bool isInit = false;
 
@@ -61,6 +59,8 @@
 
     protected SkeletonAnimation spineComp;
     protected Spine.AnimationState spineAnimationState;
+
+    protected int heroSetedSortingOrder;
 
     public GameObjectPoolManager.GameObjectPool pool;
 
@@ -157,24 +157,43 @@
         onComplete?.Invoke();
     }
 
-    public virtual void Play(bool showLog = true)
+    public void SetSortingOrder(int _heroSetedSortingOrder)
     {
+        heroSetedSortingOrder = _heroSetedSortingOrder;
 
+        int so = heroSetedSortingOrder;
 
-        if (!isInit)
+        if (null != blocker && effectConfig != null)
+        {
+            if (BattleConst.UnactiveHeroSortingOrder == heroSetedSortingOrder)
             {
-                InitComponent(showLog);
-                isInit = true;
+                so = effectConfig.frontBack == 1 ? BattleConst.UnactiveHeroFrontSortingOrder : BattleConst.UnactiveHeroBackSortingOrder;
             }
             else
             {
-                //閬垮厤閲嶅鍒涘缓
-                if (!this.gameObject.activeSelf)
-                {
-                    this.gameObject.SetActive(true);
-                }
-                return;
+                so = effectConfig.frontBack == 1 ? BattleConst.ActiveHeroFrontSortingOrder : BattleConst.ActiveHeroBackSortingOrder;
             }
+
+            blocker.SetSortingOrder(so);
+        }
+    }
+
+    public virtual void Play(bool showLog = true)
+    {
+        if (!isInit)
+        {
+            InitComponent(showLog);
+            isInit = true;
+        }
+        else
+        {
+            //閬垮厤閲嶅鍒涘缓
+            if (!this.gameObject.activeSelf)
+            {
+                this.gameObject.SetActive(true);
+            }
+            return;
+        }
 
         if (EffectMgr.IsNotShowBySetting(effectId))
         {
@@ -195,12 +214,12 @@
 
         if (effectConfig.autoDestroy != 0)
         {
-            GameObject.Destroy(gameObject, effectConfig.destroyDelay);
+            GameObject.Destroy(gameObject, effectConfig.destroyDelay / speedRate);
         }
 
 
         PlayEffect();
-        
+
 
     }
 
@@ -250,22 +269,15 @@
         spineAnimationState.Complete -= OnSpineAnimationComplete;
         spineAnimationState.Complete += OnSpineAnimationComplete;
 
-
-        if (null == canvas)
-            canvas = GetComponentInParent<Canvas>();
-
         // 娣诲姞鐗规晥绌块�忛樆鎸″櫒
-        blocker = spineComp.AddMissingComponent<EffectPenetrationBlocker>();
+        blocker = spineComp.AddMissingComponent<RendererAdjuster>();
 
         blocker.onSortingChanged = OnSortingChanged;
 
-        //  濡傛灉娌℃湁canvas鐨勮瘽 姝e父鏄洜涓轰笉鍦˙attleWin涓嬮潰鐨勮妭鐐� 鎰忔�濆氨鏄綋鍓嶆病鏈夋樉绀� 绛夊埌鍒囧洖鎴樻枟鐨勬椂鍊欏啀閫氳繃BattleField.UpdateCanvas鏉ユ洿鏂�
-        if (canvas != null)
-        {
-            blocker.SetParentCanvas(canvas);
-        }
-
         spineComp.enabled = true;
+
+        spineComp.timeScale = speedRate;
+        spineAnimationState.TimeScale = speedRate;
 
         Spine.Animation animation = spineAnimationState.Data.SkeletonData.Animations.First();
         spineAnimationState.SetAnimation(0, animation, effectConfig.isLoop != 0);
@@ -320,19 +332,11 @@
 
         OnUnityAnimationComplete();
 
-        if (null == canvas)
-            canvas = GetComponentInParent<Canvas>();
 
         // 娣诲姞鐗规晥绌块�忛樆鎸″櫒
-        blocker = effectTarget.AddMissingComponent<EffectPenetrationBlocker>();
+        blocker = effectTarget.AddMissingComponent<RendererAdjuster>();
 
         blocker.onSortingChanged = OnSortingChanged;
-
-        //  濡傛灉娌℃湁canvas鐨勮瘽 姝e父鏄洜涓轰笉鍦˙attleWin涓嬮潰鐨勮妭鐐� 鎰忔�濆氨鏄綋鍓嶆病鏈夋樉绀� 绛夊埌鍒囧洖鎴樻枟鐨勬椂鍊欏啀閫氳繃BattleField.UpdateCanvas鏉ユ洿鏂�
-        if (canvas != null)
-        {
-            blocker.SetParentCanvas(canvas);
-        }
 
         SoundPlayer.Instance.PlayUIAudio(effectConfig.audio);
 
@@ -526,21 +530,18 @@
         return true;
     }
 
-    /// <summary>
-    /// 璁剧疆閬僵锛堟敮鎸丷ectMask2D銆丮ask銆丼moothMask绛夛級
-    /// </summary>
-    public void SetMask(RectTransform maskArea = null)
+    public void SetSpeedRatio(float ratio)
     {
-        if (effectTarget == null || blocker == null)
-            return;
-
-        // 浼樺厛浣跨敤浼犲叆鐨刴askArea
-        if (maskArea != null)
+        speedRate = ratio;
+        if (spineComp != null)
         {
-            blocker.PerformMask(maskArea);
-            return;
+            spineComp.timeScale = speedRate;
+        }
+
+        // Animator鍔ㄧ敾
+        foreach (var animator in animatorList)
+        {
+            animator.speed = speedRate;
         }
     }
-
-
 }

--
Gitblit v1.8.0