182 lines
6.1 KiB
C#
182 lines
6.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
using FairyGUI;
|
|
using BingoBrain.Core;
|
|
|
|
using BingoBrain;
|
|
using FGUI.G006_menu_animal;
|
|
using FGUI.Common_animal;
|
|
using System;
|
|
|
|
namespace BingoBrain
|
|
{
|
|
public class BuyslotUI : BaseUI
|
|
{
|
|
private BuyslotUICtrl ctrl;
|
|
private BuyslotModel model;
|
|
private FGUI.G006_menu_animal.com_buyslot ui;
|
|
|
|
public BuyslotUI(BuyslotUICtrl ctrl) : base(ctrl)
|
|
{
|
|
uiName = UIConst.BuyslotUI;
|
|
this.ctrl = ctrl;
|
|
}
|
|
|
|
protected override void SetUIInfo(UIInfo uiInfo)
|
|
{
|
|
uiInfo.packageName = "G006_menu_animal";
|
|
uiInfo.assetName = "com_buyslot";
|
|
uiInfo.layerType = UILayerType.Popup;
|
|
uiInfo.isNeedOpenAnim = false;
|
|
uiInfo.isNeedCloseAnim = false;
|
|
uiInfo.isNeedUIMask = true;
|
|
}
|
|
|
|
#region 生命周期
|
|
protected override void OnInit()
|
|
{
|
|
//model = ModuleManager.Instance.GetModel(ModelConst.BuyslotModel) as BuyslotModel;
|
|
}
|
|
|
|
protected override void OnClose()
|
|
{
|
|
GameHelper.showGameUI = true;
|
|
}
|
|
|
|
protected override void OnBind()
|
|
{
|
|
ui = baseUI as FGUI.G006_menu_animal.com_buyslot;
|
|
}
|
|
|
|
protected override void OnOpenBefore(object args)
|
|
{
|
|
InitView();
|
|
GameHelper.showGameUI = false;
|
|
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event,BuriedPointEvent.buy_one_show,1);
|
|
}
|
|
|
|
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);
|
|
Hall.Instance.UpdateSecondEvent += InitView;
|
|
}
|
|
protected override void RemoveListener()
|
|
{
|
|
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
|
Hall.Instance.UpdateSecondEvent -= InitView;
|
|
}
|
|
#endregion
|
|
void pay_success(object str)
|
|
{
|
|
string type = (string)str;
|
|
|
|
if (type == PurchasingManager.buy_one)
|
|
{
|
|
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.BuyslotUI_Close);
|
|
// SaveData.GetSaveobject().have_slot = true;
|
|
// SaveData.saveDataFunc();
|
|
// GameDispatcher.Instance.Dispatch(GameMsg.Slot_refresh);
|
|
CtrlCloseUI();
|
|
}
|
|
|
|
|
|
}
|
|
//初始化页面逻辑
|
|
private void InitView()
|
|
{
|
|
ui.btn_close.SetClick(CtrlCloseUI);
|
|
|
|
if (!GameHelper.IsAdModelOfPay()){
|
|
ui.pay_type.selectedIndex = 1;
|
|
if (GameHelper.IsGiftSwitch() && ConfigSystem.GetConfig<CommonModel>().PiggyBankSwitch == 1) (ui.btn_max_pay.GetChild("img_saveingpot") as GImage).visible = true;
|
|
|
|
decimal price = (decimal)GameHelper.GetCommonModel().addspace2;
|
|
ui.btn_max_pay.title = GameHelper.Get102Str(price);
|
|
ui.btn_max_pay.SetClick(() => {
|
|
MaxPayClass maxPayData = new()
|
|
{
|
|
amount = (int)Math.Round(price * 100),
|
|
sku = MaxPayManager.buy_one,
|
|
currency = "USD"
|
|
};
|
|
MaxPayManager.Instance.Buy(maxPayData);
|
|
});
|
|
|
|
|
|
return;
|
|
}
|
|
ui.pay_type.selectedIndex = 0;
|
|
|
|
ui.text_have.text = "Owner ADs:" + SaveData.GetSaveobject().look_ad_numbers;
|
|
ui.need_text.text = "need " + ConfigSystem.GetConfig<CommonModel>().addspace + " ADs";
|
|
|
|
|
|
btn_green btn_buy = ui.btn_buy as btn_green;
|
|
btn_buy.img_saveingpot.visible = false;
|
|
if (SaveData.GetSaveobject().look_ad_numbers >= ConfigSystem.GetConfig<CommonModel>().addspace)
|
|
{
|
|
btn_buy.state.selectedIndex = 1;
|
|
btn_buy.cooldown.selectedIndex = 0;
|
|
ui.btn_buy.SetClick(() =>
|
|
{
|
|
ApplePayClass test = new ApplePayClass()
|
|
{
|
|
|
|
sku = PurchasingManager.buy_one,
|
|
|
|
};
|
|
SaveData.GetSaveobject().look_ad_numbers -= (int)ConfigSystem.GetConfig<CommonModel>().addspace;
|
|
PurchasingManager.Instance.Purchase(PurchasingManager.buy_one, test);
|
|
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.buy_one_success, 1);
|
|
});
|
|
}
|
|
else if (SaveData.GetSaveobject().look_ad_time > GameHelper.GetNowTime())
|
|
{
|
|
btn_buy.state.selectedIndex = 0;
|
|
btn_buy.cooldown.selectedIndex = 1;
|
|
btn_buy.text = GameHelper.TimeFormat(SaveData.GetSaveobject().look_ad_time - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
|
|
btn_buy.SetClick(() =>
|
|
{
|
|
|
|
|
|
});
|
|
}
|
|
else
|
|
{
|
|
btn_buy.state.selectedIndex = 0;
|
|
btn_buy.cooldown.selectedIndex = 0;
|
|
btn_buy.text = "Watch AD";
|
|
if (GameHelper.IsGiftSwitch() && ConfigSystem.GetConfig<CommonModel>().PiggyBankSwitch == 1) btn_buy.img_saveingpot.visible = true;
|
|
btn_buy.SetClick(() =>
|
|
{
|
|
GameHelper.ShowVideoAd("Pass", (issuccess) =>
|
|
{
|
|
if (issuccess)
|
|
{
|
|
SaveData.GetSaveobject().look_ad_time = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().exchangeCD;
|
|
InitView();
|
|
|
|
}
|
|
});
|
|
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.buy_one_click, 1);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
} |