Files
RedHotRoast-ios/Assets/Scripts/ModuleUI/OpenGame/OpenGameUI.cs
T

151 lines
4.3 KiB
C#
Raw Normal View History

2026-04-22 09:52:55 +08:00
using System;
2026-07-13 15:47:20 +08:00
using System.Linq;
2026-04-22 09:52:55 +08:00
using DG.Tweening;
using Newtonsoft.Json;
2026-04-22 09:52:55 +08:00
using Spine.Unity;
using UnityEngine;
2026-04-22 09:52:55 +08:00
namespace RedHotRoast
2026-04-22 09:52:55 +08:00
{
public class OpenGameUI : BaseUI
{
private OpenGameUICtrl ctrl;
private OpenGameModel model;
private FGUI.ZM_Game_04.com_open ui;
2026-04-22 09:52:55 +08:00
public OpenGameUI(OpenGameUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.OpenGameUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_Game_04";
2026-04-22 09:52:55 +08:00
uiInfo.assetName = "com_open";
uiInfo.layerType = UILayerType.Highest;
2026-04-22 09:52:55 +08:00
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = false;
}
#region 生命周期
protected override void OnInit()
{
// model = ModuleManager.Instance.GetModel(ModelConst.OpenGameModel) as OpenGameModel;
}
protected override void OnClose()
{
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_Game_04.com_open;
2026-04-22 09:52:55 +08:00
}
protected override void OnOpenBefore(object args)
{
ui.state.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;
if (GameHelper.IsGiftSwitch())
{
2026-07-13 15:47:20 +08:00
SetLevelText();
((FGUI.ZM_Common_01.com_open_tips)ui.com_tips).t0.Play(() =>
{
DOVirtual.DelayedCall(0.2f, () =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenGameUI_Close);
});
});
return;
}
2026-04-22 09:52:55 +08:00
DOVirtual.DelayedCall(0.7f, () => { GameDispatcher.Instance.Dispatch(GameMsg.reset_game, args); });
InitView();
if (AudioManager.Instance.IsOpenEffect)
{
AudioManager.Instance.PlayDynamicEffect(AudioConst.game_open);
}
2026-04-22 09:52:55 +08:00
}
2026-07-13 15:47:20 +08:00
private void SetLevelText()
{
try
{
// 添加空值检查,防止 NullReferenceException
if (DataMgr.MakeupTaskHistory != null)
{
var makeupTaskHistory = DataMgr.MakeupTaskHistory?.Value;
if (makeupTaskHistory != null && makeupTaskHistory.Any())
{
var makeupTaskData = makeupTaskHistory.Last();
var config = MakeupModel.GetData(makeupTaskData.tableId);
if (config != null)
{
var textLevelLimit = ((FGUI.ZM_Common_01.com_open_tips)ui.com_tips).text_level_limit;
if (textLevelLimit != null)
{
var stage = config.levels_need - GameHelper.GetLevel();
if (stage <= 0)
{
stage = 1;
}
textLevelLimit.SetVar("x", stage.ToString()).FlushVars();
}
}
}
}
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
2026-04-22 09:52:55 +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
private Action closeCallback;
//初始化页面逻辑
private void InitView()
{
string stage = GameHelper.gameType == 0 ? Language.GetContentParams("need_lv_text", GameHelper.GetLevel()) : "";
2026-04-22 09:52:55 +08:00
ui.text_level.text = stage;
DOVirtual.DelayedCall(1.5f, () =>
2026-04-22 09:52:55 +08:00
{
2026-04-27 10:11:52 +08:00
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenGameUI_Close);
});
2026-04-22 09:52:55 +08:00
}
}
}