ball 项目提交
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
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 BallKingdomCrush
|
||||
{
|
||||
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,139 @@
|
||||
using DG.Tweening;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
using System.Collections;
|
||||
using FairyGUI;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
public class LoadingUI : BaseUI
|
||||
{
|
||||
private LoadingUICtrl ctrl;
|
||||
private LoadingModel model;
|
||||
private FGUI.ZM_Loading_25.com_loading ui;
|
||||
|
||||
protected GProgressBar pb_loading;
|
||||
private Tweener tweener;
|
||||
|
||||
|
||||
protected int currValue;
|
||||
|
||||
public LoadingUI(LoadingUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.LoadingUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_Loading_25";
|
||||
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()
|
||||
{
|
||||
tweener.Kill();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.ZM_Loading_25.com_loading;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
var lang = PlayerPrefsKit.ReadString("LangIdKey");
|
||||
if (lang.IsNullOrWhiteSpace())
|
||||
{
|
||||
lang = "en";
|
||||
}
|
||||
UIManager.Instance.SetSwitchLanguage(lang);
|
||||
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenBgUI_Open);
|
||||
ui.com_pb.max = 100;
|
||||
ui.com_pb.value = 0;
|
||||
|
||||
CrazyAsyKit.StartCoroutine(SetProgress());
|
||||
}
|
||||
|
||||
private IEnumerator SetProgress()
|
||||
{
|
||||
tweener.Kill();
|
||||
tweener = DOTween.To(() => ui.com_pb.value,
|
||||
x => ui.com_pb.value = x, 98, 12.0f);
|
||||
|
||||
yield return tweener;
|
||||
}
|
||||
|
||||
private void Reconnection(object obj = null) {
|
||||
CrazyAsyKit.StartCoroutine(SetProgress());
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.UpdateHotFixMax, OnUpdateHotFixMax);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.UpdateHotFixProgress, OnUpdateHotFixProgress);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.Network_reconnection, Reconnection);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.UpdateHotFixMax, OnUpdateHotFixMax);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.UpdateHotFixProgress, OnUpdateHotFixProgress);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.Network_reconnection, Reconnection);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private bool isAgree = true;
|
||||
|
||||
public void CheckAgree()
|
||||
{
|
||||
tweener.Kill();
|
||||
tweener = DOTween.To(() => ui.com_pb.value,
|
||||
x => ui.com_pb.value = x, 100, 0.1f).OnComplete(() =>
|
||||
{
|
||||
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 BallKingdomCrush
|
||||
{
|
||||
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