Files
ArrowBeatTap-Gp/Assets/Scripts/ModuleUI/OpenGame/OpenGameUI.cs
T

139 lines
3.7 KiB
C#
Raw Normal View History

using System;
2026-07-01 10:26:18 +08:00
using System.Linq;
using DG.Tweening;
2026-07-01 10:26:18 +08:00
using FGUI.Common_01;
using FGUI.Game_04;
2026-07-01 10:26:18 +08:00
using IgnoreOPS;
using Spine.Unity;
namespace ChillConnect
{
public class OpenGameUI : BaseUI
{
private OpenGameUICtrl ctrl;
private OpenGameModel model;
2026-07-01 10:26:18 +08:00
private com_open_tips ui;
private Action closeCallback;
public OpenGameUI(OpenGameUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.OpenGameUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
2026-07-01 10:26:18 +08:00
uiInfo.packageName = "Common_01";
uiInfo.assetName = "com_open_tips";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
2026-07-01 10:26:18 +08:00
uiInfo.isNeedUIMask = true;
}
#region 生命周期
protected override void OnInit()
{
// model = ModuleManager.Instance.GetModel(ModelConst.OpenGameModel) as OpenGameModel;
}
protected override void OnClose()
{
}
protected override void OnBind()
{
2026-07-01 10:26:18 +08:00
ui = baseUI as com_open_tips;
}
protected override void OnOpenBefore(object args)
{
2026-07-01 10:26:18 +08:00
try
{
2026-07-01 10:26:18 +08:00
// 添加空值检查,防止 NullReferenceException
2026-07-07 14:03:12 +08:00
if (DataMgr.MakeupTaskHistory != null)
2026-07-01 10:26:18 +08:00
{
2026-07-07 14:03:12 +08:00
var makeupTaskHistory = DataMgr.MakeupTaskHistory?.Value;
if (makeupTaskHistory != null && makeupTaskHistory.Any())
2026-07-01 10:26:18 +08:00
{
2026-07-07 14:03:12 +08:00
var makeupTaskData = makeupTaskHistory.Last();
var config = ConfigSystem.GetConfig<MakeupModel>();
if (config != null)
2026-07-01 10:26:18 +08:00
{
2026-07-07 14:03:12 +08:00
var vo = config.GetData(makeupTaskData.tableId);
if (vo != null && ui != null && ui.text_level_limit != null)
2026-07-01 10:26:18 +08:00
{
2026-07-07 14:03:12 +08:00
var stage = vo.levels_need - GameHelper.GetLevel();
if (stage <= 0)
{
stage = 1;
}
ui.text_level_limit.SetVar("x", stage.ToString()).FlushVars();
2026-07-01 10:26:18 +08:00
}
}
}
}
}
2026-07-01 10:26:18 +08:00
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
2026-07-07 14:03:12 +08:00
// 添加 ui 空值检查
if (ui != null)
{
InitView();
}
2026-07-01 10:26:18 +08:00
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region 消息
protected override void AddListener()
{
}
protected override void RemoveListener()
{
}
#endregion
2026-07-07 14:03:12 +08:00
//初始化页面逻辑
private void InitView()
{
2026-07-07 14:03:12 +08:00
// 添加空值检查
if (ui == null || ui.t0 == null)
{
return;
}
2026-07-01 10:26:18 +08:00
ui.t0.Play(() =>
{
2026-07-01 10:26:18 +08:00
DOVirtual.DelayedCall(0.2f, () =>
{
2026-07-07 14:03:12 +08:00
if (UICtrlDispatcher.Instance != null)
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenGameUI_Close);
}
2026-07-01 10:26:18 +08:00
});
});
2026-07-01 10:26:18 +08:00
}
}
}