2026-04-22 09:52:55 +08:00
|
|
|
using System;
|
2026-04-22 11:13:16 +08:00
|
|
|
using FGUI.ZM_Common_01;
|
|
|
|
|
using SGModule.NetKit;
|
2026-04-22 09:52:55 +08:00
|
|
|
using Spine.Unity;
|
|
|
|
|
|
2026-04-27 11:20:13 +08:00
|
|
|
namespace RedHotRoast
|
2026-04-22 09:52:55 +08:00
|
|
|
{
|
|
|
|
|
public class AddViewUI : BaseUI
|
|
|
|
|
{
|
|
|
|
|
private AddViewUICtrl ctrl;
|
|
|
|
|
private AddViewModel model;
|
2026-04-22 11:13:16 +08:00
|
|
|
private FGUI.ZM_AddCell_12.com_addView ui;
|
2026-04-22 09:52:55 +08:00
|
|
|
public int ad_cool_down = 120;
|
|
|
|
|
public btn_watchAd btn_WatchAd;
|
|
|
|
|
|
|
|
|
|
public AddViewUI(AddViewUICtrl ctrl) : base(ctrl)
|
|
|
|
|
{
|
|
|
|
|
uiName = UIConst.AddViewUI;
|
|
|
|
|
this.ctrl = ctrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void SetUIInfo(UIInfo uiInfo)
|
|
|
|
|
{
|
2026-04-22 11:13:16 +08:00
|
|
|
uiInfo.packageName = "ZM_AddCell_12";
|
2026-04-22 09:52:55 +08:00
|
|
|
uiInfo.assetName = "com_addView";
|
|
|
|
|
uiInfo.layerType = UILayerType.Popup;
|
|
|
|
|
uiInfo.isNeedOpenAnim = false;
|
|
|
|
|
uiInfo.isNeedCloseAnim = false;
|
|
|
|
|
uiInfo.isNeedUIMask = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 生命周期
|
|
|
|
|
protected override void OnInit()
|
|
|
|
|
{
|
|
|
|
|
//model = ModuleManager.Instance.GetModel(ModelConst.AddViewModel) as AddViewModel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnClose()
|
|
|
|
|
{
|
|
|
|
|
GameHelper.showGameUI = true;
|
2026-04-22 11:13:16 +08:00
|
|
|
// HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
|
2026-04-22 09:52:55 +08:00
|
|
|
if (GameHelper.IsAdModelOfPay())
|
|
|
|
|
{
|
2026-04-22 11:13:16 +08:00
|
|
|
AdExchangeManager.Instance.Destroy();
|
2026-04-22 09:52:55 +08:00
|
|
|
}
|
2026-04-22 11:13:16 +08:00
|
|
|
if (need_call) GameHelper.CallShowTurn();
|
2026-04-22 09:52:55 +08:00
|
|
|
}
|
2026-04-22 11:13:16 +08:00
|
|
|
private bool need_call;
|
2026-04-22 09:52:55 +08:00
|
|
|
protected override void OnBind()
|
|
|
|
|
{
|
2026-04-22 11:13:16 +08:00
|
|
|
ui = baseUI as FGUI.ZM_AddCell_12.com_addView;
|
2026-04-22 09:52:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnOpenBefore(object args)
|
|
|
|
|
{
|
2026-04-22 11:13:16 +08:00
|
|
|
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.buy_one_show);
|
|
|
|
|
if (args != null) need_call = (bool)args;
|
2026-04-22 09:52:55 +08:00
|
|
|
// ad_cool_down = ConfigSystem.GetConfig<CommonModel>().exchangeCD;
|
|
|
|
|
// btn_WatchAd = ui.btn_watch as btn_watchAd;
|
2026-04-22 11:13:16 +08:00
|
|
|
if (GameHelper.IsAdModelOfPay())
|
2026-04-22 09:52:55 +08:00
|
|
|
{
|
2026-04-22 11:13:16 +08:00
|
|
|
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.buy_one), ui.btn_watch as btn_watchAd, SetTextString);
|
2026-04-22 09:52:55 +08:00
|
|
|
ui.pay_type.selectedIndex = 0;
|
|
|
|
|
|
|
|
|
|
|
2026-04-22 11:13:16 +08:00
|
|
|
AdExchangeManager.Instance.Start();
|
2026-04-22 09:52:55 +08:00
|
|
|
SetTextString();
|
|
|
|
|
}
|
2026-04-22 11:13:16 +08:00
|
|
|
else
|
2026-04-22 09:52:55 +08:00
|
|
|
{
|
|
|
|
|
ui.pay_type.selectedIndex = 1;
|
|
|
|
|
decimal price = (decimal)GameHelper.GetCommonModel().addspace2;
|
|
|
|
|
ui.btn_max_pay.title = GameHelper.getPrice(price);
|
|
|
|
|
ui.btn_max_pay.SetClick(() =>
|
|
|
|
|
{
|
|
|
|
|
ApplePayClass maxPayData = new ApplePayClass
|
|
|
|
|
{
|
|
|
|
|
amount = (int)Math.Round(price * 100),
|
2026-04-22 11:13:16 +08:00
|
|
|
sku =PurchasingManager.GetPaySku(PayType.buy_one),
|
2026-04-22 09:52:55 +08:00
|
|
|
currency = "USD"
|
|
|
|
|
};
|
|
|
|
|
MaxPayManager.Instance.Buy(maxPayData);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
InitView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnOpen(object args)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHide()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnDisplay(object args)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 消息
|
|
|
|
|
protected override void AddListener()
|
|
|
|
|
{
|
|
|
|
|
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
protected override void RemoveListener()
|
|
|
|
|
{
|
|
|
|
|
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
void pay_success(object str)
|
|
|
|
|
{
|
|
|
|
|
string type = (string)str;
|
|
|
|
|
|
2026-04-22 11:13:16 +08:00
|
|
|
if (type == PurchasingManager.GetPaySku(PayType.buy_one))
|
2026-04-22 09:52:55 +08:00
|
|
|
{
|
|
|
|
|
CtrlCloseUI();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-22 11:13:16 +08:00
|
|
|
private Action closeCallback = null;
|
|
|
|
|
|
2026-04-22 09:52:55 +08:00
|
|
|
//初始化页面逻辑
|
|
|
|
|
private void InitView()
|
|
|
|
|
{
|
2026-04-22 11:13:16 +08:00
|
|
|
|
|
|
|
|
|
2026-04-27 10:11:52 +08:00
|
|
|
// var add = FXManager.Instance.SetFx<SkeletonAnimation>(ui.anim_bg, Fx_Type.fx_add_box, ref closeCallback);
|
|
|
|
|
// add.state.SetAnimation(0, "animation", true);
|
|
|
|
|
//
|
2026-04-22 11:13:16 +08:00
|
|
|
|
2026-04-22 09:52:55 +08:00
|
|
|
ui.btn_close.SetClick(() =>
|
|
|
|
|
{
|
|
|
|
|
CtrlCloseUI();
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-22 11:13:16 +08:00
|
|
|
// HallManager.Instance.UpdateSecondEvent += updateWatchCD;
|
|
|
|
|
// updateWatchCD();
|
2026-04-22 09:52:55 +08:00
|
|
|
|
|
|
|
|
// checkBtnState();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetTextString()
|
|
|
|
|
{
|
2026-04-22 11:13:16 +08:00
|
|
|
var need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.buy_one));
|
|
|
|
|
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
|
2026-04-22 09:52:55 +08:00
|
|
|
|
2026-04-27 10:11:52 +08:00
|
|
|
ui.text_watch_ad.SetVar("needNum", need.ToString()).FlushVars();
|
|
|
|
|
ui.tips.SetVar("needAds", need.ToString()).FlushVars();
|
|
|
|
|
ui.tips.SetVar("myAds", myAd.ToString()).FlushVars();
|
2026-04-22 09:52:55 +08:00
|
|
|
}
|
|
|
|
|
}
|
2026-04-22 11:13:16 +08:00
|
|
|
}
|