1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- /// #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<bool> callback;
- }
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class DragonEggFlyIconCtrl : UIController<DragonEggFlyIconVM>
- {
- 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.ScaleAni.Play();
- }
- private void PlayFlyingAni(FlyingIconParam flyingParam)
- {
- _actMove = ObjectPool.Acquire<UIMoveBezierAction>();
- _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;
- }
- }
- }
- }
|