187 lines
6.4 KiB
C#
187 lines
6.4 KiB
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
using FairyGUI;
|
||
|
|
using BingoBrain.Core;
|
||
|
|
|
||
|
|
using BingoBrain;
|
||
|
|
using FGUI.G009_video_animal;
|
||
|
|
using FGUI.Common_animal;
|
||
|
|
using System;
|
||
|
|
|
||
|
|
namespace BingoBrain
|
||
|
|
{
|
||
|
|
public class PassunlockUI : BaseUI
|
||
|
|
{
|
||
|
|
private PassunlockUICtrl ctrl;
|
||
|
|
private PassunlockModel model;
|
||
|
|
private FGUI.G009_video_animal.com_passunlock ui;
|
||
|
|
|
||
|
|
public PassunlockUI(PassunlockUICtrl ctrl) : base(ctrl)
|
||
|
|
{
|
||
|
|
uiName = UIConst.PassunlockUI;
|
||
|
|
this.ctrl = ctrl;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void SetUIInfo(UIInfo uiInfo)
|
||
|
|
{
|
||
|
|
uiInfo.packageName = "G009_video_animal";
|
||
|
|
uiInfo.assetName = "com_passunlock";
|
||
|
|
uiInfo.layerType = UILayerType.Popup;
|
||
|
|
uiInfo.isNeedOpenAnim = false;
|
||
|
|
uiInfo.isNeedCloseAnim = false;
|
||
|
|
uiInfo.isNeedUIMask = true;
|
||
|
|
}
|
||
|
|
|
||
|
|
#region 生命周期
|
||
|
|
protected override void OnInit()
|
||
|
|
{
|
||
|
|
//model = ModuleManager.Instance.GetModel(ModelConst.PassunlockModel) as PassunlockModel;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnClose()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnBind()
|
||
|
|
{
|
||
|
|
ui = baseUI as FGUI.G009_video_animal.com_passunlock;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected override void OnOpenBefore(object args)
|
||
|
|
{
|
||
|
|
InitView();
|
||
|
|
ui.btn_close.SetClick(CtrlCloseUI);
|
||
|
|
int gold = 0;
|
||
|
|
|
||
|
|
List<Passportrewards> Passportrewards_list = ConfigSystem.GetConfig<PassportrewardsModel>().dataList;
|
||
|
|
for (int i = 0; i < Passportrewards_list.Count; i++)
|
||
|
|
{
|
||
|
|
|
||
|
|
if (Passportrewards_list[i].Paid_rewards_type == 0) gold += Passportrewards_list[i].Paid_rewards_num;
|
||
|
|
|
||
|
|
}
|
||
|
|
ui.text_allgold.text = gold.ToString();
|
||
|
|
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event,BuriedPointEvent.pass_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);
|
||
|
|
if (GameHelper.IsAdModelOfPay()){
|
||
|
|
Hall.Instance.UpdateSecondEvent += InitView;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
protected override void RemoveListener()
|
||
|
|
{
|
||
|
|
if (GameHelper.IsAdModelOfPay()){
|
||
|
|
Hall.Instance.UpdateSecondEvent -= InitView;
|
||
|
|
}
|
||
|
|
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||
|
|
}
|
||
|
|
#endregion
|
||
|
|
void pay_success(object str)
|
||
|
|
{
|
||
|
|
string type = (string)str;
|
||
|
|
if (type == PurchasingManager.battle_pass)
|
||
|
|
{
|
||
|
|
CtrlCloseUI();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
//初始化页面逻辑
|
||
|
|
private void InitView()
|
||
|
|
{
|
||
|
|
if (!GameHelper.IsAdModelOfPay())
|
||
|
|
{
|
||
|
|
ui.pay_type.selectedIndex = 1;
|
||
|
|
decimal price = (decimal)GameHelper.GetCommonModel().Passportgift2;
|
||
|
|
ui.btn_max_pay.title = GameHelper.Get102Str(price);
|
||
|
|
if (GameHelper.IsGiftSwitch() && ConfigSystem.GetConfig<CommonModel>().PiggyBankSwitch == 1) (ui.btn_max_pay.GetChild("img_saveingpot") as GImage).visible = true;
|
||
|
|
ui.btn_max_pay.SetClick(() => {
|
||
|
|
MaxPayClass maxPayData = new()
|
||
|
|
{
|
||
|
|
amount = (int)Math.Round(price * 100),
|
||
|
|
sku = MaxPayManager.battle_pass,
|
||
|
|
currency = "USD"
|
||
|
|
};
|
||
|
|
MaxPayManager.Instance.Buy(maxPayData);
|
||
|
|
});
|
||
|
|
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
ui.pay_type.selectedIndex = 0;
|
||
|
|
|
||
|
|
btn_green btn_buypass = ui.btn_buypass as btn_green;
|
||
|
|
|
||
|
|
ui.text_have.text = "Owner ADs:" + SaveData.GetSaveobject().look_ad_numbers;
|
||
|
|
ui.need_text.text = "need " + ConfigSystem.GetConfig<CommonModel>().Passportgift + " ADs";
|
||
|
|
btn_buypass.img_saveingpot.visible = false;
|
||
|
|
if (SaveData.GetSaveobject().look_ad_numbers >= ConfigSystem.GetConfig<CommonModel>().Passportgift)
|
||
|
|
{
|
||
|
|
btn_buypass.state.selectedIndex = 1;
|
||
|
|
btn_buypass.cooldown.selectedIndex = 0;
|
||
|
|
ui.btn_buypass.SetClick(() =>
|
||
|
|
{
|
||
|
|
ApplePayClass test = new ApplePayClass()
|
||
|
|
{
|
||
|
|
|
||
|
|
sku = PurchasingManager.battle_pass,
|
||
|
|
|
||
|
|
};
|
||
|
|
SaveData.GetSaveobject().look_ad_numbers -= (int)ConfigSystem.GetConfig<CommonModel>().Passportgift;
|
||
|
|
PurchasingManager.Instance.Purchase(PurchasingManager.battle_pass, test);
|
||
|
|
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_pay_event, BuriedPointEvent.pass_success, 1);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
else if (SaveData.GetSaveobject().look_ad_time > GameHelper.GetNowTime())
|
||
|
|
{
|
||
|
|
btn_buypass.state.selectedIndex = 0;
|
||
|
|
btn_buypass.cooldown.selectedIndex = 1;
|
||
|
|
btn_buypass.text = GameHelper.TimeFormat(SaveData.GetSaveobject().look_ad_time - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
|
||
|
|
btn_buypass.SetClick(() =>
|
||
|
|
{
|
||
|
|
|
||
|
|
|
||
|
|
});
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
btn_buypass.state.selectedIndex = 0;
|
||
|
|
btn_buypass.cooldown.selectedIndex = 0;
|
||
|
|
btn_buypass.text = "Watch AD";
|
||
|
|
if (GameHelper.IsGiftSwitch() && ConfigSystem.GetConfig<CommonModel>().PiggyBankSwitch == 1) btn_buypass.img_saveingpot.visible = true;
|
||
|
|
btn_buypass.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.pass_click, 1);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|