Files
ArrowBeatTap-IOS/Assets/Scripts/ModuleUI/ArrowTips/ArrowTipsUI.cs
T

121 lines
3.4 KiB
C#
Raw Normal View History

2026-06-25 15:22:28 +08:00
using System;
using FGUI.Arrow_game;
using UnityEngine;
namespace ChillConnect
{
public class ArrowTipsUI : BaseUI
{
private ArrowTipsUICtrl ctrl;
private ArrowTipsModel model;
private com_tips ui;
public ArrowTipsUI(ArrowTipsUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.ArrowTipsUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "Arrow_game";
uiInfo.assetName = "com_tips";
2026-06-29 08:59:34 +08:00
uiInfo.layerType = UILayerType.Popup;
2026-06-25 15:22:28 +08:00
uiInfo.isNeedUIMask = true;
uiInfo.isNeedOpenAnim = true;
uiInfo.isNeedCloseAnim = true;
}
protected override void OnInit()
{
}
protected override void OnClose()
{
GameDispatcher.Instance.Dispatch(GameMsg.StopArrowTouch, true);
CommonHelper.FadeOut(ui);
2026-06-29 08:59:34 +08:00
HallManager.Instance.UpdateSecondEvent -= UpdateCd;
2026-06-25 15:22:28 +08:00
}
protected override void OnBind()
{
ui = baseUI as com_tips;
}
2026-06-29 08:59:34 +08:00
private int state_;
2026-06-25 15:22:28 +08:00
protected override void OnOpenBefore(object args)
{
GameDispatcher.Instance.Dispatch(GameMsg.StopArrowTouch, false);
if (args != null)
2026-06-29 08:59:34 +08:00
{
2026-06-25 15:22:28 +08:00
InitView((int)args);
2026-06-29 08:59:34 +08:00
state_ = (int)args + 5;
}
HallManager.Instance.UpdateSecondEvent += UpdateCd;
UpdateCd();
2026-06-25 15:22:28 +08:00
}
protected override void OnOpen(object args)
{
CommonHelper.FadeIn(ui);
}
protected override void AddListener()
{
}
protected override void RemoveListener()
{
}
private void InitView(int type)
{
int state = type;
Debug.Log($"tips state = {state} ");
// 0 提示 1 删除道具
ui.state.selectedIndex = state;
ui.btn_watch.SetClick(() =>
{
string idStr = state == 1 ? "deletePop" : "HintPop";
GameHelper.ShowVideoAd(idStr, isSuccess =>
{
if (isSuccess)
{
Debug.Log($"isSuccess tips state = {state} ");
2026-06-29 08:59:34 +08:00
GameHelper.SetWatchCd(state_);
2026-06-25 15:22:28 +08:00
GameDispatcher.Instance.Dispatch(GameMsg.UseProps, state);
CtrlCloseUI();
}
});
});
ui.btn_close.SetClick(CtrlCloseUI);
}
2026-06-29 08:59:34 +08:00
private void UpdateCd()
{
var btnWatch = ui.btn_watch ;
// Debug.Log($"DataMgr.NewWatchCd.Value[state_ + 2]==={DataMgr.NewWatchCd.Value[state_ + 2]}");
if (DataMgr.NewWatchCd.Value[state_] > Convert.ToInt32(GameHelper.GetNowTime()))
{
btnWatch.enabled = false;
btnWatch.can.selectedIndex = 1;
btnWatch.text.text = CommonHelper.TimeFormat(DataMgr.NewWatchCd.Value[state_] - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
}
else
{
ui.btn_watch.enabled = true;
btnWatch.can.selectedIndex = 0;
btnWatch.text.text = "Use Item";
}
}
2026-06-25 15:22:28 +08:00
}
}