From f4da988ce76d8ad87f195ad9d98176b3dcb7622b Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期日, 28 九月 2025 11:56:45 +0800
Subject: [PATCH] 125 战斗 特效层级修改处理
---
Main/Component/UI/Common/RendererAdjuster.cs | 15 ++++++-
Main/System/Battle/BattleConst.cs | 1
Main/System/Battle/BattleObject/BattleObject.cs | 2
Main/System/Battle/BattleObject/BattleObjectFactory.cs | 6 +-
Main/System/Battle/Motion/MotionBase.cs | 22 +++++-----
Main/Component/UI/Effect/BattleEffectPlayer.cs | 49 ++++++++++--------------
Main/System/Battle/BattleObject/BattleObjectLayerMgr.cs | 7 +++
7 files changed, 56 insertions(+), 46 deletions(-)
diff --git a/Main/Component/UI/Common/RendererAdjuster.cs b/Main/Component/UI/Common/RendererAdjuster.cs
index fe9d096..4ecc7ee 100644
--- a/Main/Component/UI/Common/RendererAdjuster.cs
+++ b/Main/Component/UI/Common/RendererAdjuster.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using UnityEngine;
using System;
+using Spine.Unity;
public class RendererAdjuster : MonoBehaviour
{
@@ -11,6 +12,8 @@
public string customSortingLayer = "UI";
public List<Renderer> renderers = new List<Renderer>();
+
+ // private List<SkeletonAnimation> skeletonAnimations = new List<SkeletonAnimation>();
protected Canvas canvas;
@@ -33,7 +36,10 @@
renderers.Clear();
renderers.AddRange(gameObject.GetComponentsInChildren<Renderer>(true));
- canvas = GetComponent<Canvas>();
+ // skeletonAnimations.Clear();
+ // skeletonAnimations.AddRange(gameObject.GetComponentsInChildren<SkeletonAnimation>(true));
+
+ canvas = GetComponentInChildren<Canvas>();
}
public void UpdateSortingOrder()
@@ -59,13 +65,18 @@
if (null != canvas)
{
- canvas.sortingOrder = sortingOrder;
+ canvas.sortingOrder = sortingOrder + 1;
if (!string.IsNullOrEmpty(sortingLayer))
{
canvas.sortingLayerName = sortingLayer;
}
}
+ // foreach (var skeletonAnim in skeletonAnimations)
+ // {
+
+ // }
+
onSortingChanged?.Invoke(sortingLayer, sortingOrder);
}
}
diff --git a/Main/Component/UI/Effect/BattleEffectPlayer.cs b/Main/Component/UI/Effect/BattleEffectPlayer.cs
index 480cae5..3b47ad3 100644
--- a/Main/Component/UI/Effect/BattleEffectPlayer.cs
+++ b/Main/Component/UI/Effect/BattleEffectPlayer.cs
@@ -58,8 +58,6 @@
protected SkeletonAnimation spineComp;
protected Spine.AnimationState spineAnimationState;
- protected int heroSetedSortingOrder;
-
public GameObjectPoolManager.GameObjectPool pool;
public Action onComplete;
@@ -75,6 +73,8 @@
//闅愯棌锛屼細鏈夐潤鎬佹樉绀洪棶棰�
spineComp.enabled = false;
}
+
+ ApplySortingOrder();
}
@@ -159,24 +159,29 @@
onComplete?.Invoke();
}
- public void SetSortingOrder(int _heroSetedSortingOrder)
+ public Func<bool> funcIsHeroFront;
+
+ public void SetSortingOrder(Func<bool> _isHeroFrontCallback)
{
- heroSetedSortingOrder = _heroSetedSortingOrder;
+ funcIsHeroFront = _isHeroFrontCallback;
- int so = heroSetedSortingOrder;
+ ApplySortingOrder();
+ }
- if (null != blocker && effectConfig != null)
+
+ public void ApplySortingOrder()
+ {
+ if (null != blocker && effectConfig != null && funcIsHeroFront != null)
{
- if (BattleConst.UnactiveHeroSortingOrder == heroSetedSortingOrder)
- {
- so = effectConfig.frontBack == 1 ? BattleConst.UnactiveHeroFrontSortingOrder : BattleConst.UnactiveHeroBackSortingOrder;
- }
- else
- {
- so = effectConfig.frontBack == 1 ? BattleConst.ActiveHeroFrontSortingOrder : BattleConst.ActiveHeroBackSortingOrder;
- }
+ bool isEffectFront = effectConfig.frontBack == 1;
- blocker.SetSortingOrder(so);
+ bool isHeroFront = funcIsHeroFront();
+
+ int finalSortingOrder = isHeroFront ?
+ (isEffectFront ? BattleConst.ActiveHeroActionSortingOrder : BattleConst.ActiveHeroBackSortingOrder) : (isEffectFront ? BattleConst.UnactiveHeroFrontSortingOrder : BattleConst.UnactiveHeroBackSortingOrder);
+
+
+ blocker.SetSortingOrder(finalSortingOrder);
}
}
@@ -295,19 +300,7 @@
blocker.onSortingChanged = OnSortingChanged;
- if (0 != heroSetedSortingOrder)
- {
- if (BattleConst.UnactiveHeroSortingOrder == heroSetedSortingOrder)
- {
- heroSetedSortingOrder = effectConfig.frontBack == 1 ? BattleConst.UnactiveHeroFrontSortingOrder : BattleConst.UnactiveHeroBackSortingOrder;
- }
- else
- {
- heroSetedSortingOrder = effectConfig.frontBack == 1 ? BattleConst.ActiveHeroFrontSortingOrder : BattleConst.ActiveHeroBackSortingOrder;
- }
-
- blocker.SetSortingOrder(heroSetedSortingOrder);
- }
+ ApplySortingOrder();
spineComp.enabled = true;
diff --git a/Main/System/Battle/BattleConst.cs b/Main/System/Battle/BattleConst.cs
index 18eb822..b83efe9 100644
--- a/Main/System/Battle/BattleConst.cs
+++ b/Main/System/Battle/BattleConst.cs
@@ -99,6 +99,7 @@
}
}
+ // 閲婃斁鎶�鑳介挓鐨勮嫳闆勫眰绾�
public static int ActiveHeroActionSortingOrder
{
get
diff --git a/Main/System/Battle/BattleObject/BattleObject.cs b/Main/System/Battle/BattleObject/BattleObject.cs
index c686fea..d3b7bdd 100644
--- a/Main/System/Battle/BattleObject/BattleObject.cs
+++ b/Main/System/Battle/BattleObject/BattleObject.cs
@@ -83,7 +83,7 @@
teamHero = _teamHero;
Camp = _camp;
motionBase = new MotionBase();
- motionBase.Init(heroGo.GetComponentInChildren<SkeletonGraphic>(true));
+ motionBase.Init(heroGo.GetComponentInChildren<SkeletonAnimation>(true));
buffMgr = new BattleObjectBuffMgr();
buffMgr.Init(this);
diff --git a/Main/System/Battle/BattleObject/BattleObjectFactory.cs b/Main/System/Battle/BattleObject/BattleObjectFactory.cs
index 9a4d010..e738e1c 100644
--- a/Main/System/Battle/BattleObject/BattleObjectFactory.cs
+++ b/Main/System/Battle/BattleObject/BattleObjectFactory.cs
@@ -30,7 +30,7 @@
battleObject.ObjID = teamHero.ObjID;
GameObject realGO = GameObject.Instantiate(battleGO, goParent.transform);
- SkeletonGraphic skeletonGraphic = realGO.GetComponentInChildren<SkeletonGraphic>(true);
+ SkeletonAnimation skeletonAnimation = realGO.GetComponentInChildren<SkeletonAnimation>(true);
var skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("Hero/SpineRes/", skinCfg.SpineRes);
if (skeletonDataAsset == null)
@@ -42,8 +42,8 @@
float finalScaleRate = modelScaleRate * teamHero.modelScale;
- skeletonGraphic.skeletonDataAsset = skeletonDataAsset;
- skeletonGraphic.Initialize(true);
+ skeletonAnimation.skeletonDataAsset = skeletonDataAsset;
+ skeletonAnimation.Initialize(true);
realGO.name = battleObject.ObjID.ToString();
realGO.transform.localScale = new Vector3(finalScaleRate, finalScaleRate, finalScaleRate);
RectTransform rectTrans = realGO.GetComponent<RectTransform>();
diff --git a/Main/System/Battle/BattleObject/BattleObjectLayerMgr.cs b/Main/System/Battle/BattleObject/BattleObjectLayerMgr.cs
index 60e3f54..036b165 100644
--- a/Main/System/Battle/BattleObject/BattleObjectLayerMgr.cs
+++ b/Main/System/Battle/BattleObject/BattleObjectLayerMgr.cs
@@ -36,7 +36,7 @@
{
effectPlayers.Add(effectPlayer);
}
- effectPlayer.SetSortingOrder(rendererAdjuster.sortingOrder);
+ effectPlayer.SetSortingOrder(IsFront);
}
public void RemoveEffect(BattleEffectPlayer effectPlayer)
@@ -69,4 +69,9 @@
int order = isFront ? BattleConst.ActiveHeroSortingOrder : BattleConst.UnactiveHeroSortingOrder;
SetSortingOrder(order);
}
+
+ public bool IsFront()
+ {
+ return isFront;
+ }
}
\ No newline at end of file
diff --git a/Main/System/Battle/Motion/MotionBase.cs b/Main/System/Battle/Motion/MotionBase.cs
index fc8f4e9..5e652f0 100644
--- a/Main/System/Battle/Motion/MotionBase.cs
+++ b/Main/System/Battle/Motion/MotionBase.cs
@@ -29,7 +29,7 @@
#region 缁勪欢寮曠敤
- protected SkeletonGraphic skeletonGraphic;
+ protected SkeletonAnimation skeletonAnimation;
protected Spine.AnimationState spineAnimationState;
protected Spine.Skeleton skeleton;
@@ -51,17 +51,17 @@
/// 鍒濆鍖栧姩鐢荤粍浠�
/// </summary>
/// <param name="skeletonGraphic">楠ㄩ鍔ㄧ敾缁勪欢</param>
- public virtual void Init(SkeletonGraphic skeletonGraphic)
+ public virtual void Init(SkeletonAnimation _skeletonAnimation)
{
- this.skeletonGraphic = skeletonGraphic;
+ this.skeletonAnimation = _skeletonAnimation;
- if (skeletonGraphic != null)
+ if (skeletonAnimation != null)
{
- spineAnimationState = skeletonGraphic.AnimationState;
+ spineAnimationState = skeletonAnimation.AnimationState;
spineAnimationState.TimeScale = MotionTimeScale;
- skeletonGraphic.timeScale = MotionTimeScale;
+ skeletonAnimation.timeScale = MotionTimeScale;
- skeleton = skeletonGraphic.Skeleton;
+ skeleton = skeletonAnimation.Skeleton;
// 璁剧疆鍔ㄧ敾娣峰悎鏃堕棿
if (spineAnimationState != null)
@@ -93,7 +93,7 @@
spineAnimationState = null;
}
- skeletonGraphic = null;
+ skeletonAnimation = null;
skeleton = null;
currentTrackEntry = null;
}
@@ -395,13 +395,13 @@
public virtual void Pause()
{
spineAnimationState.TimeScale = 0f;
- skeletonGraphic.timeScale = 0f;
+ skeletonAnimation.timeScale = 0f;
}
public virtual void Resume()
{
spineAnimationState.TimeScale = MotionTimeScale;
- skeletonGraphic.timeScale = MotionTimeScale;
+ skeletonAnimation.timeScale = MotionTimeScale;
}
public void HaveRest()
@@ -415,7 +415,7 @@
{
MotionTimeScale = ratio;
spineAnimationState.TimeScale = ratio;
- skeletonGraphic.timeScale = ratio;
+ skeletonAnimation.timeScale = ratio;
}
#endregion
--
Gitblit v1.8.0