123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- /// #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<bool> callback;
- }
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class DragonEggFlyIconCtrl : UIController<DragonEggFlyIconVM>
- {
- 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<MoveBezierAction>();
- _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;
- }
- }
- }
- }
|