Files
barry 7deaa15511 fix:1、更换loading界面
2、修复bug,open等级添加

Signed-off-by: barry <barry@gmail.com>
2026-07-13 15:47:20 +08:00

151 lines
4.3 KiB
C#

using System;
using System.Linq;
using DG.Tweening;
using Newtonsoft.Json;
using Spine.Unity;
using UnityEngine;
namespace RedHotRoast
{
public class OpenGameUI : BaseUI
{
private OpenGameUICtrl ctrl;
private OpenGameModel model;
private FGUI.ZM_Game_04.com_open ui;
public OpenGameUI(OpenGameUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.OpenGameUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_Game_04";
uiInfo.assetName = "com_open";
uiInfo.layerType = UILayerType.Highest;
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;
}
protected override void OnOpenBefore(object args)
{
ui.state.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;
if (GameHelper.IsGiftSwitch())
{
SetLevelText();
((FGUI.ZM_Common_01.com_open_tips)ui.com_tips).t0.Play(() =>
{
DOVirtual.DelayedCall(0.2f, () =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenGameUI_Close);
});
});
return;
}
DOVirtual.DelayedCall(0.7f, () => { GameDispatcher.Instance.Dispatch(GameMsg.reset_game, args); });
InitView();
if (AudioManager.Instance.IsOpenEffect)
{
AudioManager.Instance.PlayDynamicEffect(AudioConst.game_open);
}
}
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;
}
}
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()) : "";
ui.text_level.text = stage;
DOVirtual.DelayedCall(1.5f, () =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenGameUI_Close);
});
}
}
}