From 8f983d0dab26becb6b85dbbb616fde21c3ad8f02 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期三, 20 八月 2025 18:40:23 +0800
Subject: [PATCH] 125 【战斗】战斗系统
---
Main/Component/UI/Effect/BattleEffectPlayer.cs | 111 +++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 91 insertions(+), 20 deletions(-)
diff --git a/Main/Component/UI/Effect/BattleEffectPlayer.cs b/Main/Component/UI/Effect/BattleEffectPlayer.cs
index 1a09695..5dc1a4b 100644
--- a/Main/Component/UI/Effect/BattleEffectPlayer.cs
+++ b/Main/Component/UI/Effect/BattleEffectPlayer.cs
@@ -60,7 +60,7 @@
protected GameObject spineContainer;
- protected SkeletonGraphic spineComp;
+ protected SkeletonAnimation spineComp;
protected Spine.AnimationState spineAnimationState;
public GameObjectPoolManager.GameObjectPool pool;
@@ -107,13 +107,14 @@
}
// 鍒濆鍖杝pine缁勪欢
- if (effectConfig != null && effectConfig.isSpine != 1)
+ if (effectConfig != null && effectConfig.isSpine != 0)
{
- GameObject spineContainerPrefab = ResManager.Instance.LoadAsset<GameObject>("UIComp", "SpineContainer");
- spineContainer = GameObject.Instantiate(spineContainerPrefab, transform);
+ GameObject spineContainerPrefab = ResManager.Instance.LoadAsset<GameObject>("UIComp", "SpineAnimContainer");
+ spineContainer = GameObject.Instantiate(spineContainerPrefab, transform, true);
+ spineContainer.transform.localPosition = Vector3.zero;
}
// 鏈夌壒鏁堝彲鑳藉甫spine鍙堝甫unity鐗规晥鐨勬儏鍐�
- spineComp = gameObject.GetComponentInChildren<SkeletonGraphic>(true);
+ spineComp = gameObject.GetComponentInChildren<SkeletonAnimation>(true);
}
protected virtual void Clear()
@@ -149,20 +150,22 @@
public virtual void Play(bool showLog = true)
{
+
+
if (!isInit)
- {
- InitComponent(showLog);
- isInit = true;
- }
- else
- {
- //閬垮厤閲嶅鍒涘缓
- if (!this.gameObject.activeSelf)
{
- this.gameObject.SetActive(true);
+ InitComponent(showLog);
+ isInit = true;
}
- return;
- }
+ else
+ {
+ //閬垮厤閲嶅鍒涘缓
+ if (!this.gameObject.activeSelf)
+ {
+ this.gameObject.SetActive(true);
+ }
+ return;
+ }
if (EffectMgr.IsNotShowBySetting(effectId))
{
@@ -194,6 +197,15 @@
return;
}
+ // 濡傛灉delay灏忎簬绛変簬0 閭d細绔嬪埢鎵ц
+ this.DelayTime(effectConfig.delayPlay, () =>
+ {
+ PlayEffectInternal();
+ });
+ }
+
+ protected void PlayEffectInternal()
+ {
if (effectConfig.isSpine != 0)
{
PlaySpineEffect();
@@ -202,7 +214,6 @@
{
PlayUnityEffect();
}
-
}
protected void PlaySpineEffect()
@@ -215,18 +226,50 @@
return;
}
- SkeletonDataAsset skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("UIEffect/BattleSpine/" + effectConfig.packageName, effectConfig.fxName);
+ SkeletonDataAsset skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("UIEffect/" + effectConfig.packageName, effectConfig.fxName);
spineComp.skeletonDataAsset = skeletonDataAsset;
spineComp.Initialize(true);
- spineComp.raycastTarget = false;
spineComp.timeScale = speedRate;
spineAnimationState = spineComp.AnimationState;
spineAnimationState.Complete -= OnSpineAnimationComplete;
spineAnimationState.Complete += OnSpineAnimationComplete;
+
+ if (null == canvas)
+ canvas = GetComponentInParent<Canvas>();
+
+ // 娣诲姞鐗规晥绌块�忛樆鎸″櫒
+ blocker = spineComp.AddMissingComponent<EffectPenetrationBlocker>();
+
+ blocker.onSortingChanged = OnSortingChanged;
+
+ // 濡傛灉娌℃湁canvas鐨勮瘽 姝e父鏄洜涓轰笉鍦˙attleWin涓嬮潰鐨勮妭鐐� 鎰忔�濆氨鏄綋鍓嶆病鏈夋樉绀� 绛夊埌鍒囧洖鎴樻枟鐨勬椂鍊欏啀閫氳繃BattleField.UpdateCanvas鏉ユ洿鏂�
+ if (canvas != null)
+ {
+ blocker.SetParentCanvas(canvas);
+ }
+
+ spineComp.enabled = true;
+
Spine.Animation animation = spineAnimationState.Data.SkeletonData.Animations.First();
- spineAnimationState.SetAnimation(0, animation, false);
+ spineAnimationState.SetAnimation(0, animation, effectConfig.isLoop != 0);
+
+ SoundPlayer.Instance.PlayUIAudio(effectConfig.audio);
+
+ }
+
+ private bool CheckForAdditiveBlend(Spine.Skeleton skeleton)
+ {
+ // 閬嶅巻鎵�鏈夋彃妲斤紝妫�鏌ユ槸鍚︽湁鐩稿姞妯″紡
+ foreach (var slot in skeleton.Slots)
+ {
+ if (slot.Data.BlendMode == Spine.BlendMode.Additive)
+ {
+ return true;
+ }
+ }
+ return false;
}
protected void PlayUnityEffect()
@@ -268,6 +311,8 @@
// 娣诲姞鐗规晥绌块�忛樆鎸″櫒
blocker = effectTarget.AddMissingComponent<EffectPenetrationBlocker>();
+ blocker.onSortingChanged = OnSortingChanged;
+
// 濡傛灉娌℃湁canvas鐨勮瘽 姝e父鏄洜涓轰笉鍦˙attleWin涓嬮潰鐨勮妭鐐� 鎰忔�濆氨鏄綋鍓嶆病鏈夋樉绀� 绛夊埌鍒囧洖鎴樻枟鐨勬椂鍊欏啀閫氳繃BattleField.UpdateCanvas鏉ユ洿鏂�
if (canvas != null)
{
@@ -278,6 +323,32 @@
}
+ void LateUpdate()
+ {
+ if (string.IsNullOrEmpty(sortingLayer))
+ {
+ return;
+ }
+
+ OnSortingChanged(sortingLayer, sortingOrder);
+ }
+
+ public string sortingLayer;
+ public int sortingOrder;
+
+ protected void OnSortingChanged(string _sortingLayer, int _sortingOrder)
+ {
+ sortingLayer = _sortingLayer;
+ sortingOrder = _sortingOrder;
+ // 澶勭悊鎺掑簭鍙樺寲
+ var renderers = spineComp.GetComponents<Renderer>();
+ foreach (var renderer in renderers)
+ {
+ renderer.sortingLayerName = sortingLayer;
+ renderer.sortingOrder = sortingOrder;
+ }
+ }
+
protected void OnDestroy()
{
if (onDestroy != null)
--
Gitblit v1.8.0