/// #pkgName FGUI包名 /// #panelName UIPanel名字 /// #UIName = $"{#pkgName}{#panelName}" UIKey名字 /// 该脚本由模板创建 /// created by cb 2024 using DG.Tweening; using FL.Battle.Actions; using System; using UnityEngine; using XGame.Framework; using XGame.Framework.UI; namespace FL.FGUI { public class FlyingIconParam { public bool bScore; public Vector3 startPos; public Vector3 endPos; public string iconName; public Action callback; } /// /// UI逻辑处理类 /// /// public partial class DragonEggFlyIconCtrl : UIController { private MoveBezierAction _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.delay = UnityEngine.Random.Range(0, 200); _actMove.args.ease = Ease.InOutSine; _actMove.args.onComplete = () => { ClearMove(); flyingParam?.callback?.Invoke(flyingParam.bScore); }; _actMove.Start(VM.Tr, false); } private void ClearMove() { if (_actMove != null) { ObjectPool.Recycle(_actMove); _actMove = null; } } } }