/// #pkgName FGUI包名 /// #panelName UIPanel名字 /// #UIName = $"{#pkgName}{#panelName}" UIKey名字 /// 该脚本由模板创建 /// created by cb 2024 using DG.Tweening; using FL.FGUI.Actions; using System; using UnityEngine; using XGame.Framework; using XGame.Framework.UI; namespace FL.FGUI { public struct FlyingIconParam { public bool bScore; public Vector3 startPos; public Vector3 endPos; public string iconName; public Action callback; } /// /// UI逻辑处理类 /// /// public partial class DragonEggFlyIconCtrl : UIController { private Tween _tween; private UIMoveBezierAction _actMove; protected override void OnEnable(object intent) { AddUIListenres(); } protected override void OnDisable() { RemoveUIListenres(); ClearMove(); } #region UI事件 private void AddUIListenres() { } private void RemoveUIListenres() { } #endregion public void ShowUI(FlyingIconParam flyingParam) { VM.ItemIcon.icon = flyingParam.iconName; PlayFlyingAni(flyingParam); VM.Scale.Play(); } private void PlayFlyingAni(FlyingIconParam flyingParam) { _actMove = ObjectPool.Acquire(); _actMove.args.from = flyingParam.startPos; _actMove.args.to = flyingParam.endPos; _actMove.args.duration = 1000; _actMove.args.offset = 350; _actMove.args.delay = UnityEngine.Random.Range(0, 200); _actMove.args.ease = Ease.InOutSine; _actMove.args.onComplete = () => { ClearMove(); flyingParam.callback?.Invoke(flyingParam.bScore); }; //XGame.Log.Debug($"飞行起始坐标:{flyingParam.startPos},终点坐标:{flyingParam.endPos}"); _actMove.Start(VM); } private void ClearMove() { if (_actMove != null) { ObjectPool.Recycle(_actMove); _actMove = null; } } } }