ball 项目提交
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class FXWndCtrl : BaseCtrl
|
||||
{
|
||||
public static FXWndCtrl Instance { get; private set; }
|
||||
|
||||
private FXWndModel model;
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void AddServerListener()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void RemoveServerListener()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ba389480d8644e5bb9fae2d8eb324f0
|
||||
timeCreated: 1671086538
|
||||
@@ -0,0 +1,51 @@
|
||||
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class FXWndModel : BaseModel
|
||||
{
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
// protected override void OnReset()
|
||||
// {
|
||||
// }
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region 读取数据
|
||||
|
||||
// protected override void OnReadData()
|
||||
// {
|
||||
// }
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region 本地存储
|
||||
|
||||
// protected override void WriteLocalStorage()
|
||||
// {
|
||||
// }
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c48389d259bf411e80143844af2b2591
|
||||
timeCreated: 1671086538
|
||||
@@ -0,0 +1,192 @@
|
||||
using System;
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
using Spine.Unity;
|
||||
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class FXWndUI : BaseUI
|
||||
{
|
||||
private FXWndUICtrl ctrl;
|
||||
private FXWndModel model;
|
||||
private FGUI.ZM_Fx_502.com_FX ui;
|
||||
|
||||
private Transform parTrf;
|
||||
|
||||
public FXWndUI(FXWndUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.FXWndUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_Fx_502";
|
||||
uiInfo.assetName = "com_FX";
|
||||
uiInfo.layerType = UILayerType.Animation;
|
||||
}
|
||||
|
||||
public void PlayFx(FxPlayData fxPlayData)
|
||||
{
|
||||
FxPlayData data = fxPlayData;
|
||||
GameObject arg = null;
|
||||
Transform trf = null;
|
||||
Action recFx = null;
|
||||
if (data.isParticleSystem)
|
||||
{
|
||||
ParticleSystem system = FXManager.Instance.GetFx<ParticleSystem>(data.fxType);
|
||||
system.Play();
|
||||
arg = system.gameObject;
|
||||
trf = system.transform;
|
||||
recFx = delegate { FXManager.Instance.RecFx<ParticleSystem>(data.fxType, system); };
|
||||
}
|
||||
else
|
||||
{
|
||||
SkeletonAnimation system = FXManager.Instance.GetFx<SkeletonAnimation>(data.fxType);
|
||||
trf = system.transform;
|
||||
arg = system.gameObject;
|
||||
recFx = delegate { FXManager.Instance.RecFx<SkeletonAnimation>(data.fxType, system); };
|
||||
}
|
||||
|
||||
trf.SetParent(parTrf);
|
||||
arg.SetLayer("UI");
|
||||
Action cb = SetSortingOrder(arg);
|
||||
data.endEvent += (e) => cb?.Invoke();
|
||||
|
||||
Vector3 startPot = GameHelper.FguiPotToUnityTrfLocalPot(data.startPot);
|
||||
|
||||
trf.localPosition = startPot;
|
||||
trf.localScale = Vector3.one * data.size;
|
||||
trf.localEulerAngles = Vector3.zero;
|
||||
fxPlayData.startEvent?.Invoke(arg);
|
||||
|
||||
DOVirtual.DelayedCall(data.duration, () =>
|
||||
{
|
||||
data.endEvent?.Invoke(arg);
|
||||
|
||||
|
||||
recFx?.Invoke();
|
||||
|
||||
FxPlayData.Release(data);
|
||||
});
|
||||
}
|
||||
|
||||
private Action SetSortingOrder(GameObject obj)
|
||||
{
|
||||
Action action = null;
|
||||
Renderer[] renders = obj.GetComponentsInChildren<Renderer>();
|
||||
foreach (Renderer render in renders)
|
||||
{
|
||||
if (render != null)
|
||||
{
|
||||
render.sortingOrder += 300;
|
||||
action += () => { render.sortingOrder -= 300; };
|
||||
}
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.ZM_Fx_502.com_FX;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
parTrf = ui.displayObject.cachedTransform;
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class FxPlayData
|
||||
{
|
||||
private static ObjectPool<FxPlayData> _Pool = new ObjectPool<FxPlayData>();
|
||||
|
||||
public static FxPlayData Get(Fx_Type fx_Type, float _duration, Vector2 _pot)
|
||||
{
|
||||
FxPlayData data = _Pool.Get();
|
||||
if (_pot == Vector2.zero)
|
||||
{
|
||||
data.startPot = GRoot.inst.size / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
data.startPot = _pot;
|
||||
}
|
||||
|
||||
if (_duration == 0)
|
||||
{
|
||||
data.duration = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
data.duration = _duration;
|
||||
}
|
||||
|
||||
data.fxType = fx_Type;
|
||||
return data;
|
||||
}
|
||||
|
||||
public static void Release(FxPlayData data)
|
||||
{
|
||||
data.duration = 0;
|
||||
data.startEvent = null;
|
||||
data.endEvent = null;
|
||||
data.isParticleSystem = true;
|
||||
data.startPot = Vector2.zero;
|
||||
_Pool.Release(data);
|
||||
}
|
||||
|
||||
public float duration;
|
||||
|
||||
public Fx_Type fxType;
|
||||
|
||||
public bool isParticleSystem = true;
|
||||
|
||||
public Vector2 startPot;
|
||||
|
||||
public Action<GameObject> startEvent;
|
||||
|
||||
public Action<GameObject> endEvent;
|
||||
|
||||
public int size = 100;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57addc9545404bc9b81d1ffbe0d02508
|
||||
timeCreated: 1671086538
|
||||
@@ -0,0 +1,95 @@
|
||||
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class FXWndUICtrl : BaseUICtrl
|
||||
{
|
||||
private FXWndUI ui;
|
||||
private FXWndModel model;
|
||||
|
||||
private uint openUIMsg = UICtrlMsg.FXWndUI_Open;
|
||||
private uint closeUIMsg = UICtrlMsg.FXWndUI_Close;
|
||||
|
||||
private bool isOpen = false;
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OpenUI(object args = null)
|
||||
{
|
||||
if (ui == null || ui.isClose)
|
||||
{
|
||||
ui = new FXWndUI(this);
|
||||
ui.Open(args);
|
||||
}
|
||||
}
|
||||
|
||||
public override void CloseUI(object args = null)
|
||||
{
|
||||
if (ui != null && !ui.isClose)
|
||||
{
|
||||
ui.Close();
|
||||
}
|
||||
ui = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
public override uint GetOpenUIMsg(string uiName)
|
||||
{
|
||||
return openUIMsg;
|
||||
}
|
||||
public override uint GetCloseUIMsg(string uiName)
|
||||
{
|
||||
return closeUIMsg;
|
||||
}
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
|
||||
uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
|
||||
uiCtrlDispatcher.AddListener(UICtrlMsg.PlayUIFX, PlayFx);
|
||||
|
||||
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
|
||||
uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI);
|
||||
uiCtrlDispatcher.RemoveListener(UICtrlMsg.PlayUIFX, PlayFx);
|
||||
}
|
||||
|
||||
private void PlayFx(object obj)
|
||||
{
|
||||
if (!isOpen)
|
||||
{
|
||||
OpenUI();
|
||||
}
|
||||
FxPlayData fxType = (FxPlayData)obj;
|
||||
ui.PlayFx(fxType);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected override void AddServerListener()
|
||||
{
|
||||
|
||||
}
|
||||
protected override void RemoveServerListener()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e43875b511c04a81a511ab1a4bdb6c5c
|
||||
timeCreated: 1671086538
|
||||
Reference in New Issue
Block a user