首次提交
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
namespace ScrewsMaster
|
||||
{
|
||||
public class LoadingCtrl : BaseCtrl
|
||||
{
|
||||
public static LoadingCtrl Instance { get; private set; }
|
||||
|
||||
private LoadingModel model;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 341654c8a54544e9aefdab73ec4873a4
|
||||
timeCreated: 1676622067
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace ScrewsMaster
|
||||
{
|
||||
public class LoadingModel : BaseModel
|
||||
{
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fcfcdf9f5d1c4197b3049bca9336855a
|
||||
timeCreated: 1676622067
|
||||
@@ -0,0 +1,170 @@
|
||||
using DG.Tweening;
|
||||
|
||||
namespace ScrewsMaster
|
||||
{
|
||||
using System;
|
||||
using System.Collections;
|
||||
using FairyGUI;
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
public class LoadingUI : BaseUI
|
||||
{
|
||||
private LoadingUICtrl ctrl;
|
||||
private LoadingModel model;
|
||||
private FGUI.SLoading.com_loading ui;
|
||||
|
||||
protected GProgressBar pb_loading;
|
||||
private Tweener tweener;
|
||||
private Action closeCallback;
|
||||
|
||||
|
||||
protected int currValue;
|
||||
|
||||
public LoadingUI(LoadingUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.LoadingUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "SLoading";
|
||||
uiInfo.assetName = "com_loading";
|
||||
uiInfo.layerType = UILayerType.Loading;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = false;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.SLoading.com_loading;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
|
||||
// var login = FXManager.Instance.SetFx<SkeletonAnimation>(ui.title_parent, Fx_Type.fx_title, ref closeCallback);
|
||||
// login.state.SetAnimation(0, "animation", true);
|
||||
// var rabbit = FXManager.Instance.SetFx<SkeletonAnimation>(ui.logo_parent, Fx_Type.fx_rabbit, ref closeCallback);
|
||||
// rabbit.state.SetAnimation(0, "animation", true);
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenBgUI_Open);
|
||||
pb_loading = this.ui.pb_loading;
|
||||
pb_loading.max = 100;
|
||||
pb_loading.value = 0;
|
||||
// DOVirtual.Float(0, 100, 2.8f, (value) =>
|
||||
// {
|
||||
// // ui.pb_loading.title = $"Loading...{(int)value}%";
|
||||
|
||||
// ui.pb_loading.value = (int)value;
|
||||
// });
|
||||
CrazyAsyKit.StartCoroutine(SetProgressState());
|
||||
|
||||
var splashCanvas = GameObject.Find("SplashCanvas");
|
||||
if (splashCanvas != null)
|
||||
{
|
||||
splashCanvas.SetActive(false);
|
||||
Object.Destroy(splashCanvas);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator SetProgressState()
|
||||
{
|
||||
tweener = DOTween.To(() => ui.pb_loading.value,
|
||||
x => ui.pb_loading.value = x, 97, 5.0f).SetEase(Ease.Linear);
|
||||
|
||||
// RotateImageObject();
|
||||
ui.pb_loading.grip.TweenRotate(1800, 5) // 1 秒内旋转 360 度
|
||||
.SetEase(EaseType.Linear);
|
||||
ui.pb_loading.grip.TweenMoveX(ui.pb_loading.grip.x + ui.pb_loading.Progress.width - ui.pb_loading.grip.width, 5).SetEase(EaseType.Linear);
|
||||
|
||||
|
||||
yield return tweener;
|
||||
}
|
||||
|
||||
|
||||
private int _loopCount = 0;
|
||||
private const int maxLoops = 5; // 设定最大循环次数
|
||||
void RotateImageObject()
|
||||
{
|
||||
// 如果旋转次数还没有达到最大值,继续旋转
|
||||
if (_loopCount < maxLoops)
|
||||
{
|
||||
// 使用 FairyGUI 自带的 TweenRotate 让图片旋转 360 度
|
||||
ui.pb_loading.grip.TweenRotate(359, 1f) // 1 秒内旋转 360 度
|
||||
.SetEase(EaseType.Linear) // 匀速旋转
|
||||
.OnComplete(() =>
|
||||
{
|
||||
_loopCount++; // 每次完成后递增计数
|
||||
RotateImageObject(); // 递归调用实现循环
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Rotation completed 5 times");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.UpdateHotFixMax, OnUpdateHotFixMax);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.UpdateHotFixProgress, OnUpdateHotFixProgress);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.UpdateHotFixMax, OnUpdateHotFixMax);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.UpdateHotFixProgress, OnUpdateHotFixProgress);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private bool isAgree = true;
|
||||
|
||||
public void CheckAgree()
|
||||
{
|
||||
if (!isAgree) return;
|
||||
ctrl.CloseUI();
|
||||
}
|
||||
|
||||
private void OnUpdateHotFixMax(object obj)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
var max = (int)obj;
|
||||
// ui.pb_loading.max = max;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnUpdateHotFixProgress(object obj)
|
||||
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
tweener.Kill();
|
||||
var value = (int)obj;
|
||||
pb_loading.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0873adccf5e64e15a037be3341254d6c
|
||||
timeCreated: 1676622067
|
||||
@@ -0,0 +1,70 @@
|
||||
namespace ScrewsMaster
|
||||
{
|
||||
public class LoadingUICtrl : BaseUICtrl
|
||||
{
|
||||
private LoadingUI ui;
|
||||
private LoadingModel model;
|
||||
|
||||
private uint openUIMsg = 0;
|
||||
private uint closeUIMsg = 0;
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OpenUI(object args = null)
|
||||
{
|
||||
if (ui == null)
|
||||
{
|
||||
ui = new LoadingUI(this);
|
||||
ui.Open(args);
|
||||
}
|
||||
}
|
||||
|
||||
public override void CloseUI(object args = null)
|
||||
{
|
||||
if (ui is { isClose: false })
|
||||
{
|
||||
ui.Close();
|
||||
}
|
||||
|
||||
ui = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public override uint GetOpenUIMsg(string uiName)
|
||||
{
|
||||
return openUIMsg;
|
||||
}
|
||||
|
||||
public override uint GetCloseUIMsg(string uiName)
|
||||
{
|
||||
return closeUIMsg;
|
||||
}
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
AppDispatcher.Instance.AddListener(AppMsg.UI_DisplayLoadingUI, OpenUI);
|
||||
AppDispatcher.Instance.AddListener(AppMsg.UI_HideLoadingUI, OnHideLoading);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
AppDispatcher.Instance.RemoveListener(AppMsg.UI_DisplayLoadingUI, OpenUI);
|
||||
AppDispatcher.Instance.RemoveListener(AppMsg.UI_HideLoadingUI, OnHideLoading);
|
||||
}
|
||||
|
||||
private void OnHideLoading(object obj)
|
||||
{
|
||||
if (ui == null) return;
|
||||
ui.CheckAgree();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f7cb8eec2bb493fb2e95f287120770e
|
||||
timeCreated: 1676622067
|
||||
Reference in New Issue
Block a user