fix:1、接入合作方的sdk。2、支付逻辑接入sdk中的接口

This commit is contained in:
2026-05-09 09:37:34 +08:00
parent 1599bf4bbb
commit ee55c03120
1011 changed files with 167108 additions and 33552 deletions
+221 -221
View File
@@ -1,222 +1,222 @@
using System;
using FairyGUI;
using Spine.Unity;
using System.Collections.Generic;
using SGModule.NetKit;
using FGUI.ZM_Common_01;
using IgnoreOPS;
using FGUI.ZM_AddCell_12;
namespace BallKingdomCrush
{
public class AddViewUI : BaseUI
{
private AddViewUICtrl ctrl;
private AddViewModel model;
private FGUI.ZM_AddCell_12.com_addView ui;
public int ad_cool_down = 120;
public btn_watchAd btn_WatchAd;
private Action closeCallback;
private bool isAutoPop = false;
public AddViewUI(AddViewUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.AddViewUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_AddCell_12";
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;
HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
if (GameHelper.IsAdModelOfPay())
{
AdExchangeManager.Instance.Destroy();
}
if (isAutoPop)
{
GameHelper.CallShowTurn();
}
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_AddCell_12.com_addView;
}
protected override void OnOpenBefore(object args)
{
if (args != null)
{
isAutoPop = (bool)args;
}
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.buy_one_show);
// var sk = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_node as GGraph, Fx_Type.fx_add, ref closeCallback);
// sk.state.SetAnimation(0, "animation", true);
// ad_cool_down = ConfigSystem.GetCommonConf().exchangeCD;
// btn_WatchAd = ui.btn_watch as btn_watchAd;
if (GameHelper.IsAdModelOfPay())
{
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.buy_one), ui.btn_watch as btn_watchAd, SetTextString);
ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.Start();
SetTextString();
}
else
{
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),
sku = PurchasingManager.GetPaySku(PayType.buy_one),
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
if (GameHelper.IsGiftSwitch())
{
ui.broad.visible = true;
}
else
{
ui.broad.visible = false;
}
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;
if (type == PurchasingManager.GetPaySku(PayType.buy_one))
{
CtrlCloseUI();
}
}
//初始化页面逻辑
private void InitView()
{
ui.btn_close.SetClick(() =>
{
CtrlCloseUI();
GameDispatcher.Instance.Dispatch(GameMsg.resurgence_close);
});
HallManager.Instance.UpdateSecondEvent += updateWatchCD;
InitBroadCast();
// checkBtnState();
}
void updateWatchCD()
{
broadtime++;
BroadCast();
}
public void SetTextString()
{
var need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.buy_one));
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.tips.SetVar("num", need.ToString()).FlushVars();
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
}
private int broadtime = 1;
private List<string> config_name_list = LevelAttemptsModel.config_name_list;
private List<string> config_money_list = LevelAttemptsModel.config_money_list;
private List<string[]> broad_list = new List<string[]>();
private void BroadCast()
{
if (broadtime % 3 == 0)
{
(ui.broad as com_broadcast_new).t1.Play(() =>
{
broad_list.RemoveAt(0);
int name_index = UnityEngine.Random.Range(0, config_name_list.Count);
int money_index = UnityEngine.Random.Range(0, config_money_list.Count);
broad_list.Add(new string[2] { config_name_list[name_index], config_money_list[money_index] });
for (int i = 0; i < 4; i++)
{
text_list[i].text = Language.GetContentParams("congratulations_des", new[] { broad_list[i][0], broad_list[i][1] });
}
});
}
}
private List<GTextField> text_list = new List<GTextField>();
private void InitBroadCast()
{
text_list.Add((ui.broad as com_broadcast_new).text_0);
text_list.Add((ui.broad as com_broadcast_new).text_1);
text_list.Add((ui.broad as com_broadcast_new).text_2);
text_list.Add((ui.broad as com_broadcast_new).text_3);
for (int i = 0; i < 4; i++)
{
int name_index = UnityEngine.Random.Range(0, config_name_list.Count);
int money_index = UnityEngine.Random.Range(0, config_money_list.Count);
broad_list.Add(new string[2] { config_name_list[name_index], config_money_list[money_index] });
text_list[i].text = Language.GetContentParams("congratulations_des", new[] { broad_list[i][0], broad_list[i][1] });
}
}
}
using System;
using FairyGUI;
using Spine.Unity;
using System.Collections.Generic;
using SGModule.NetKit;
using FGUI.ZM_Common_01;
using IgnoreOPS;
using FGUI.ZM_AddCell_12;
namespace BallKingdomCrush
{
public class AddViewUI : BaseUI
{
private AddViewUICtrl ctrl;
private AddViewModel model;
private FGUI.ZM_AddCell_12.com_addView ui;
public int ad_cool_down = 120;
public btn_watchAd btn_WatchAd;
private Action closeCallback;
private bool isAutoPop = false;
public AddViewUI(AddViewUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.AddViewUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_AddCell_12";
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;
HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
if (GameHelper.IsAdModelOfPay())
{
AdExchangeManager.Instance.Destroy();
}
if (isAutoPop)
{
GameHelper.CallShowTurn();
}
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_AddCell_12.com_addView;
}
protected override void OnOpenBefore(object args)
{
if (args != null)
{
isAutoPop = (bool)args;
}
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.buy_one_show);
// var sk = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_node as GGraph, Fx_Type.fx_add, ref closeCallback);
// sk.state.SetAnimation(0, "animation", true);
// ad_cool_down = ConfigSystem.GetCommonConf().exchangeCD;
// btn_WatchAd = ui.btn_watch as btn_watchAd;
if (GameHelper.IsAdModelOfPay())
{
AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_SPACE_BONUS, ui.btn_watch as btn_watchAd, SetTextString);
ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.Start();
SetTextString();
}
else
{
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),
sku = IAPPayManager.PRODUCT_SPACE_BONUS,//IAPPayManager.PRODUCT_SPACE_BONUS,
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
if (GameHelper.IsGiftSwitch())
{
ui.broad.visible = true;
}
else
{
ui.broad.visible = false;
}
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.IAP_PAY_SUCCESS, pay_success);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
if (type == IAPPayManager.PRODUCT_SPACE_BONUS)
{
CtrlCloseUI();
}
}
//初始化页面逻辑
private void InitView()
{
ui.btn_close.SetClick(() =>
{
CtrlCloseUI();
GameDispatcher.Instance.Dispatch(GameMsg.resurgence_close);
});
HallManager.Instance.UpdateSecondEvent += updateWatchCD;
InitBroadCast();
// checkBtnState();
}
void updateWatchCD()
{
broadtime++;
BroadCast();
}
public void SetTextString()
{
var need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_SPACE_BONUS);
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.tips.SetVar("num", need.ToString()).FlushVars();
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
}
private int broadtime = 1;
private List<string> config_name_list = LevelAttemptsModel.config_name_list;
private List<string> config_money_list = LevelAttemptsModel.config_money_list;
private List<string[]> broad_list = new List<string[]>();
private void BroadCast()
{
if (broadtime % 3 == 0)
{
(ui.broad as com_broadcast_new).t1.Play(() =>
{
broad_list.RemoveAt(0);
int name_index = UnityEngine.Random.Range(0, config_name_list.Count);
int money_index = UnityEngine.Random.Range(0, config_money_list.Count);
broad_list.Add(new string[2] { config_name_list[name_index], config_money_list[money_index] });
for (int i = 0; i < 4; i++)
{
text_list[i].text = Language.GetContentParams("congratulations_des", new[] { broad_list[i][0], broad_list[i][1] });
}
});
}
}
private List<GTextField> text_list = new List<GTextField>();
private void InitBroadCast()
{
text_list.Add((ui.broad as com_broadcast_new).text_0);
text_list.Add((ui.broad as com_broadcast_new).text_1);
text_list.Add((ui.broad as com_broadcast_new).text_2);
text_list.Add((ui.broad as com_broadcast_new).text_3);
for (int i = 0; i < 4; i++)
{
int name_index = UnityEngine.Random.Range(0, config_name_list.Count);
int money_index = UnityEngine.Random.Range(0, config_money_list.Count);
broad_list.Add(new string[2] { config_name_list[name_index], config_money_list[money_index] });
text_list[i].text = Language.GetContentParams("congratulations_des", new[] { broad_list[i][0], broad_list[i][1] });
}
}
}
}
+232 -233
View File
@@ -1,234 +1,233 @@
using FairyGUI;
using SGModule.NetKit;
using Spine.Unity;
using System;
using System.Collections.Generic;
using DontConfuse;
using IgnoreOPS;
using FGUI.ZM_Common_01;
namespace BallKingdomCrush
{
public class AddViewoffUI : BaseUI
{
private AddViewoffUICtrl ctrl;
private AddViewoffModel model;
private FGUI.ZM_AddCell_12.com_addView_off ui;
private Action closeCallback;
private bool isAutoPop = false;
public AddViewoffUI(AddViewoffUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.AddViewoffUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_AddCell_12";
uiInfo.assetName = "com_addView_off";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.AddViewoffModel) as AddViewoffModel;
}
protected override void OnClose()
{
GameHelper.showGameUI = true;
HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
if (GameHelper.IsAdModelOfPay())
{
AdExchangeManager.Instance.Destroy();
}
closeCallback?.Invoke();
if (isAutoPop)
{
GameHelper.CallShowTurn();
}
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_AddCell_12.com_addView_off;
}
protected override void OnOpenBefore(object args)
{
if (args != null)
{
isAutoPop = (bool)args;
}
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.BuyOneOffShow);
// ad_cool_down = ConfigSystem.GetCommonConf().exchangeCD;
// btn_WatchAd = ui.btn_watch as btn_watchAd;
if (GameHelper.IsAdModelOfPay())
{
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.buy_one_off), ui.btn_watch as btn_watchAd, SetTextString);
ui.pay_type.selectedIndex = 0;
ui.text_old_price.text = GameHelper.GetCommonModel().addspace + "ADs";
btn_watchAd btn = ui.btn_watch as btn_watchAd;
AdExchangeManager.Instance.Start();
SetTextString();
}
else
{
ui.pay_type.selectedIndex = 1;
ui.text_old_price.text = GameHelper.getPrice((decimal)GameHelper.GetCommonModel().addspace2);
decimal price = (decimal)GameHelper.GetCommonModel().AddDiscount2;
ui.btn_max_pay.title = GameHelper.getPrice(price);
ui.btn_max_pay.SetClick(() =>
{
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price * 100),
sku = PurchasingManager.GetPaySku(PayType.buy_one_off),
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
if (GameHelper.IsGiftSwitch())
{
ui.broad.visible = true;
}
else
{
ui.broad.visible = false;
}
InitView();
InitBroadCast();
}
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;
if (type == PurchasingManager.GetPaySku(PayType.buy_one_off))
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AddViewoffUI_Close);
SaveData.GetSaveObject().have_slot = true;
SaveData.SaveDataFunc();
GameDispatcher.Instance.Dispatch(GameMsg.Slot_refresh);
GameDispatcher.Instance.Dispatch(GameMsg.resurgence_close);
CtrlCloseUI();
}
}
//初始化页面逻辑
private void InitView()
{
// var tAnimation = FXManager.Instance.SetFx<SkeletonAnimation>(ui.tip_parent, Fx_Type.Fx_AddBoxTip, ref _closeCallback);
// tAnimation.state.AddAnimation(0, "animation", true, 0);
ui.btn_close.SetClick(() =>
{
GameDispatcher.Instance.Dispatch(GameMsg.resurgence_close);
CtrlCloseUI();
});
HallManager.Instance.UpdateSecondEvent += updateWatchCD;
// updateWatchCD();
// checkBtnState();
}
void updateWatchCD()
{
ui.text_time.text = CommonHelper.TimeFormat((int)SaveData.GetSaveObject().addview_off_time - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
broadtime++;
BroadCast();
}
public void SetTextString()
{
var need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.buy_one_off));
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.tips.SetVar("num", need.ToString()).FlushVars();
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
}
private int broadtime = 1;
private List<string> config_name_list = LevelAttemptsModel.config_name_list;
private List<string> config_money_list = LevelAttemptsModel.config_money_list;
private List<string[]> broad_list = new List<string[]>();
private void BroadCast()
{
if (broadtime % 3 == 0)
{
(ui.broad as com_broadcast_new).t1.Play(() =>
{
broad_list.RemoveAt(0);
int name_index = UnityEngine.Random.Range(0, config_name_list.Count);
int money_index = UnityEngine.Random.Range(0, config_money_list.Count);
broad_list.Add(new string[2] { config_name_list[name_index], config_money_list[money_index] });
for (int i = 0; i < 4; i++)
{
text_list[i].text = "Congratulations,User [color=#ad4800][size=36]" + broad_list[i][0] + "[/size][/color] !After purchasing the +1 Block Pack,play [color=#ad4800]" + broad_list[i][1] + "[/color] matcher to clear the level!";
}
});
}
}
private List<GTextField> text_list = new List<GTextField>();
private void InitBroadCast()
{
text_list.Add((ui.broad as com_broadcast_new).text_0);
text_list.Add((ui.broad as com_broadcast_new).text_1);
text_list.Add((ui.broad as com_broadcast_new).text_2);
text_list.Add((ui.broad as com_broadcast_new).text_3);
for (int i = 0; i < 4; i++)
{
int name_index = UnityEngine.Random.Range(0, config_name_list.Count);
int money_index = UnityEngine.Random.Range(0, config_money_list.Count);
broad_list.Add(new string[2] { config_name_list[name_index], config_money_list[money_index] });
text_list[i].text = "Congratulations,User [color=#ad4800][size=36]" + broad_list[i][0] + "[/size][/color] !After purchasing the +1 Block Pack,play [color=#ad4800]" + broad_list[i][1] + "[/color] matcher to clear the level!";
}
}
}
using FairyGUI;
using SGModule.NetKit;
using Spine.Unity;
using System;
using System.Collections.Generic;
using IgnoreOPS;
using FGUI.ZM_Common_01;
namespace BallKingdomCrush
{
public class AddViewoffUI : BaseUI
{
private AddViewoffUICtrl ctrl;
private AddViewoffModel model;
private FGUI.ZM_AddCell_12.com_addView_off ui;
private Action closeCallback;
private bool isAutoPop = false;
public AddViewoffUI(AddViewoffUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.AddViewoffUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_AddCell_12";
uiInfo.assetName = "com_addView_off";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.AddViewoffModel) as AddViewoffModel;
}
protected override void OnClose()
{
GameHelper.showGameUI = true;
HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
if (GameHelper.IsAdModelOfPay())
{
AdExchangeManager.Instance.Destroy();
}
closeCallback?.Invoke();
if (isAutoPop)
{
GameHelper.CallShowTurn();
}
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_AddCell_12.com_addView_off;
}
protected override void OnOpenBefore(object args)
{
if (args != null)
{
isAutoPop = (bool)args;
}
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.BuyOneOffShow);
// ad_cool_down = ConfigSystem.GetCommonConf().exchangeCD;
// btn_WatchAd = ui.btn_watch as btn_watchAd;
if (GameHelper.IsAdModelOfPay())
{
// AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.buy_one_off), ui.btn_watch as btn_watchAd, SetTextString);
// ui.pay_type.selectedIndex = 0;
// ui.text_old_price.text = GameHelper.GetCommonModel().addspace + "ADs";
// btn_watchAd btn = ui.btn_watch as btn_watchAd;
//
// AdExchangeManager.Instance.Start();
// SetTextString();
}
else
{
ui.pay_type.selectedIndex = 1;
ui.text_old_price.text = GameHelper.getPrice((decimal)GameHelper.GetCommonModel().addspace2);
decimal price = (decimal)GameHelper.GetCommonModel().AddDiscount2;
ui.btn_max_pay.title = GameHelper.getPrice(price);
ui.btn_max_pay.SetClick(() =>
{
// ApplePayClass maxPayData = new ApplePayClass
// {
// amount = (int)Math.Round(price * 100),
// sku = PurchasingManager.GetPaySku(PayType.buy_one_off),
// currency = "USD"
// };
// MaxPayManager.Instance.Buy(maxPayData);
});
}
if (GameHelper.IsGiftSwitch())
{
ui.broad.visible = true;
}
else
{
ui.broad.visible = false;
}
InitView();
InitBroadCast();
}
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.IAP_PAY_SUCCESS, pay_success);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
// if (type == PurchasingManager.GetPaySku(PayType.buy_one_off))
// {
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AddViewoffUI_Close);
// SaveData.GetSaveObject().have_slot = true;
// SaveData.SaveDataFunc();
// GameDispatcher.Instance.Dispatch(GameMsg.Slot_refresh);
// GameDispatcher.Instance.Dispatch(GameMsg.resurgence_close);
// CtrlCloseUI();
// }
}
//初始化页面逻辑
private void InitView()
{
// var tAnimation = FXManager.Instance.SetFx<SkeletonAnimation>(ui.tip_parent, Fx_Type.Fx_AddBoxTip, ref _closeCallback);
// tAnimation.state.AddAnimation(0, "animation", true, 0);
ui.btn_close.SetClick(() =>
{
GameDispatcher.Instance.Dispatch(GameMsg.resurgence_close);
CtrlCloseUI();
});
HallManager.Instance.UpdateSecondEvent += updateWatchCD;
// updateWatchCD();
// checkBtnState();
}
void updateWatchCD()
{
ui.text_time.text = CommonHelper.TimeFormat((int)SaveData.GetSaveObject().addview_off_time - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
broadtime++;
BroadCast();
}
public void SetTextString()
{
// var need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.buy_one_off));
// var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
//
// ui.tips.SetVar("num", need.ToString()).FlushVars();
// ui.ads.SetVar("num", myAd.ToString()).FlushVars();
}
private int broadtime = 1;
private List<string> config_name_list = LevelAttemptsModel.config_name_list;
private List<string> config_money_list = LevelAttemptsModel.config_money_list;
private List<string[]> broad_list = new List<string[]>();
private void BroadCast()
{
if (broadtime % 3 == 0)
{
(ui.broad as com_broadcast_new).t1.Play(() =>
{
broad_list.RemoveAt(0);
int name_index = UnityEngine.Random.Range(0, config_name_list.Count);
int money_index = UnityEngine.Random.Range(0, config_money_list.Count);
broad_list.Add(new string[2] { config_name_list[name_index], config_money_list[money_index] });
for (int i = 0; i < 4; i++)
{
text_list[i].text = "Congratulations,User [color=#ad4800][size=36]" + broad_list[i][0] + "[/size][/color] !After purchasing the +1 Block Pack,play [color=#ad4800]" + broad_list[i][1] + "[/color] matcher to clear the level!";
}
});
}
}
private List<GTextField> text_list = new List<GTextField>();
private void InitBroadCast()
{
text_list.Add((ui.broad as com_broadcast_new).text_0);
text_list.Add((ui.broad as com_broadcast_new).text_1);
text_list.Add((ui.broad as com_broadcast_new).text_2);
text_list.Add((ui.broad as com_broadcast_new).text_3);
for (int i = 0; i < 4; i++)
{
int name_index = UnityEngine.Random.Range(0, config_name_list.Count);
int money_index = UnityEngine.Random.Range(0, config_money_list.Count);
broad_list.Add(new string[2] { config_name_list[name_index], config_money_list[money_index] });
text_list[i].text = "Congratulations,User [color=#ad4800][size=36]" + broad_list[i][0] + "[/size][/color] !After purchasing the +1 Block Pack,play [color=#ad4800]" + broad_list[i][1] + "[/color] matcher to clear the level!";
}
}
}
}
+244 -244
View File
@@ -1,245 +1,245 @@
using UnityEngine;
using FairyGUI;
using SGModule.Net;
using System;
using Spine.Unity;
using SGModule.NetKit;
using IgnoreOPS;
using FGUI.ZM_Common_01;
namespace BallKingdomCrush
{
public class AddviewnewUI : BaseUI
{
private AddviewnewUICtrl ctrl;
private AddviewnewModel model;
private FGUI.ZM_AddCell_12.com_addView_new ui;
private bool is_off = false;
public AddviewnewUI(AddviewnewUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.AddviewnewUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_AddCell_12";
uiInfo.assetName = "com_addView_new";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.AddviewnewModel) as AddviewnewModel;
}
private Action closeCallback;
protected override void OnClose()
{
GameHelper.showGameUI = true;
HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
closeCallback?.Invoke();
AdExchangeManager.Instance.Destroy();
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_AddCell_12.com_addView_new;
}
protected override void OnOpenBefore(object args)
{
// if (ui.btn_watch is btn_watchAd watchAdBtn)
// {
// CommonTools.GetInstance.InitAdBtnAnim(watchAdBtn.icon_Parent);
// }
// if (SaveData.GetSaveObject().addview_off_time > GameHelper.GetNowTime()) is_off = true;
ui.text_out.text = "x" + GameHelper.GetItemNumber(0);
ui.text_back.text = "x" + GameHelper.GetItemNumber(1);
ui.text_refresh.text = "x" + GameHelper.GetItemNumber(2);
ui.text_level.text = "Level " + GameHelper.GetLevel();
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_show);
ui.btn_play.SetClick(() =>
{
GameHelper.gameType = 0;
GameDispatcher.Instance.Dispatch(GameMsg.OpenGame, false);
CtrlCloseUI();
});
// ui.btn_watch.GetChild("img_saveingpot").x += 20;
// ui.btn_watch.GetChild("img_saveingpot").y -= 33;
// ad_cool_down = ConfigSystem.GetCommonConf().exchangeCD;
// btn_WatchAd = ui.btn_watch as btn_watchAd;
if (GameHelper.IsAdModelOfPay())
{
if (is_off)
{
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.buy_one_off), ui.btn_watch as btn_watchAd, () =>
{
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_click);
SetTextString();
});
ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.Start();
}
else
{
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.buy_one), ui.btn_watch as btn_watchAd, () =>
{
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_click);
SetTextString();
});
ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.Start();
}
SetTextString();
}
else
{
ui.pay_type.selectedIndex = 1;
if (is_off)
{
decimal price = (decimal)GameHelper.GetCommonModel().AddDiscount2;
ui.btn_max_pay.title = GameHelper.getPrice(price);
ui.btn_max_pay.SetClick(() =>
{
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_click);
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price * 100),
sku = PurchasingManager.GetPaySku(PayType.buy_one_off),
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
else
{
decimal price = (decimal)GameHelper.GetCommonModel().addspace2;
ui.btn_max_pay.title = GameHelper.getPrice(price);
ui.btn_max_pay.SetClick(() =>
{
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_click);
ApplePayClass maxPayData = new ApplePayClass()
{
amount = (int)Math.Round(price * 100),
sku = PurchasingManager.GetPaySku(PayType.buy_one),
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);
GameDispatcher.Instance.AddListener(GameMsg.Sheep_item_refresh, SetItemNumber);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
GameDispatcher.Instance.RemoveListener(GameMsg.Sheep_item_refresh, SetItemNumber);
}
#endregion
void SetItemNumber(object a)
{
ui.text_out.text = "x" + GameHelper.GetItemNumber(0);
ui.text_back.text = "x" + GameHelper.GetItemNumber(1);
ui.text_refresh.text = "x" + GameHelper.GetItemNumber(2);
}
void pay_success(object str)
{
string type = (string)str;
if (type == PurchasingManager.GetPaySku(PayType.buy_one) || type == PurchasingManager.GetPaySku(PayType.buy_one_off))
{
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_success);
SaveData.GetSaveObject().have_slot = true;
SaveData.SaveDataFunc();
GameDispatcher.Instance.Dispatch(GameMsg.Slot_refresh);
ui.pay_type.selectedIndex = 2;
// SkeletonAnimation addeffect = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_parent1, Fx_Type.fx_addeffect, ref closeCallback);
// addeffect.state.SetAnimation(0, "animation", true);
// SkeletonAnimation addeffect1 = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_parent2, Fx_Type.fx_addarrow, ref closeCallback);
// addeffect1.state.SetAnimation(0, "animation", true);
// CtrlCloseUI();
}
}
//初始化页面逻辑
private void InitView()
{
var tAnimation = FXManager.Instance.SetFx<SkeletonAnimation>(ui.btn_up.ani_node, Fx_Type.fx_powerup, ref closeCallback);
tAnimation.state.SetAnimation(0, "animation", true);
ui.btn_close.SetClick(() =>
{
GameDispatcher.Instance.Dispatch(GameMsg.OpenGame);
CtrlCloseUI();
});
HallManager.Instance.UpdateSecondEvent += updateWatchCD;
ui.btn_addback.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SheepwindowUI_Open, 1);
});
ui.btn_addout.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SheepwindowUI_Open, 0);
});
ui.btn_addrefresh.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SheepwindowUI_Open, 2);
});
// updateWatchCD();
// checkBtnState();
}
void updateWatchCD()
{
}
public void SetTextString()
{
int need = 0;
if (is_off) need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.buy_one_off));
else need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.buy_one));
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
// ui.tips.SetVar("num", need.ToString()).FlushVars();
ui.ads.SetVar("num", myAd + "/").FlushVars();
ui.ads.SetVar("num1", need.ToString()).FlushVars();
}
}
using UnityEngine;
using FairyGUI;
using SGModule.Net;
using System;
using Spine.Unity;
using SGModule.NetKit;
using IgnoreOPS;
using FGUI.ZM_Common_01;
namespace BallKingdomCrush
{
public class AddviewnewUI : BaseUI
{
private AddviewnewUICtrl ctrl;
private AddviewnewModel model;
private FGUI.ZM_AddCell_12.com_addView_new ui;
private bool is_off = false;
public AddviewnewUI(AddviewnewUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.AddviewnewUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_AddCell_12";
uiInfo.assetName = "com_addView_new";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.AddviewnewModel) as AddviewnewModel;
}
private Action closeCallback;
protected override void OnClose()
{
GameHelper.showGameUI = true;
HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
closeCallback?.Invoke();
AdExchangeManager.Instance.Destroy();
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_AddCell_12.com_addView_new;
}
protected override void OnOpenBefore(object args)
{
// if (ui.btn_watch is btn_watchAd watchAdBtn)
// {
// CommonTools.GetInstance.InitAdBtnAnim(watchAdBtn.icon_Parent);
// }
// if (SaveData.GetSaveObject().addview_off_time > GameHelper.GetNowTime()) is_off = true;
ui.text_out.text = "x" + GameHelper.GetItemNumber(0);
ui.text_back.text = "x" + GameHelper.GetItemNumber(1);
ui.text_refresh.text = "x" + GameHelper.GetItemNumber(2);
ui.text_level.text = "Level " + GameHelper.GetLevel();
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_show);
ui.btn_play.SetClick(() =>
{
GameHelper.gameType = 0;
GameDispatcher.Instance.Dispatch(GameMsg.OpenGame, false);
CtrlCloseUI();
});
// ui.btn_watch.GetChild("img_saveingpot").x += 20;
// ui.btn_watch.GetChild("img_saveingpot").y -= 33;
// ad_cool_down = ConfigSystem.GetCommonConf().exchangeCD;
// btn_WatchAd = ui.btn_watch as btn_watchAd;
if (GameHelper.IsAdModelOfPay())
{
if (is_off)
{
// AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.buy_one_off), ui.btn_watch as btn_watchAd, () =>
// {
// TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_click);
// SetTextString();
// });
ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.Start();
}
else
{
AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_SPACE_BONUS, ui.btn_watch as btn_watchAd, () =>
{
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_click);
SetTextString();
});
ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.Start();
}
SetTextString();
}
else
{
ui.pay_type.selectedIndex = 1;
if (is_off)
{
decimal price = (decimal)GameHelper.GetCommonModel().AddDiscount2;
ui.btn_max_pay.title = GameHelper.getPrice(price);
ui.btn_max_pay.SetClick(() =>
{
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_click);
// ApplePayClass maxPayData = new ApplePayClass
// {
// amount = (int)Math.Round(price * 100),
// sku = PurchasingManager.GetPaySku(PayType.buy_one_off),
// currency = "USD"
// };
// MaxPayManager.Instance.Buy(maxPayData);
});
}
else
{
decimal price = (decimal)GameHelper.GetCommonModel().addspace2;
ui.btn_max_pay.title = GameHelper.getPrice(price);
ui.btn_max_pay.SetClick(() =>
{
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_click);
ApplePayClass maxPayData = new ApplePayClass()
{
amount = (int)Math.Round(price * 100),
sku = IAPPayManager.PRODUCT_SPACE_BONUS,
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.IAP_PAY_SUCCESS, pay_success);
GameDispatcher.Instance.AddListener(GameMsg.Sheep_item_refresh, SetItemNumber);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
GameDispatcher.Instance.RemoveListener(GameMsg.Sheep_item_refresh, SetItemNumber);
}
#endregion
void SetItemNumber(object a)
{
ui.text_out.text = "x" + GameHelper.GetItemNumber(0);
ui.text_back.text = "x" + GameHelper.GetItemNumber(1);
ui.text_refresh.text = "x" + GameHelper.GetItemNumber(2);
}
void pay_success(object str)
{
string type = (string)str;
// if (type == IAPPayManager.PRODUCT_SPACE_BONUS || type == PurchasingManager.GetPaySku(PayType.buy_one_off))
// {
// TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_success);
// SaveData.GetSaveObject().have_slot = true;
// SaveData.SaveDataFunc();
// GameDispatcher.Instance.Dispatch(GameMsg.Slot_refresh);
// ui.pay_type.selectedIndex = 2;
// // SkeletonAnimation addeffect = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_parent1, Fx_Type.fx_addeffect, ref closeCallback);
// // addeffect.state.SetAnimation(0, "animation", true);
// // SkeletonAnimation addeffect1 = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_parent2, Fx_Type.fx_addarrow, ref closeCallback);
// // addeffect1.state.SetAnimation(0, "animation", true);
// // CtrlCloseUI();
// }
}
//初始化页面逻辑
private void InitView()
{
var tAnimation = FXManager.Instance.SetFx<SkeletonAnimation>(ui.btn_up.ani_node, Fx_Type.fx_powerup, ref closeCallback);
tAnimation.state.SetAnimation(0, "animation", true);
ui.btn_close.SetClick(() =>
{
GameDispatcher.Instance.Dispatch(GameMsg.OpenGame);
CtrlCloseUI();
});
HallManager.Instance.UpdateSecondEvent += updateWatchCD;
ui.btn_addback.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SheepwindowUI_Open, 1);
});
ui.btn_addout.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SheepwindowUI_Open, 0);
});
ui.btn_addrefresh.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SheepwindowUI_Open, 2);
});
// updateWatchCD();
// checkBtnState();
}
void updateWatchCD()
{
}
public void SetTextString()
{
// int need = 0;
// if (is_off) need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.buy_one_off));
// else need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_SPACE_BONUS);
// var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
//
// // ui.tips.SetVar("num", need.ToString()).FlushVars();
// ui.ads.SetVar("num", myAd + "/").FlushVars();
// ui.ads.SetVar("num1", need.ToString()).FlushVars();
}
}
}
+408 -408
View File
@@ -1,409 +1,409 @@
using System.Collections.Generic;
using FairyGUI;
using DG.Tweening;
using FGUI.ZM_Common_01;
using System;
using IgnoreOPS;
using SGModule.NetKit;
using UnityEngine;
using FGUI.ZM_Pass_14;
namespace BallKingdomCrush
{
public class LuckyPackUI : BaseUI
{
private LuckyPackUICtrl ctrl;
private LuckyPackModel model;
private FGUI.LG_LuckyGift.com_lucky ui;
private List<Paidgift> list;
public LuckyPackUI(LuckyPackUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.LuckyPackUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "LG_LuckyGift";
uiInfo.assetName = "com_lucky";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.PackrewardModel) as LuckyPackModel;
}
private List<GLoader> loader_list = new List<GLoader>();
protected override void OnClose()
{
AdExchangeManager.Instance.Destroy();
GameHelper.showGameUI = true;
HallManager.Instance.UpdateSecondEvent -= RemoveAdCountDown;
GameDispatcher.Instance.Dispatch(GameMsg.pack_close);
int three_gift_got_index = SaveData.GetSaveObject().three_gift_got_index;
if (GameHelper.isAutoPop && (three_gift_got_index <= (int)rewardState.day3))
{
uiCtrlDispatcher.Dispatch(UICtrlMsg.ThreeDaysGiftUI_Open);
GameHelper.isAutoPop = false;
}
GameHelper.CallShowTurn();
foreach (var t in loader_list)
{
if (t != null && !t.isDisposed && t.texture != null)
{
t.texture = null;
}
}
loader_list.Clear();
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_LuckyGift.com_lucky;
}
protected override void OnOpenBefore(object args)
{
if (GameHelper.IsGiftSwitch())
{
ui.state.selectedIndex = 1;
}
else
{
ui.state.selectedIndex = 0;
}
ui.gold.GetChild("text_gold").text = GameHelper.Get101Str(GameHelper.GetGoldNumber());
var needScroll = false;
if (args != null) needScroll = (bool)args;
ui.type.selectedIndex = needScroll ? 1 : 0;
Debug.Log($"needScroll============={needScroll}= {ui.type.selectedIndex}");
TrackKit.SendEvent(GameHelper.getTrackEvenName(), needScroll ? ADEventTrack.Property.remove_ad_show : ADEventTrack.Property.lucky_gift_show);
list = ConfigSystem.GetConfig<Paidgift>();
if (GameHelper.IsAdModelOfPay())
{
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.pack_reward), ui.btn_buypack as btn_watchAd, SetTextString1);
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.remove_ad), ui.btn_buyremovead as btn_watchAd, SetTextString1);
}
ui.btn_go_ad.SetClick(() =>
{
ui.type.selectedIndex = 1;
});
ui.btn_go_lucky.SetClick(() =>
{
ui.type.selectedIndex = 0;
});
if (!loader_list.Contains(ui.lucky_pic.picture))
{
loader_list.Add(ui.lucky_pic.picture);
}
if (!loader_list.Contains(ui.no_ad_pic.picture))
{
loader_list.Add(ui.no_ad_pic.picture);
}
InitView();
var fileName = GameHelper.GetBackgroundName(des_key.remove_ad_gift.ToString());
var task = new List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)>();
task.Add((ui.no_ad_pic.picture, fileName, null, "Background/", FolderNames.BackgroundName));
var fileName1 = GameHelper.GetBackgroundName(des_key.pack_gift.ToString());
task.Add((ui.lucky_pic.picture, fileName1, null, "Background/", FolderNames.BackgroundName));
TextureHelper.SetImgLoaders(task);
}
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;
Debug.Log($"pay_success type================{type}");
if (type == PurchasingManager.GetPaySku(PayType.remove_ad))
{
var gold = list[1].coins_quantity;
var start = GameHelper.GetUICenterPosition(ui.text_goldnum2);
var end = GameHelper.GetUICenterPosition((ui.gold as com_gold).img);
var rewardData = new RewardData();
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
{
startPosition = start,
endPosition = end,
};
rewardData.AddReward(rewardSingleData);
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
rewardData.AddCompleted((isScu) =>
{
DOVirtual.DelayedCall(0.5f, () =>
{
var startNum = DataMgr.Coin.Value - gold;
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f,
value => { ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); }).OnComplete(() =>
{
// 动画完成时确保最终值被正确设置
ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)DataMgr.Coin.Value);
});
});
});
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AdcomingUI_Close);
SaveData.GetSaveObject().is_get_removead = true;
SaveData.SaveDataFunc();
InitView();
}
else if (type == PurchasingManager.GetPaySku(PayType.pack_reward))
{
var start = GameHelper.GetUICenterPosition(ui.text_goldnum);
var end = GameHelper.GetUICenterPosition((ui.gold as com_gold).img);
var gold = list[0].coins_quantity;
var rewardData = new RewardData();
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
{
startPosition = start,
endPosition = end,
};
rewardData.AddReward(rewardSingleData);
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
rewardData.AddCompleted((isScu) =>
{
DOVirtual.DelayedCall(0.5f, () =>
{
var startNum = DataMgr.Coin.Value - gold;
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f,
value => { ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); }).OnComplete(() =>
{
// 动画完成时确保最终值被正确设置
ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)DataMgr.Coin.Value);
});
});
});
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
SaveData.GetSaveObject().is_get_packreward = true;
SaveData.SaveDataFunc();
InitView();
}
}
//初始化页面逻辑
private int gold_num = 300;
private int back_num = 1;
private int out_num = 1;
private int refresh_num = 1;
private void InitView()
{
gold_num = list[0].coins_quantity;
back_num = list[0].props_quantity[1];
out_num = list[0].props_quantity[0];
refresh_num = list[0].props_quantity[2];
ui.text_time.SetVar("time", ConfigSystem.GetCommonConf().RemoveADsPackDuration.ToString()).FlushVars();
ui.btn_close.SetClick(CtrlCloseUI);
ui.text_goldnum.text = "x" + GameHelper.Get101Str(gold_num);
ui.text_backnum1.text = "x" + back_num;
ui.text_outnum.text = "x" + out_num;
ui.text_refreshnum.text = "x" + refresh_num;
var buy_text = ui.btn_buypack.GetChild("title") as GTextField;
buy_text.SetVar("price", list[0].Paid_price.ToString()).FlushVars();
ui.text_goldnum2.text = "x" + GameHelper.Get101Str(list[1].coins_quantity);
var buy_text1 = ui.btn_buyremovead.GetChild("title") as GTextField;
buy_text1.SetVar("price", list[1].Paid_price.ToString()).FlushVars();
if (!GameHelper.IsAdModelOfPay())
{
ui.pay_type.selectedIndex = 1;
decimal price_pack = (decimal)list[0].Paid_price2;
ui.btn_max_pack.title = GameHelper.Get102Str(price_pack);
bool is_get = SaveData.GetSaveObject().is_get_packreward;
Debug.Log($"is_get================{is_get}");
if (is_get)
{
ui.btn_max_pack.enabled = false;
ui.btn_max_pack.title = Language.GetContent("Received");
ui.btn_max_pack.SetClick(() => { });
}
else
{
ui.btn_max_pack.enabled = true;
ui.btn_max_pack.SetClick(() =>
{
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price_pack * 100),
sku = PurchasingManager.GetPaySku(PayType.pack_reward),
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
decimal price_remove = (decimal)list[1].Paid_price2;
ui.btn_max_remove.title = GameHelper.Get102Str(price_remove);
bool is_get1 = SaveData.GetSaveObject().is_get_removead;
Debug.Log($"is_get1================{is_get1}");
if (is_get1)
{
HallManager.Instance.UpdateSecondEvent += RemoveAdCountDown;
ui.btn_max_remove.enabled = false;
ui.btn_max_remove.SetClick(() => { });
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
if (cd > 24 * 3600)
{
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
}
else
{
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
}
}
else
{
(ui.btn_max_remove as FGUI.ZM_Common_01.btn_max_buy).state.selectedIndex = 0;
ui.btn_max_remove.enabled = true;
ui.btn_max_remove.SetClick(() =>
{
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price_remove * 100),
sku = PurchasingManager.GetPaySku(PayType.remove_ad),
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
}
else
{
AdExchangeManager.Instance.Start();
SetTextString1();
bool is_get = SaveData.GetSaveObject().is_get_packreward;
Debug.Log($"is_get================{is_get}");
if (is_get)
{
(ui.btn_buypack as btn_watchAd).buy_state.selectedIndex = 1;
(ui.btn_buypack as btn_watchAd).can_buy.selectedIndex = 1;
ui.btn_buypack.title = Language.GetContent("Received");
}
ui.pay_type.selectedIndex = 0;
ui.btn_buyremovead.title = Language.GetContent("Receive_");
decimal price_remove = (decimal)list[1].Paid_price2;
bool is_get1 = SaveData.GetSaveObject().is_get_removead;
if (is_get1)
{
HallManager.Instance.UpdateSecondEvent += RemoveAdCountDown;
ui.btn_buyremovead.enabled = false;
ui.btn_buyremovead.SetClick(() => { });
var lastTimes = SaveData.GetSaveObject()._watch_ad_cd;
if (GameHelper.GetNowTime() < lastTimes)
{
}
(ui.btn_buyremovead as btn_watchAd).buy_state.selectedIndex = 1;
(ui.btn_buyremovead as btn_watchAd).can_buy.selectedIndex = 1;
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
if (cd > 24 * 3600)
{
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
}
else
{
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
}
}
}
}
private void RemoveAdCountDown()
{
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
if (cd > 0)
{
if (cd > 24 * 3600)
{
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
}
else
{
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
}
}
else
{
HallManager.Instance.UpdateSecondEvent -= RemoveAdCountDown;
SaveData.GetSaveObject().is_get_removead = false;
SaveData.GetSaveObject().remove_ad_time = 0;
InitView();
}
}
public void SetTextString1()
{
var remove_need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.remove_ad));
var pack_need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.pack_reward));
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
ui.tips1.SetVar("num", pack_need.ToString()).FlushVars();
ui.tips2.SetVar("num", remove_need.ToString()).FlushVars();
}
}
using System.Collections.Generic;
using FairyGUI;
using DG.Tweening;
using FGUI.ZM_Common_01;
using System;
using IgnoreOPS;
using SGModule.NetKit;
using UnityEngine;
using FGUI.ZM_Pass_14;
namespace BallKingdomCrush
{
public class LuckyPackUI : BaseUI
{
private LuckyPackUICtrl ctrl;
private LuckyPackModel model;
private FGUI.LG_LuckyGift.com_lucky ui;
private List<Paidgift> list;
public LuckyPackUI(LuckyPackUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.LuckyPackUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "LG_LuckyGift";
uiInfo.assetName = "com_lucky";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.PackrewardModel) as LuckyPackModel;
}
private List<GLoader> loader_list = new List<GLoader>();
protected override void OnClose()
{
AdExchangeManager.Instance.Destroy();
GameHelper.showGameUI = true;
HallManager.Instance.UpdateSecondEvent -= RemoveAdCountDown;
GameDispatcher.Instance.Dispatch(GameMsg.pack_close);
int three_gift_got_index = SaveData.GetSaveObject().three_gift_got_index;
if (GameHelper.isAutoPop && (three_gift_got_index <= (int)rewardState.day3))
{
uiCtrlDispatcher.Dispatch(UICtrlMsg.ThreeDaysGiftUI_Open);
GameHelper.isAutoPop = false;
}
GameHelper.CallShowTurn();
foreach (var t in loader_list)
{
if (t != null && !t.isDisposed && t.texture != null)
{
t.texture = null;
}
}
loader_list.Clear();
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_LuckyGift.com_lucky;
}
protected override void OnOpenBefore(object args)
{
if (GameHelper.IsGiftSwitch())
{
ui.state.selectedIndex = 1;
}
else
{
ui.state.selectedIndex = 0;
}
ui.gold.GetChild("text_gold").text = GameHelper.Get101Str(GameHelper.GetGoldNumber());
var needScroll = false;
if (args != null) needScroll = (bool)args;
ui.type.selectedIndex = needScroll ? 1 : 0;
Debug.Log($"needScroll============={needScroll}= {ui.type.selectedIndex}");
TrackKit.SendEvent(GameHelper.getTrackEvenName(), needScroll ? ADEventTrack.Property.remove_ad_show : ADEventTrack.Property.lucky_gift_show);
list = ConfigSystem.GetConfig<Paidgift>();
if (GameHelper.IsAdModelOfPay())
{
AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_FIRST_GIFT, ui.btn_buypack as btn_watchAd, SetTextString1);
AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_REMOVE_ADS, ui.btn_buyremovead as btn_watchAd, SetTextString1);
}
ui.btn_go_ad.SetClick(() =>
{
ui.type.selectedIndex = 1;
});
ui.btn_go_lucky.SetClick(() =>
{
ui.type.selectedIndex = 0;
});
if (!loader_list.Contains(ui.lucky_pic.picture))
{
loader_list.Add(ui.lucky_pic.picture);
}
if (!loader_list.Contains(ui.no_ad_pic.picture))
{
loader_list.Add(ui.no_ad_pic.picture);
}
InitView();
var fileName = GameHelper.GetBackgroundName(des_key.remove_ad_gift.ToString());
var task = new List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)>();
task.Add((ui.no_ad_pic.picture, fileName, null, "Background/", FolderNames.BackgroundName));
var fileName1 = GameHelper.GetBackgroundName(des_key.pack_gift.ToString());
task.Add((ui.lucky_pic.picture, fileName1, null, "Background/", FolderNames.BackgroundName));
TextureHelper.SetImgLoaders(task);
}
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.IAP_PAY_SUCCESS, pay_success);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
Debug.Log($"pay_success type================{type}");
if (type == IAPPayManager.PRODUCT_REMOVE_ADS)
{
var gold = list[1].coins_quantity;
var start = GameHelper.GetUICenterPosition(ui.text_goldnum2);
var end = GameHelper.GetUICenterPosition((ui.gold as com_gold).img);
var rewardData = new RewardData();
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
{
startPosition = start,
endPosition = end,
};
rewardData.AddReward(rewardSingleData);
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
rewardData.AddCompleted((isScu) =>
{
DOVirtual.DelayedCall(0.5f, () =>
{
var startNum = DataMgr.Coin.Value - gold;
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f,
value => { ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); }).OnComplete(() =>
{
// 动画完成时确保最终值被正确设置
ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)DataMgr.Coin.Value);
});
});
});
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AdcomingUI_Close);
SaveData.GetSaveObject().is_get_removead = true;
SaveData.SaveDataFunc();
InitView();
}
else if (type == IAPPayManager.PRODUCT_FIRST_GIFT)
{
var start = GameHelper.GetUICenterPosition(ui.text_goldnum);
var end = GameHelper.GetUICenterPosition((ui.gold as com_gold).img);
var gold = list[0].coins_quantity;
var rewardData = new RewardData();
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
{
startPosition = start,
endPosition = end,
};
rewardData.AddReward(rewardSingleData);
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
rewardData.AddCompleted((isScu) =>
{
DOVirtual.DelayedCall(0.5f, () =>
{
var startNum = DataMgr.Coin.Value - gold;
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f,
value => { ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); }).OnComplete(() =>
{
// 动画完成时确保最终值被正确设置
ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)DataMgr.Coin.Value);
});
});
});
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
SaveData.GetSaveObject().is_get_packreward = true;
SaveData.SaveDataFunc();
InitView();
}
}
//初始化页面逻辑
private int gold_num = 300;
private int back_num = 1;
private int out_num = 1;
private int refresh_num = 1;
private void InitView()
{
gold_num = list[0].coins_quantity;
back_num = list[0].props_quantity[1];
out_num = list[0].props_quantity[0];
refresh_num = list[0].props_quantity[2];
ui.text_time.SetVar("time", ConfigSystem.GetCommonConf().RemoveADsPackDuration.ToString()).FlushVars();
ui.btn_close.SetClick(CtrlCloseUI);
ui.text_goldnum.text = "x" + GameHelper.Get101Str(gold_num);
ui.text_backnum1.text = "x" + back_num;
ui.text_outnum.text = "x" + out_num;
ui.text_refreshnum.text = "x" + refresh_num;
var buy_text = ui.btn_buypack.GetChild("title") as GTextField;
buy_text.SetVar("price", list[0].Paid_price.ToString()).FlushVars();
ui.text_goldnum2.text = "x" + GameHelper.Get101Str(list[1].coins_quantity);
var buy_text1 = ui.btn_buyremovead.GetChild("title") as GTextField;
buy_text1.SetVar("price", list[1].Paid_price.ToString()).FlushVars();
if (!GameHelper.IsAdModelOfPay())
{
ui.pay_type.selectedIndex = 1;
decimal price_pack = (decimal)list[0].Paid_price2;
ui.btn_max_pack.title = GameHelper.Get102Str(price_pack);
bool is_get = SaveData.GetSaveObject().is_get_packreward;
Debug.Log($"is_get================{is_get}");
if (is_get)
{
ui.btn_max_pack.enabled = false;
ui.btn_max_pack.title = Language.GetContent("Received");
ui.btn_max_pack.SetClick(() => { });
}
else
{
ui.btn_max_pack.enabled = true;
ui.btn_max_pack.SetClick(() =>
{
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price_pack * 100),
sku = IAPPayManager.PRODUCT_FIRST_GIFT,
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
decimal price_remove = (decimal)list[1].Paid_price2;
ui.btn_max_remove.title = GameHelper.Get102Str(price_remove);
bool is_get1 = SaveData.GetSaveObject().is_get_removead;
Debug.Log($"is_get1================{is_get1}");
if (is_get1)
{
HallManager.Instance.UpdateSecondEvent += RemoveAdCountDown;
ui.btn_max_remove.enabled = false;
ui.btn_max_remove.SetClick(() => { });
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
if (cd > 24 * 3600)
{
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
}
else
{
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
}
}
else
{
(ui.btn_max_remove as FGUI.ZM_Common_01.btn_max_buy).state.selectedIndex = 0;
ui.btn_max_remove.enabled = true;
ui.btn_max_remove.SetClick(() =>
{
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price_remove * 100),
sku = IAPPayManager.PRODUCT_REMOVE_ADS,
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
}
else
{
AdExchangeManager.Instance.Start();
SetTextString1();
bool is_get = SaveData.GetSaveObject().is_get_packreward;
Debug.Log($"is_get================{is_get}");
if (is_get)
{
(ui.btn_buypack as btn_watchAd).buy_state.selectedIndex = 1;
(ui.btn_buypack as btn_watchAd).can_buy.selectedIndex = 1;
ui.btn_buypack.title = Language.GetContent("Received");
}
ui.pay_type.selectedIndex = 0;
ui.btn_buyremovead.title = Language.GetContent("Receive_");
decimal price_remove = (decimal)list[1].Paid_price2;
bool is_get1 = SaveData.GetSaveObject().is_get_removead;
if (is_get1)
{
HallManager.Instance.UpdateSecondEvent += RemoveAdCountDown;
ui.btn_buyremovead.enabled = false;
ui.btn_buyremovead.SetClick(() => { });
var lastTimes = SaveData.GetSaveObject()._watch_ad_cd;
if (GameHelper.GetNowTime() < lastTimes)
{
}
(ui.btn_buyremovead as btn_watchAd).buy_state.selectedIndex = 1;
(ui.btn_buyremovead as btn_watchAd).can_buy.selectedIndex = 1;
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
if (cd > 24 * 3600)
{
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
}
else
{
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
}
}
}
}
private void RemoveAdCountDown()
{
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
if (cd > 0)
{
if (cd > 24 * 3600)
{
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
}
else
{
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
}
}
else
{
HallManager.Instance.UpdateSecondEvent -= RemoveAdCountDown;
SaveData.GetSaveObject().is_get_removead = false;
SaveData.GetSaveObject().remove_ad_time = 0;
InitView();
}
}
public void SetTextString1()
{
var remove_need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_REMOVE_ADS);
var pack_need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_FIRST_GIFT);
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
ui.tips1.SetVar("num", pack_need.ToString()).FlushVars();
ui.tips2.SetVar("num", remove_need.ToString()).FlushVars();
}
}
}
File diff suppressed because it is too large Load Diff
+164 -164
View File
@@ -1,165 +1,165 @@
using System;
using System.Collections.Generic;
using FairyGUI;
using FGUI.ZM_Common_01;
using IgnoreOPS;
using SGModule.NetKit;
namespace BallKingdomCrush
{
public class PassunlockUI : BaseUI
{
private PassunlockUICtrl ctrl;
private PassunlockModel model;
private FGUI.ZM_Pass_14.com_passunlock ui;
public btn_watchAd btn_WatchAd;
public PassunlockUI(PassunlockUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.PassunlockUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_Pass_14";
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()
{
AdExchangeManager.Instance.Destroy();
GameHelper.CallShowTurn();
if (_loader != null && !_loader.isDisposed && _loader.texture != null)
{
_loader.texture = null;
}
_loader = null;
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_Pass_14.com_passunlock;
}
private GLoader _loader = new GLoader();
protected override void OnOpenBefore(object args)
{
_loader = ui.loader.picture;
if (GameHelper.IsAdModelOfPay()) {
ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.battle_pass), ui.btn_buypass as btn_watchAd,SetTextString);
AdExchangeManager.Instance.Start();
SetTextString();
} else {
ui.pay_type.selectedIndex = 1;
decimal price = (decimal)GameHelper.GetCommonModel().Passportgift2;
ui.btn_max_pay.title = GameHelper.Get102Str(price);
ui.btn_max_pay.SetClick(() => {
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price * 100),
sku = PurchasingManager.GetPaySku(PayType.battle_pass),
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
InitView();
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.master_pass_show);
if (GameHelper.IsGiftSwitch())
{
ui.state.selectedIndex = 1;
var fileName = GameHelper.GetBackgroundName(des_key.pass_gift.ToString());
TextureHelper.SetImgLoader(ui.loader.picture, fileName, null, "Background/", FolderNames.BackgroundName);
}
else
{
ui.state.selectedIndex = 0;
}
}
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;
string purch_number = "";
if (type == PurchasingManager.GetPaySku(PayType.battle_pass))
{
CtrlCloseUI();
}
// if (purch_number != "")
// {
// GameHelper.SendRevenueToAF(purch_number);
// }
}
//初始化页面逻辑
private void InitView()
{
ui.btn_close.SetClick(CtrlCloseUI);
int gold = 0;
List<Passportrewards> Passportrewards_list = ConfigSystem.GetConfig<Passportrewards>();
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 = GameHelper.Get101Str(gold);
}
public void SetTextString()
{
var need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.battle_pass));
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.tips.SetVar("num", need.ToString()).FlushVars();
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
}
}
using System;
using System.Collections.Generic;
using FairyGUI;
using FGUI.ZM_Common_01;
using IgnoreOPS;
using SGModule.NetKit;
namespace BallKingdomCrush
{
public class PassunlockUI : BaseUI
{
private PassunlockUICtrl ctrl;
private PassunlockModel model;
private FGUI.ZM_Pass_14.com_passunlock ui;
public btn_watchAd btn_WatchAd;
public PassunlockUI(PassunlockUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.PassunlockUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_Pass_14";
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()
{
AdExchangeManager.Instance.Destroy();
GameHelper.CallShowTurn();
if (_loader != null && !_loader.isDisposed && _loader.texture != null)
{
_loader.texture = null;
}
_loader = null;
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_Pass_14.com_passunlock;
}
private GLoader _loader = new GLoader();
protected override void OnOpenBefore(object args)
{
_loader = ui.loader.picture;
if (GameHelper.IsAdModelOfPay()) {
ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_PASS_BONUS, ui.btn_buypass as btn_watchAd,SetTextString);
AdExchangeManager.Instance.Start();
SetTextString();
} else {
ui.pay_type.selectedIndex = 1;
decimal price = (decimal)GameHelper.GetCommonModel().Passportgift2;
ui.btn_max_pay.title = GameHelper.Get102Str(price);
ui.btn_max_pay.SetClick(() => {
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price * 100),
sku = IAPPayManager.PRODUCT_PASS_BONUS,
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
InitView();
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.master_pass_show);
if (GameHelper.IsGiftSwitch())
{
ui.state.selectedIndex = 1;
var fileName = GameHelper.GetBackgroundName(des_key.pass_gift.ToString());
TextureHelper.SetImgLoader(ui.loader.picture, fileName, null, "Background/", FolderNames.BackgroundName);
}
else
{
ui.state.selectedIndex = 0;
}
}
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.IAP_PAY_SUCCESS, pay_success);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
string purch_number = "";
if (type == IAPPayManager.PRODUCT_PASS_BONUS)
{
CtrlCloseUI();
}
// if (purch_number != "")
// {
// GameHelper.SendRevenueToAF(purch_number);
// }
}
//初始化页面逻辑
private void InitView()
{
ui.btn_close.SetClick(CtrlCloseUI);
int gold = 0;
List<Passportrewards> Passportrewards_list = ConfigSystem.GetConfig<Passportrewards>();
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 = GameHelper.Get101Str(gold);
}
public void SetTextString()
{
var need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_PASS_BONUS);
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.tips.SetVar("num", need.ToString()).FlushVars();
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
}
}
}
+327 -341
View File
@@ -1,342 +1,328 @@
using System.Collections.Generic;
using System.Globalization;
using AppsFlyerSDK;
using FairyGUI;
using IgnoreOPS;
using SGModule.Common.Extensions;
using SGModule.Net;
using SGModule.NetKit;
using UnityEngine;
namespace BallKingdomCrush
{
public class RainPlayUICtrl : BaseUICtrl
{
private RainPlayUI ui;
private RainPlayModel model;
private uint openUIMsg = UICtrlMsg.RainPlayUI_Open;
private uint closeUIMsg = UICtrlMsg.RainPlayUI_Close;
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.RainPlayModel) as RainPlayModel;
}
protected override void OnDispose()
{
}
public override void OpenUI(object args = null)
{
if (ui == null)
{
ui = new RainPlayUI(this);
ui.Open(args);
}
}
public override void CloseUI(object args = null)
{
if (ui != null && !ui.isClose)
{
ui.Close();
}
ui = null;
}
#endregion
#region
public override uint GetOpenUIMsg(string uiName)
{
return openUIMsg;
}
public override uint GetCloseUIMsg(string uiName)
{
return closeUIMsg;
}
protected override void AddListener()
{
uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
}
protected override void RemoveListener()
{
uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI);
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
}
protected override void AddServerListener()
{
}
protected override void RemoveServerListener()
{
}
private bool CheckIsOpen(string name)
{
var isOpen = UIManager.Instance.IsExistUI(name);
return isOpen;
}
private void GetPayReward(decimal goldNum)
{
if (goldNum == 0) return;
if (ui == null)
{
DataMgr.Coin.Value += goldNum.As<int>();
return;
}
GImage endObj = ui.getCoinPosition();
var start = new Vector2(540, 960);
var end = GameHelper.GetUICenterPosition(endObj);
var rewardData = new RewardData();
var rewardSingleData = new RewardSingleData(101, goldNum, RewardOrigin.AdTask)
{
startPosition = start,
endPosition = end,
};
rewardData.AddReward(rewardSingleData);
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
}
void pay_success(object str)
{
string type = (string)str;
bool is_secret_albnums = false;
string purch_number = "";
if (type.Contains("buy_gold"))
{
if (type.StartsWith("buy_gold"))
{
int startIndex = "buy_gold".Length;
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffix_num = int.Parse(suffix);
purch_number = ConfigSystem.GetConfig<Paidcoins>()[suffix_num].Payment_amount2.ToString();
if (!UIManager.Instance.IsExistUI(UIConst.BuygoldUI))
{
List<Paidcoins> list = ConfigSystem.GetConfig<Paidcoins>();
// GameHelper.AddGoldNumber(list[suffix_num].Actual_coins);
int gold_num = list[suffix_num].Actual_coins;
GetPayReward(gold_num);
SaveData.GetSaveObject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
SaveData.SaveDataFunc();
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
}
}
}
else if (type == PurchasingManager.GetPaySku(PayType.battle_pass))
{
SaveData.GetSaveObject().is_get_battlepass = true;
int gold = 0;
int out_ = 0;
int back_ = 0;
int refresh_ = 0;
List<Passportrewards> Passportrewards_list = ConfigSystem.GetConfig<Passportrewards>();
for (int i = 0; i < Passportrewards_list.Count; i++)
{
if (GameHelper.GetBattleLv() > i|| (GameHelper.GetGameExp() >= Passportrewards_list[Passportrewards_list.Count-1].Eliminating_quantity))
{
if (Passportrewards_list[i].Paid_rewards_type == 0) gold += Passportrewards_list[i].Paid_rewards_num;
else if (Passportrewards_list[i].Paid_rewards_type == 1) out_ += Passportrewards_list[i].Paid_rewards_num;
else if (Passportrewards_list[i].Paid_rewards_type == 2) back_ += Passportrewards_list[i].Paid_rewards_num;
else if (Passportrewards_list[i].Paid_rewards_type == 3) refresh_ += Passportrewards_list[i].Paid_rewards_num;
SaveData.GetSaveObject().battle_pass_paylist.Add(i + 1);
}
else break;
}
GameHelper.AddItemNumber(0, out_);
GameHelper.AddItemNumber(1, back_);
GameHelper.AddItemNumber(2, refresh_);
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
SaveData.SaveDataFunc();
purch_number = ConfigSystem.GetCommonConf().Passportgift2.ToString();
if (!CheckIsOpen(UIConst.PassViewUI))
{
// DataMgr.Coin.Value += gold;
GetPayReward(gold);
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
}
}
else if (type == PurchasingManager.GetPaySku(PayType.buy_one))
{
SaveData.GetSaveObject().have_slot = true;
SaveData.SaveDataFunc();
GameDispatcher.Instance.Dispatch(GameMsg.Slot_refresh);
GameHelper.ShowTips("purchase_succ", true);
purch_number = GameHelper.GetCommonModel().addspace2.ToString();
}
else if (type == PurchasingManager.GetPaySku(PayType.remove_ad))
{
SaveData.GetSaveObject().remove_ad_time = (int)GameHelper.GetNowTime() + ConfigSystem.GetCommonConf().RemoveADsPackDuration * 3600;
SaveData.GetSaveObject().is_get_removead = true;
SaveData.SaveDataFunc();
// GameHelper.AddGoldNumber(ConfigSystem.GetConfig<Paidgift>()[1].coins_quantity);
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
ui?.setBtnAds();
GameDispatcher.Instance.Dispatch(GameMsg.UpdateNoads);
GameHelper.ShowTips("purchase_succ", true);
purch_number = ConfigSystem.GetConfig<Paidgift>()[1].Paid_price2.ToString();
if (!CheckIsOpen(UIConst.LuckyPackUI))
{
// DataMgr.Coin.Value += ConfigSystem.GetConfig<Paidgift>()[1].coins_quantity;
int gold_num = ConfigSystem.GetConfig<Paidgift>()[1].coins_quantity;
GetPayReward(gold_num);
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
}
}
else if (type == PurchasingManager.GetPaySku(PayType.pack_reward))
{
List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
int gold_num = list[0].coins_quantity;
int back_num = list[0].props_quantity[1];
int out_num = list[0].props_quantity[0];
int refresh_num = list[0].props_quantity[2];
Debug.Log($"[PayType.pack_reward 1] gold_num==={gold_num}==={out_num}==={back_num}==={refresh_num}");
GameHelper.AddItemNumber(0, out_num);
GameHelper.AddItemNumber(1, back_num);
GameHelper.AddItemNumber(2, refresh_num);
SaveData.GetSaveObject().is_get_packreward = true;
SaveData.SaveDataFunc();
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
ui?.setBtnAds();
GameDispatcher.Instance.Dispatch(GameMsg.UpdateNoads);
GameHelper.ShowTips("purchase_succ", true);
purch_number = ConfigSystem.GetConfig<Paidgift>()[0].Paid_price2.ToString();
if (!CheckIsOpen(UIConst.LuckyPackUI))
{
// DataMgr.Coin.Value += gold_num;
Debug.Log($"[PayType.pack_reward 2] gold_num==={gold_num}==={out_num}==={back_num}==={refresh_num}");
GetPayReward(gold_num);
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
}
}
else if (type == PurchasingManager.GetPaySku(PayType.fail_pack))
{
List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
purch_number = ConfigSystem.GetConfig<Paidgift>()[2].Paid_price2.ToString();
//ui?.setBtnAds();
GameDispatcher.Instance.Dispatch(GameMsg.resurgence);
// DataMgr.Coin.Value += ConfigSystem.GetConfig<Paidgift>()[1].coins_quantity;
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
int back_num = list[2].props_quantity[1];
int out_num = list[2].props_quantity[0];
int refresh_num = list[2].props_quantity[2];
//GameHelper.addGoldNumber(gold_num);
int gold_num = list[2].coins_quantity;
if (!UIManager.Instance.IsExistUI(UIConst.ResurgenceUI)) DataMgr.Coin.Value += gold_num;
GameHelper.AddItemNumber(0, out_num);
GameHelper.AddItemNumber(1, back_num);
GameHelper.AddItemNumber(2, refresh_num);
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
SaveData.SaveDataFunc();
}
else if (type == PurchasingManager.GetPaySku(PayType.three_days_gift))
{
SaveData.GetSaveObject().is_get_ThreeDaysGift = true;
SaveData.SaveDataFunc();
purch_number = ConfigSystem.GetConfig<Multigift>()[0].Paid_price2.ToString();
}
else if (type.StartsWith("vip_club"))
{
int startIndex = "vip_club".Length;
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffixNum = int.Parse(suffix);
if (!MaxPayManager.isOfficialPay)
{
var days = 0;
switch (suffixNum)
{
case 0:
days = (int)VipDay.Week;
break;
case 1:
days = (int)VipDay.Month;
break;
case 2:
days = (int)VipDay.Year;
break;
}
if (days > 0)
{
// 设置 VIP 到期时间(当前时间戳 + VIP 天数对应的秒数)
DataMgr.VipExpirationTime.Value =
ServerClock.GetCurrentServerTime() + days * 24 * 60 * 60;
}
DataMgr.VipLevel.Value = suffixNum + 1;
}
GameDispatcher.Instance.Dispatch(GameMsg.BuyVip);
purch_number = ConfigSystem.GetConfig<VipClub>()[suffixNum].DiscountPrice.ToString();
}
else if (type.StartsWith("secret_albnums"))
{
is_secret_albnums = true;
int startIndex = "secret_albnums".Length;
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffix_num = int.Parse(suffix);
var model = ConfigSystem.GetConfig<SecretAlbums>()[suffix_num];
if (model.PayType == (int)UnlockPayType.Pay)
{
purch_number = ConfigSystem.GetConfig<SecretAlbums>()[suffix_num].DiscountPrice.ToString();
}
}
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
if ((!GameHelper.IsAdModelOfPay() || is_secret_albnums) && !string.IsNullOrEmpty(purch_number) && decimal.TryParse(purch_number, out decimal revenue))
{
var payType = MaxPayManager.isOfficialPay ? 0 : 1;
// 付费上报BI
BIManager.Instance.TrackPurchase(purch_number.As<double>(), "USD", payType.ToString(), type, "paid");
Debug.Log("付费收益上报AF----------- " + revenue);
adCallbackInfo.Clear();
adCallbackInfo.Add("appsflyer_id", AppsFlyer.getAppsFlyerId());
adCallbackInfo.Add("customer_user_id", GameHelper.GetLoginModel().Uid.ToString());
adCallbackInfo.Add("af_currency", "USD");
adCallbackInfo.Add("af_revenue", revenue.ToString(CultureInfo.InvariantCulture));
AppsFlyer.sendEvent("af_purchase", adCallbackInfo);
FireBaseManger.OnPayRevenueEvent(purch_number.As<double>());
TrackKit.SendEvent(AfPurchaseTrack.Event, AfPurchaseTrack.Property.af_revenue,(int)(purch_number.As<decimal>() * 10000));
}
}
#endregion
public static Dictionary<string, string> adCallbackInfo = new Dictionary<string, string>();
}
using System.Collections.Generic;
using System.Globalization;
using AppsFlyerSDK;
using FairyGUI;
using IgnoreOPS;
using SGModule.Common.Extensions;
using SGModule.Net;
using SGModule.NetKit;
using UnityEngine;
namespace BallKingdomCrush
{
public class RainPlayUICtrl : BaseUICtrl
{
private RainPlayUI ui;
private RainPlayModel model;
private uint openUIMsg = UICtrlMsg.RainPlayUI_Open;
private uint closeUIMsg = UICtrlMsg.RainPlayUI_Close;
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.RainPlayModel) as RainPlayModel;
}
protected override void OnDispose()
{
}
public override void OpenUI(object args = null)
{
if (ui == null)
{
ui = new RainPlayUI(this);
ui.Open(args);
}
}
public override void CloseUI(object args = null)
{
if (ui != null && !ui.isClose)
{
ui.Close();
}
ui = null;
}
#endregion
#region
public override uint GetOpenUIMsg(string uiName)
{
return openUIMsg;
}
public override uint GetCloseUIMsg(string uiName)
{
return closeUIMsg;
}
protected override void AddListener()
{
uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
protected override void RemoveListener()
{
uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI);
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
protected override void AddServerListener()
{
}
protected override void RemoveServerListener()
{
}
private bool CheckIsOpen(string name)
{
var isOpen = UIManager.Instance.IsExistUI(name);
return isOpen;
}
private void GetPayReward(decimal goldNum)
{
if (goldNum == 0) return;
if (ui == null)
{
DataMgr.Coin.Value += goldNum.As<int>();
return;
}
GImage endObj = ui.getCoinPosition();
var start = new Vector2(540, 960);
var end = GameHelper.GetUICenterPosition(endObj);
var rewardData = new RewardData();
var rewardSingleData = new RewardSingleData(101, goldNum, RewardOrigin.AdTask)
{
startPosition = start,
endPosition = end,
};
rewardData.AddReward(rewardSingleData);
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
}
void pay_success(object str)
{
string type = (string)str;
bool is_secret_albnums = false;
string purch_number = "";
if (PurchasingManager._shopProductMap.TryGetValue(type, out var shopId))
{
int suffix_num = int.Parse(shopId);
purch_number = ConfigSystem.GetConfig<Paidcoins>()[suffix_num].Payment_amount2.ToString();
if (!UIManager.Instance.IsExistUI(UIConst.BuygoldUI))
{
List<Paidcoins> list = ConfigSystem.GetConfig<Paidcoins>();
// GameHelper.AddGoldNumber(list[suffix_num].Actual_coins);
int gold_num = list[suffix_num].Actual_coins;
GetPayReward(gold_num);
SaveData.GetSaveObject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
SaveData.SaveDataFunc();
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
}
}
else if (type == IAPPayManager.PRODUCT_PASS_BONUS)
{
SaveData.GetSaveObject().is_get_battlepass = true;
int gold = 0;
int out_ = 0;
int back_ = 0;
int refresh_ = 0;
List<Passportrewards> Passportrewards_list = ConfigSystem.GetConfig<Passportrewards>();
for (int i = 0; i < Passportrewards_list.Count; i++)
{
if (GameHelper.GetBattleLv() > i|| (GameHelper.GetGameExp() >= Passportrewards_list[Passportrewards_list.Count-1].Eliminating_quantity))
{
if (Passportrewards_list[i].Paid_rewards_type == 0) gold += Passportrewards_list[i].Paid_rewards_num;
else if (Passportrewards_list[i].Paid_rewards_type == 1) out_ += Passportrewards_list[i].Paid_rewards_num;
else if (Passportrewards_list[i].Paid_rewards_type == 2) back_ += Passportrewards_list[i].Paid_rewards_num;
else if (Passportrewards_list[i].Paid_rewards_type == 3) refresh_ += Passportrewards_list[i].Paid_rewards_num;
SaveData.GetSaveObject().battle_pass_paylist.Add(i + 1);
}
else break;
}
GameHelper.AddItemNumber(0, out_);
GameHelper.AddItemNumber(1, back_);
GameHelper.AddItemNumber(2, refresh_);
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
SaveData.SaveDataFunc();
purch_number = ConfigSystem.GetCommonConf().Passportgift2.ToString();
if (!CheckIsOpen(UIConst.PassViewUI))
{
// DataMgr.Coin.Value += gold;
GetPayReward(gold);
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
}
}
else if (type == IAPPayManager.PRODUCT_SPACE_BONUS)
{
SaveData.GetSaveObject().have_slot = true;
SaveData.SaveDataFunc();
GameDispatcher.Instance.Dispatch(GameMsg.Slot_refresh);
GameHelper.ShowTips("purchase_succ", true);
purch_number = GameHelper.GetCommonModel().addspace2.ToString();
}
else if (type == IAPPayManager.PRODUCT_REMOVE_ADS)
{
SaveData.GetSaveObject().remove_ad_time = (int)GameHelper.GetNowTime() + ConfigSystem.GetCommonConf().RemoveADsPackDuration * 3600;
SaveData.GetSaveObject().is_get_removead = true;
SaveData.SaveDataFunc();
// GameHelper.AddGoldNumber(ConfigSystem.GetConfig<Paidgift>()[1].coins_quantity);
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
ui?.setBtnAds();
GameDispatcher.Instance.Dispatch(GameMsg.UpdateNoads);
GameHelper.ShowTips("purchase_succ", true);
purch_number = ConfigSystem.GetConfig<Paidgift>()[1].Paid_price2.ToString();
if (!CheckIsOpen(UIConst.LuckyPackUI))
{
// DataMgr.Coin.Value += ConfigSystem.GetConfig<Paidgift>()[1].coins_quantity;
int gold_num = ConfigSystem.GetConfig<Paidgift>()[1].coins_quantity;
GetPayReward(gold_num);
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
}
}
else if (type == IAPPayManager.PRODUCT_FIRST_GIFT)
{
List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
int gold_num = list[0].coins_quantity;
int back_num = list[0].props_quantity[1];
int out_num = list[0].props_quantity[0];
int refresh_num = list[0].props_quantity[2];
Debug.Log($"[PayType.pack_reward 1] gold_num==={gold_num}==={out_num}==={back_num}==={refresh_num}");
GameHelper.AddItemNumber(0, out_num);
GameHelper.AddItemNumber(1, back_num);
GameHelper.AddItemNumber(2, refresh_num);
SaveData.GetSaveObject().is_get_packreward = true;
SaveData.SaveDataFunc();
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
ui?.setBtnAds();
GameDispatcher.Instance.Dispatch(GameMsg.UpdateNoads);
GameHelper.ShowTips("purchase_succ", true);
purch_number = ConfigSystem.GetConfig<Paidgift>()[0].Paid_price2.ToString();
if (!CheckIsOpen(UIConst.LuckyPackUI))
{
// DataMgr.Coin.Value += gold_num;
Debug.Log($"[PayType.pack_reward 2] gold_num==={gold_num}==={out_num}==={back_num}==={refresh_num}");
GetPayReward(gold_num);
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
}
}
// else if (type == PurchasingManager.GetPaySku(PayType.fail_pack))
// {
// List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
// purch_number = ConfigSystem.GetConfig<Paidgift>()[2].Paid_price2.ToString();
// //ui?.setBtnAds();
// GameDispatcher.Instance.Dispatch(GameMsg.resurgence);
//
// // DataMgr.Coin.Value += ConfigSystem.GetConfig<Paidgift>()[1].coins_quantity;
// // GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
// int back_num = list[2].props_quantity[1];
// int out_num = list[2].props_quantity[0];
// int refresh_num = list[2].props_quantity[2];
// //GameHelper.addGoldNumber(gold_num);
// int gold_num = list[2].coins_quantity;
// if (!UIManager.Instance.IsExistUI(UIConst.ResurgenceUI)) DataMgr.Coin.Value += gold_num;
// GameHelper.AddItemNumber(0, out_num);
// GameHelper.AddItemNumber(1, back_num);
// GameHelper.AddItemNumber(2, refresh_num);
// GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
// SaveData.SaveDataFunc();
//
// }
else if (type == IAPPayManager.PRODUCT_THREE_DAY)
{
SaveData.GetSaveObject().is_get_ThreeDaysGift = true;
SaveData.SaveDataFunc();
purch_number = ConfigSystem.GetConfig<Multigift>()[0].Paid_price2.ToString();
}
else if (PurchasingManager._vipProductMap.TryGetValue(type, out var vipIdx))
{
var suffixNum = int.Parse(vipIdx);
if (!MaxPayManager.isOfficialPay)
{
var days = suffixNum switch
{
0 => (int)VipDay.Week,
1 => (int)VipDay.Month,
2 => (int)VipDay.Year,
_ => 0
};
if (days > 0)
{
// 设置 VIP 到期时间(当前时间戳 + VIP 天数对应的秒数)
DataMgr.VipExpirationTime.Value =
ServerClock.GetCurrentServerTime() + days * 24 * 60 * 60;
}
DataMgr.VipLevel.Value = suffixNum + 1;
}
GameDispatcher.Instance.Dispatch(GameMsg.BuyVip);
purch_number = ConfigSystem.GetConfig<VipClub>()[suffixNum].DiscountPrice.ToString();
}
else if (type.StartsWith("secret_albnums"))
{
is_secret_albnums = true;
int startIndex = "secret_albnums".Length;
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffix_num = int.Parse(suffix);
var model = ConfigSystem.GetConfig<SecretAlbums>()[suffix_num];
if (model.PayType == (int)UnlockPayType.Pay)
{
purch_number = ConfigSystem.GetConfig<SecretAlbums>()[suffix_num].DiscountPrice.ToString();
}
}
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
if ((!GameHelper.IsAdModelOfPay() || is_secret_albnums) && !string.IsNullOrEmpty(purch_number) && decimal.TryParse(purch_number, out decimal revenue))
{
var payType = MaxPayManager.isOfficialPay ? 0 : 1;
// 付费上报BI
BIManager.Instance.TrackPurchase(purch_number.As<double>(), "USD", payType.ToString(), type, "paid");
Debug.Log("付费收益上报AF----------- " + revenue);
adCallbackInfo.Clear();
adCallbackInfo.Add("appsflyer_id", AppsFlyer.getAppsFlyerId());
adCallbackInfo.Add("customer_user_id", GameHelper.GetLoginModel().Uid.ToString());
adCallbackInfo.Add("af_currency", "USD");
adCallbackInfo.Add("af_revenue", revenue.ToString(CultureInfo.InvariantCulture));
AppsFlyer.sendEvent("af_purchase", adCallbackInfo);
FireBaseManger.OnPayRevenueEvent(purch_number.As<double>());
TrackKit.SendEvent(AfPurchaseTrack.Event, AfPurchaseTrack.Property.af_revenue,(int)(purch_number.As<decimal>() * 10000));
}
}
#endregion
public static Dictionary<string, string> adCallbackInfo = new Dictionary<string, string>();
}
}
@@ -1,430 +1,430 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DG.Tweening;
using FairyGUI;
using FGUI.LG_secretAlbums;
using SGModule.Common.Helper;
using SGModule.NetKit;
using UnityEngine;
namespace BallKingdomCrush
{
public class SecretAlbumsNextUI : BaseUI
{
private SecretAlbumsNextUICtrl ctrl;
private SecretAlbumsNextModel model;
private FGUI.LG_secretAlbums.com_scAlbumPreview ui;
public SecretAlbumsNextUI(SecretAlbumsNextUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.SecretAlbumsNextUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "LG_secretAlbums";
uiInfo.assetName = "com_scAlbumPreview";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.SecretAlbumsModel) as SecretAlbumsModel;
}
protected override void OnClose()
{
HallManager.Instance.UpdateSecondEvent -= UpWatchAdsBtn;
// 清理 Loader 的材质和贴图
foreach (var loader in loader_list)
{
if (loader == null || loader.isDisposed) continue;
// 释放材质到材质池
if (loader.material != null)
{
TextureHelper.CancelImageBlur(loader); // 自动返回材质池
loader.material = null;
}
// 清理 NTexture
if (loader.texture != null)
{
if (loader.texture.destroyMethod == DestroyMethod.Destroy)
loader.texture.Dispose(); // 销毁 NTexture 对象
loader.texture = null;
}
}
loader_list.Clear();
// 强制卸载未使用的资源
Resources.UnloadUnusedAssets();
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_secretAlbums.com_scAlbumPreview;
}
private AlbumPreviewData _albumPreviewData;
protected override void OnOpenBefore(object args)
{
if (args == null) return;
_albumPreviewData = (AlbumPreviewData)args;
InitView();
var event_names = ADEventTrack.Property.secret_albums_show + (_albumPreviewData.Index + 1);
var event_type = _albumPreviewData.PayType == (int)UnlockPayType.Ad ? ADEventTrack.AD_Event : ADEventTrack.MaxPayEvent;
TrackKit.SendEvent(event_type, event_names);
}
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);
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, InitView);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, InitView);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
string purch_number = "";
if (type.StartsWith("secret_albnums"))
{
int startIndex = "secret_albnums".Length;
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffix_num = int.Parse(suffix);
Log.Info("Secret_pay_success", $"index================:{suffix_num}");
// 判断是否已存在,避免重复添加
if (!DataMgr.SecretUnlockList.Value.Contains(suffix_num))
{
DataMgr.SecretUnlockList.Value.Add(suffix_num);
DataMgr.SecretUnlockList.Save();
GameDispatcher.Instance.Dispatch(GameMsg.UnlockSecretSuccess);
}
GameHelper.ShowTips("purchase_succ", true);
InitView();
}
}
private List<string> _secretData;
private bool is_unlock = false; //当前专辑是否解锁
private List<GLoader> loader_list = new List<GLoader>();
//初始化页面逻辑
private void InitView(object a = null)
{
// 先清理上一次的 loader 和任务
foreach (var l in loader_list)
{
if (l != null && !l.isDisposed)
{
TextureHelper.CancelImageBlur(l); // 放回材质池
if (l.texture != null)
{
l.texture.Dispose();
l.texture = null;
}
if (l.material != null) l.material = null;
}
}
loader_list.Clear();
_tasks.Clear();
//专辑解锁状态
is_unlock = DataMgr.SecretUnlockList.Value.Contains(_albumPreviewData.Index);
UpWatchAdsBtn();
// if (_albumPreviewData.PayType == (int)UnlockPayType.Ad &&
// DataMgr.SecretUnlockCd.Value.TryGetValue(_albumPreviewData.Index, out var unlockCdValue) &&
// unlockCdValue > 0)
// {
// }
HallManager.Instance.UpdateSecondEvent += UpWatchAdsBtn;
ui.btn_close.SetClick(CtrlCloseUI);
// ui.text_original_price.text = _albumPreviewData.Price.ToString();
ui.old_price.text = GameHelper.getPrice((decimal)_albumPreviewData.Price);
ui.btn_pay.title = GameHelper.getPrice((decimal)_albumPreviewData.DiscountPrice);
_secretData = SplitStringToList(_albumPreviewData.Name2);
ui.list.itemRenderer = ItemRender;
ui.list.numItems = _secretData.Count;
ui.pay_type.selectedIndex = !is_unlock ? _albumPreviewData.PayType : (int)UnlockPayType.None;
if (is_unlock)
{
ui.pay_type.selectedIndex = (int)UnlockPayType.None;
}
else
{
if (_albumPreviewData.SubscribeUnlock == 1)
{
ui.vip.selectedIndex = 1;
if (GameHelper.GetVipLevel() >= 1)
{
ui.has_vip.selectedIndex = 1;
}
else
{
ui.has_vip.selectedIndex = 0;
}
}
else
{
ui.vip.selectedIndex = 0;
}
ui.pay_type.selectedIndex = _albumPreviewData.PayType;
}
var _type = "secret_albnums" + _albumPreviewData.Index;
ui.btn_pay.SetClick(() =>
{
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(_albumPreviewData.DiscountPrice * 100),
sku = _type,
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
ui.btn_gold.title = _albumPreviewData.GoldCoins.ToString();
ui.btn_gold.SetClick(() =>
{
if (GameHelper.Get101() >= _albumPreviewData.GoldCoins)
{
GameHelper.AddGold(-_albumPreviewData.GoldCoins);
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _type);
string eventName = ADEventTrack.Property.secret_albums_success_ + (_albumPreviewData.Index + 1);
TrackKit.SendEvent(ADEventTrack.SecretAlbums, eventName);
GameDispatcher.Instance.Dispatch(GameMsg.Update101);
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.unlock_secretAlbums_resources);
}
else
{
GameHelper.ShowTips("no_enough_gold", true);
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
}
});
var AdCount = DataMgr.SecretUnlockADs.Value.GetValueOrDefault(_albumPreviewData.Index, 0);
ui.btn_watch.ads.SetVar("ads", AdCount + "/" + _albumPreviewData.AD).FlushVars();
ui.btn_watch.SetClick(() =>
{
if (AdCount >= _albumPreviewData.AD)
{
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _type);
}
else
{
GameHelper.ShowVideoAd("UnlockSecretAlbums", (isSuccess) =>
{
if (isSuccess)
{
var adTimes = Convert.ToInt32(GameHelper.GetNowTime());
DataMgr.SecretUnlockCd.Value[_albumPreviewData.Index] = adTimes + _albumPreviewData.CD;
DataMgr.SecretUnlockCd.Save();
var currentAdCount = DataMgr.SecretUnlockADs.Value.GetValueOrDefault(_albumPreviewData.Index, 0);
DataMgr.SecretUnlockADs.Value[_albumPreviewData.Index] = currentAdCount + 1;
DataMgr.SecretUnlockADs.Save();
string eventName = ADEventTrack.Property.secret_albums_success_ + (_albumPreviewData.Index + 1);
TrackKit.SendEvent(ADEventTrack.AD_Event, eventName);
InitView();
}
});
}
});
ui.btn_vip.SetClick(() =>
{
TrackKit.SendEvent(ADEventTrack.SecretAlbums, ADEventTrack.Property.secret_albums_click_ + (_albumPreviewData.Index + 1));
if (GameHelper.GetVipLevel() >= 1)
{
GameHelper.isVipUnlock = true;
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _type);
string eventName = ADEventTrack.Property.vip_secret_albums_unclock_ + (_albumPreviewData.Index + 1);
TrackKit.SendEvent(ADEventTrack.VipSecretAlbums, eventName);
}
else
{
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open, 2);
TrackKit.SendEvent(ADEventTrack.VipSecretAlbums, ADEventTrack.Property.vip_secret_albums_unclock);
}
});
}
private List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)> _tasks = new();
private void ItemRender(int index, GObject obj)
{
var item = (item_scAlbumPreview)obj;
var picture = (GLoader)item.com_pic_in.GetChild("picture");
if (!loader_list.Contains(picture))
loader_list.Add(picture);
var state = GetSafe(_albumPreviewData.State, index);
item.state.selectedIndex = is_unlock ? 0 : state;
var task = (picture, _secretData[index], (Action<NTexture>)(s =>
{
if (picture != null && !picture.isDisposed)
{
if (!is_unlock && state == 1)
TextureHelper.SetImageBlur(picture);
else
TextureHelper.CancelImageBlur(picture);
}
}), $"SecretAlbums/{_albumPreviewData.Name}/", FolderNames.SecretName);
_tasks.Add(task);
item.btn_detail.SetClick(() =>
{
if (is_unlock)
{
var data = new DetailData
{
Name = _secretData[index],
Name1 = $"SecretAlbums/{_albumPreviewData.Name}/"
};
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretDetailUI_Open, data);
}
else
{
GameHelper.ShowTips("not_unlocked", true);
}
});
if (index == _secretData.Count - 1)
{
TextureHelper.SetImgLoaders(_tasks);
}
}
private void UpWatchAdsBtn()
{
DataMgr.SecretUnlockCd.Value.TryGetValue(_albumPreviewData.Index, out var lastTimes);
if (DataMgr.SecretUnlockADs.Value.TryGetValue(_albumPreviewData.Index, out var unlockAdValue) &&
unlockAdValue >= _albumPreviewData.AD)
{
ui.btn_watch.can_buy.selectedIndex = 1;
}
else
{
ui.btn_watch.can_buy.selectedIndex = 0;
if (GameHelper.GetNowTime() < lastTimes)
{
ui.btn_watch.enabled = false;
ui.btn_watch.CD.selectedIndex = 1;
ui.btn_watch.watch_cd.text =
CommonHelper.TimeFormat(lastTimes - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
}
else
{
ui.btn_watch.enabled = true;
ui.btn_watch.CD.selectedIndex = 0;
}
}
}
// 拆分字符串为列表
public static List<string> SplitStringToList(string input)
{
if (string.IsNullOrWhiteSpace(input))
return new List<string>();
// 支持英文逗号, 中文逗号,空格
char[] separators = new char[] { ',', '', ' ' };
return input
.Split(separators, StringSplitOptions.RemoveEmptyEntries)
.Select(s => s.Trim()) // 去掉前后空白
.ToList();
}
/// <summary>
/// 安全获取列表或数组中的元素,如果越界则返回最后一个元素;如果为空则返回默认值。
/// </summary>
public static T GetSafe<T>(IList<T> list, int index, T defaultValue = default)
{
if (list == null || list.Count == 0)
return defaultValue;
if (index < 0)
return list[0];
if (index >= list.Count)
return list[list.Count - 1];
return list[index];
}
}
public class DetailData
{
public string Name;
public string Name1;
}
using System;
using System.Collections.Generic;
using System.Linq;
using DG.Tweening;
using FairyGUI;
using FGUI.LG_secretAlbums;
using SGModule.Common.Helper;
using SGModule.NetKit;
using UnityEngine;
namespace BallKingdomCrush
{
public class SecretAlbumsNextUI : BaseUI
{
private SecretAlbumsNextUICtrl ctrl;
private SecretAlbumsNextModel model;
private FGUI.LG_secretAlbums.com_scAlbumPreview ui;
public SecretAlbumsNextUI(SecretAlbumsNextUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.SecretAlbumsNextUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "LG_secretAlbums";
uiInfo.assetName = "com_scAlbumPreview";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.SecretAlbumsModel) as SecretAlbumsModel;
}
protected override void OnClose()
{
HallManager.Instance.UpdateSecondEvent -= UpWatchAdsBtn;
// 清理 Loader 的材质和贴图
foreach (var loader in loader_list)
{
if (loader == null || loader.isDisposed) continue;
// 释放材质到材质池
if (loader.material != null)
{
TextureHelper.CancelImageBlur(loader); // 自动返回材质池
loader.material = null;
}
// 清理 NTexture
if (loader.texture != null)
{
if (loader.texture.destroyMethod == DestroyMethod.Destroy)
loader.texture.Dispose(); // 销毁 NTexture 对象
loader.texture = null;
}
}
loader_list.Clear();
// 强制卸载未使用的资源
Resources.UnloadUnusedAssets();
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_secretAlbums.com_scAlbumPreview;
}
private AlbumPreviewData _albumPreviewData;
protected override void OnOpenBefore(object args)
{
if (args == null) return;
_albumPreviewData = (AlbumPreviewData)args;
InitView();
var event_names = ADEventTrack.Property.secret_albums_show + (_albumPreviewData.Index + 1);
var event_type = _albumPreviewData.PayType == (int)UnlockPayType.Ad ? ADEventTrack.AD_Event : ADEventTrack.MaxPayEvent;
TrackKit.SendEvent(event_type, event_names);
}
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.IAP_PAY_SUCCESS, pay_success);
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, InitView);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, InitView);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
string purch_number = "";
if (type.StartsWith("secret_albnums"))
{
int startIndex = "secret_albnums".Length;
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffix_num = int.Parse(suffix);
Log.Info("Secret_pay_success", $"index================:{suffix_num}");
// 判断是否已存在,避免重复添加
if (!DataMgr.SecretUnlockList.Value.Contains(suffix_num))
{
DataMgr.SecretUnlockList.Value.Add(suffix_num);
DataMgr.SecretUnlockList.Save();
GameDispatcher.Instance.Dispatch(GameMsg.UnlockSecretSuccess);
}
GameHelper.ShowTips("purchase_succ", true);
InitView();
}
}
private List<string> _secretData;
private bool is_unlock = false; //当前专辑是否解锁
private List<GLoader> loader_list = new List<GLoader>();
//初始化页面逻辑
private void InitView(object a = null)
{
// 先清理上一次的 loader 和任务
foreach (var l in loader_list)
{
if (l != null && !l.isDisposed)
{
TextureHelper.CancelImageBlur(l); // 放回材质池
if (l.texture != null)
{
l.texture.Dispose();
l.texture = null;
}
if (l.material != null) l.material = null;
}
}
loader_list.Clear();
_tasks.Clear();
//专辑解锁状态
is_unlock = DataMgr.SecretUnlockList.Value.Contains(_albumPreviewData.Index);
UpWatchAdsBtn();
// if (_albumPreviewData.PayType == (int)UnlockPayType.Ad &&
// DataMgr.SecretUnlockCd.Value.TryGetValue(_albumPreviewData.Index, out var unlockCdValue) &&
// unlockCdValue > 0)
// {
// }
HallManager.Instance.UpdateSecondEvent += UpWatchAdsBtn;
ui.btn_close.SetClick(CtrlCloseUI);
// ui.text_original_price.text = _albumPreviewData.Price.ToString();
ui.old_price.text = GameHelper.getPrice((decimal)_albumPreviewData.Price);
ui.btn_pay.title = GameHelper.getPrice((decimal)_albumPreviewData.DiscountPrice);
_secretData = SplitStringToList(_albumPreviewData.Name2);
ui.list.itemRenderer = ItemRender;
ui.list.numItems = _secretData.Count;
ui.pay_type.selectedIndex = !is_unlock ? _albumPreviewData.PayType : (int)UnlockPayType.None;
if (is_unlock)
{
ui.pay_type.selectedIndex = (int)UnlockPayType.None;
}
else
{
if (_albumPreviewData.SubscribeUnlock == 1)
{
ui.vip.selectedIndex = 1;
if (GameHelper.GetVipLevel() >= 1)
{
ui.has_vip.selectedIndex = 1;
}
else
{
ui.has_vip.selectedIndex = 0;
}
}
else
{
ui.vip.selectedIndex = 0;
}
ui.pay_type.selectedIndex = _albumPreviewData.PayType;
}
var _type = "secret_albnums" + _albumPreviewData.Index;
ui.btn_pay.SetClick(() =>
{
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(_albumPreviewData.DiscountPrice * 100),
sku = _type,
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
ui.btn_gold.title = _albumPreviewData.GoldCoins.ToString();
ui.btn_gold.SetClick(() =>
{
if (GameHelper.Get101() >= _albumPreviewData.GoldCoins)
{
GameHelper.AddGold(-_albumPreviewData.GoldCoins);
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, _type);
string eventName = ADEventTrack.Property.secret_albums_success_ + (_albumPreviewData.Index + 1);
TrackKit.SendEvent(ADEventTrack.SecretAlbums, eventName);
GameDispatcher.Instance.Dispatch(GameMsg.Update101);
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.unlock_secretAlbums_resources);
}
else
{
GameHelper.ShowTips("no_enough_gold", true);
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
}
});
var AdCount = DataMgr.SecretUnlockADs.Value.GetValueOrDefault(_albumPreviewData.Index, 0);
ui.btn_watch.ads.SetVar("ads", AdCount + "/" + _albumPreviewData.AD).FlushVars();
ui.btn_watch.SetClick(() =>
{
if (AdCount >= _albumPreviewData.AD)
{
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, _type);
}
else
{
GameHelper.ShowVideoAd("UnlockSecretAlbums", (isSuccess) =>
{
if (isSuccess)
{
var adTimes = Convert.ToInt32(GameHelper.GetNowTime());
DataMgr.SecretUnlockCd.Value[_albumPreviewData.Index] = adTimes + _albumPreviewData.CD;
DataMgr.SecretUnlockCd.Save();
var currentAdCount = DataMgr.SecretUnlockADs.Value.GetValueOrDefault(_albumPreviewData.Index, 0);
DataMgr.SecretUnlockADs.Value[_albumPreviewData.Index] = currentAdCount + 1;
DataMgr.SecretUnlockADs.Save();
string eventName = ADEventTrack.Property.secret_albums_success_ + (_albumPreviewData.Index + 1);
TrackKit.SendEvent(ADEventTrack.AD_Event, eventName);
InitView();
}
});
}
});
ui.btn_vip.SetClick(() =>
{
TrackKit.SendEvent(ADEventTrack.SecretAlbums, ADEventTrack.Property.secret_albums_click_ + (_albumPreviewData.Index + 1));
if (GameHelper.GetVipLevel() >= 1)
{
GameHelper.isVipUnlock = true;
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, _type);
string eventName = ADEventTrack.Property.vip_secret_albums_unclock_ + (_albumPreviewData.Index + 1);
TrackKit.SendEvent(ADEventTrack.VipSecretAlbums, eventName);
}
else
{
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open, 2);
TrackKit.SendEvent(ADEventTrack.VipSecretAlbums, ADEventTrack.Property.vip_secret_albums_unclock);
}
});
}
private List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)> _tasks = new();
private void ItemRender(int index, GObject obj)
{
var item = (item_scAlbumPreview)obj;
var picture = (GLoader)item.com_pic_in.GetChild("picture");
if (!loader_list.Contains(picture))
loader_list.Add(picture);
var state = GetSafe(_albumPreviewData.State, index);
item.state.selectedIndex = is_unlock ? 0 : state;
var task = (picture, _secretData[index], (Action<NTexture>)(s =>
{
if (picture != null && !picture.isDisposed)
{
if (!is_unlock && state == 1)
TextureHelper.SetImageBlur(picture);
else
TextureHelper.CancelImageBlur(picture);
}
}), $"SecretAlbums/{_albumPreviewData.Name}/", FolderNames.SecretName);
_tasks.Add(task);
item.btn_detail.SetClick(() =>
{
if (is_unlock)
{
var data = new DetailData
{
Name = _secretData[index],
Name1 = $"SecretAlbums/{_albumPreviewData.Name}/"
};
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretDetailUI_Open, data);
}
else
{
GameHelper.ShowTips("not_unlocked", true);
}
});
if (index == _secretData.Count - 1)
{
TextureHelper.SetImgLoaders(_tasks);
}
}
private void UpWatchAdsBtn()
{
DataMgr.SecretUnlockCd.Value.TryGetValue(_albumPreviewData.Index, out var lastTimes);
if (DataMgr.SecretUnlockADs.Value.TryGetValue(_albumPreviewData.Index, out var unlockAdValue) &&
unlockAdValue >= _albumPreviewData.AD)
{
ui.btn_watch.can_buy.selectedIndex = 1;
}
else
{
ui.btn_watch.can_buy.selectedIndex = 0;
if (GameHelper.GetNowTime() < lastTimes)
{
ui.btn_watch.enabled = false;
ui.btn_watch.CD.selectedIndex = 1;
ui.btn_watch.watch_cd.text =
CommonHelper.TimeFormat(lastTimes - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
}
else
{
ui.btn_watch.enabled = true;
ui.btn_watch.CD.selectedIndex = 0;
}
}
}
// 拆分字符串为列表
public static List<string> SplitStringToList(string input)
{
if (string.IsNullOrWhiteSpace(input))
return new List<string>();
// 支持英文逗号, 中文逗号,空格
char[] separators = new char[] { ',', '', ' ' };
return input
.Split(separators, StringSplitOptions.RemoveEmptyEntries)
.Select(s => s.Trim()) // 去掉前后空白
.ToList();
}
/// <summary>
/// 安全获取列表或数组中的元素,如果越界则返回最后一个元素;如果为空则返回默认值。
/// </summary>
public static T GetSafe<T>(IList<T> list, int index, T defaultValue = default)
{
if (list == null || list.Count == 0)
return defaultValue;
if (index < 0)
return list[0];
if (index >= list.Count)
return list[list.Count - 1];
return list[index];
}
}
public class DetailData
{
public string Name;
public string Name1;
}
}
+369 -369
View File
@@ -1,370 +1,370 @@
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
using System;
using DG.Tweening;
using SGModule.NetKit;
using FGUI.ZM_store_17;
using IgnoreOPS;
namespace BallKingdomCrush
{
public class BuygoldUI : BaseUI
{
private BuygoldUICtrl ctrl;
private BuygoldModel model;
private FGUI.ZM_store_17.com_buygold ui;
private bool Isbuysuccess = false;
public BuygoldUI(BuygoldUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.BuygoldUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_store_17";
uiInfo.assetName = "com_buygold";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.BuygoldModel) as BuygoldModel;
}
protected override void OnClose()
{
AdExchangeManager.Instance.Destroy();
GameHelper.showGameUI = true;
HallManager.Instance.UpdateSecondEvent -= initList;
GameDispatcher.Instance.Dispatch(GameMsg.showBroadCast);
GameDispatcher.Instance.Dispatch(GameMsg.pack_close);
if (Isbuysuccess)
{
GameHelper.ShowTurnOffReward();
}
else
{
GameHelper.ShowPaidPack();
}
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_store_17.com_buygold;
}
protected override void OnOpenBefore(object args)
{
if (Screen.safeArea.y != 0)
{//刘海屏
ui.top_gold.y += 68;
}
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.shop_show);
ui.top_gold.GetChild("text_gold").text = GameHelper.Get101Str(GameHelper.GetGoldNumber());
if (!GameHelper.IsAdModelOfPay())
{
ui.ads.visible = false;
}
InitView();
HallManager.Instance.UpdateSecondEvent += initList;
}
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 GetAward(decimal gold, int index)
{
var item = ui.gold_list.GetChildAt(index);
var start = GameHelper.GetUICenterPosition(item);
var end = GameHelper.GetUICenterPosition(ui.top_gold.GetChild("img"));
var rewardData = new RewardData();
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
{
startPosition = start,
endPosition = new Vector2(end.x, end.y)
};
rewardData.AddReward(rewardSingleData);
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
rewardData.AddCompleted((isScu) =>
{
DOVirtual.DelayedCall(0.5f, () =>
{
var startNum = DataMgr.Coin.Value - gold;
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 0.5f,
value => { ui.top_gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); }
).OnComplete(() => {
// 动画完成时确保最终值被正确设置
ui.top_gold.GetChild("text_gold").text = GameHelper.Get101Str(DataMgr.Coin.Value);
});
});
});
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
}
void pay_success(object str)
{
string type = (string)str;
if (type.StartsWith("buy_gold"))
{
int startIndex = "buy_gold".Length;
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffix_num = int.Parse(suffix);
SaveData.GetSaveObject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
SaveData.SaveDataFunc();
GetAward(list[suffix_num].Actual_coins, suffix_num);
Isbuysuccess = true;
}
SetTextString();
}
//初始化页面逻辑
private void InitView()
{
ui.top_gold.touchable = false;
ui.btn_close.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.BuygoldUI_Close); });
initList();
}
private List<Paidcoins> list = ConfigSystem.GetConfig<Paidcoins>();
void initList()
{
ui.gold_list.itemRenderer = setRemaintime;
ui.gold_list.numItems = list.Count;
SetTextString();
}
public void SetTextString()
{
var myAds = AdExchangeManager.Instance.GetLookRewardADNum();
ui.ads.SetVar("num", myAds.ToString()).FlushVars();
}
void setRemaintime(int index, GObject obj)
{
buygold_item item = obj as buygold_item;
bool is_paid = list[index].is_paid;
int time = 0;
time = SaveData.GetSaveObject()._goldtime[index];
item.coin_text.text = GameHelper.Get101Str(list[index].Actual_coins);
item.index.selectedIndex = 1;//index > 4 ? 4 : index;
item.off_text.text = list[index].Discount_rate + "%";
item.discount.visible = !GameHelper.IsAdModelOfPay() && list[index].Discount_rate > 0;
if (list[index].Discount_rate != 0) item.off_text.text = list[index].Discount_rate + "%";
if (time + list[index].receive_CD < GameHelper.GetNowTime())
{
item.btn_buy.can_buy.selectedIndex = 0;
if (!GameHelper.IsAdModelOfPay()){
item.btn_buy.pay_type.selectedIndex = 1;
item.text_ads.visible = false;
if (!is_paid)
{
item.btn_buy.btn_text.text = "Free";
item.discount.visible = false;
item.index.selectedIndex = 0;
}
else
{
decimal price = (decimal)list[index].Payment_amount2;
item.btn_buy.btn_text.text = GameHelper.getPrice(price);
}
item.btn_buy.SetClick(() =>
{
rd_Gold(index);
});
} else {
int myAds = AdExchangeManager.Instance.GetLookRewardADNum();
int count = (int)list[index].Payment_amount;
if (is_paid)
{
item.text_ads.SetVar("num", count.ToString()).FlushVars();
}
if (myAds >= count)
{
item.btn_buy.pay_type.selectedIndex = 1;
if (!is_paid)
{
item.btn_buy.btn_text.text = Language.GetContent("free");
item.discount.visible = false;
item.index.selectedIndex = 0;
}
else
{
item.btn_buy.btn_text.text = Language.GetContent("exchange");
}
item.btn_buy.SetClick(() =>
{
rd_Gold(index);
});
}
else if (SaveData.GetSaveObject()._watch_ad_cd > GameHelper.GetNowTime())
{
item.btn_buy.can_buy.selectedIndex = 1;
item.btn_buy.pay_type.selectedIndex = 1;
item.btn_buy.btn_text.text = CommonHelper.TimeFormat(SaveData.GetSaveObject()._watch_ad_cd - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
item.btn_buy.SetClick(() => { });
}
else
{
item.btn_buy.can_buy.selectedIndex = 0;
item.btn_buy.pay_type.selectedIndex = 0;
item.btn_buy.SetClick(() =>
{
GameHelper.ShowVideoAd("BuyGold", (issuccess) =>
{
if (issuccess)
{
SaveData.GetSaveObject()._watch_ad_cd = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().exchangeCD;
SaveData.SaveDataFunc();
initList();
}
});
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.shop_click_ + index);
});
}
}
} else {
if (!is_paid)
{
item.discount.visible = false;
item.index.selectedIndex = 0;
}
if (!GameHelper.IsAdModelOfPay())
{
item.text_ads.visible = false;
}
else
{
if (is_paid)
{
int count = (int)list[index].Payment_amount;
item.text_ads.SetVar("num", count.ToString()).FlushVars();
}
}
item.btn_buy.can_buy.selectedIndex = 1;
item.btn_buy.pay_type.selectedIndex = 1;
item.btn_buy.btn_text.text = CommonHelper.TimeFormat(time + list[index].receive_CD - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
item.btn_buy.SetClick(() =>{});
}
}
private void rd_Gold(int index)
{
// string _type = "buy_gold" + index.ToString();
bool is_paid = list[index].is_paid;
if (!is_paid)
{
SaveData.GetSaveObject()._goldtime[index] = (int)GameHelper.GetNowTime();
SaveData.SaveDataFunc();
GetAward(list[index].Actual_coins, index);
InitView();
return;
}
string _type = getShopName(index);
if (GameHelper.IsAdModelOfPay())
{
AdExchangeData test = new AdExchangeData()
{
ad_count = AdExchangeManager.Instance.GetCeilingNeedAds(_type),
type = _type,
shopName = $"buy_gold{index}"
};
AdExchangeManager.Instance.Exchange(test);
}
else
{
decimal price = (decimal)list[index].Payment_amount2;
ApplePayClass maxPayData = new ApplePayClass()
{
amount = (int)Math.Round(price * 100),
sku = _type,
currency = "USD",
shopName = $"buy_gold{index}"
};
MaxPayManager.Instance.Buy(maxPayData);
}
}
public string getShopName(int index)
{
string name;
// switch(index)
// {
// case 1:
// name = PurchasingManager.buy_gold_1;
// break;
// case 2:
// name = PurchasingManager.buy_gold_2;
// break;
// case 3:
// name = PurchasingManager.buy_gold_3;
// break;
// case 4:
// name = PurchasingManager.buy_gold_4;
// break;
// case 5:
// name = PurchasingManager.buy_gold_5;
// break;
// default:
// return "";
//
// }
name = list[index].SKU;
return name;
}
}
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
using System;
using DG.Tweening;
using SGModule.NetKit;
using FGUI.ZM_store_17;
using IgnoreOPS;
namespace BallKingdomCrush
{
public class BuygoldUI : BaseUI
{
private BuygoldUICtrl ctrl;
private BuygoldModel model;
private FGUI.ZM_store_17.com_buygold ui;
private bool Isbuysuccess = false;
public BuygoldUI(BuygoldUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.BuygoldUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_store_17";
uiInfo.assetName = "com_buygold";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.BuygoldModel) as BuygoldModel;
}
protected override void OnClose()
{
AdExchangeManager.Instance.Destroy();
GameHelper.showGameUI = true;
HallManager.Instance.UpdateSecondEvent -= initList;
GameDispatcher.Instance.Dispatch(GameMsg.showBroadCast);
GameDispatcher.Instance.Dispatch(GameMsg.pack_close);
if (Isbuysuccess)
{
GameHelper.ShowTurnOffReward();
}
else
{
GameHelper.ShowPaidPack();
}
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_store_17.com_buygold;
}
protected override void OnOpenBefore(object args)
{
if (Screen.safeArea.y != 0)
{//刘海屏
ui.top_gold.y += 68;
}
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.shop_show);
ui.top_gold.GetChild("text_gold").text = GameHelper.Get101Str(GameHelper.GetGoldNumber());
if (!GameHelper.IsAdModelOfPay())
{
ui.ads.visible = false;
}
InitView();
HallManager.Instance.UpdateSecondEvent += initList;
}
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.IAP_PAY_SUCCESS, pay_success);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
#endregion
void GetAward(decimal gold, int index)
{
var item = ui.gold_list.GetChildAt(index);
var start = GameHelper.GetUICenterPosition(item);
var end = GameHelper.GetUICenterPosition(ui.top_gold.GetChild("img"));
var rewardData = new RewardData();
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
{
startPosition = start,
endPosition = new Vector2(end.x, end.y)
};
rewardData.AddReward(rewardSingleData);
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
rewardData.AddCompleted((isScu) =>
{
DOVirtual.DelayedCall(0.5f, () =>
{
var startNum = DataMgr.Coin.Value - gold;
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 0.5f,
value => { ui.top_gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); }
).OnComplete(() => {
// 动画完成时确保最终值被正确设置
ui.top_gold.GetChild("text_gold").text = GameHelper.Get101Str(DataMgr.Coin.Value);
});
});
});
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
}
void pay_success(object str)
{
string type = (string)str;
if (type.StartsWith("buy_gold"))
{
int startIndex = "buy_gold".Length;
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffix_num = int.Parse(suffix);
SaveData.GetSaveObject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
SaveData.SaveDataFunc();
GetAward(list[suffix_num].Actual_coins, suffix_num);
Isbuysuccess = true;
}
SetTextString();
}
//初始化页面逻辑
private void InitView()
{
ui.top_gold.touchable = false;
ui.btn_close.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.BuygoldUI_Close); });
initList();
}
private List<Paidcoins> list = ConfigSystem.GetConfig<Paidcoins>();
void initList()
{
ui.gold_list.itemRenderer = setRemaintime;
ui.gold_list.numItems = list.Count;
SetTextString();
}
public void SetTextString()
{
var myAds = AdExchangeManager.Instance.GetLookRewardADNum();
ui.ads.SetVar("num", myAds.ToString()).FlushVars();
}
void setRemaintime(int index, GObject obj)
{
buygold_item item = obj as buygold_item;
bool is_paid = list[index].is_paid;
int time = 0;
time = SaveData.GetSaveObject()._goldtime[index];
item.coin_text.text = GameHelper.Get101Str(list[index].Actual_coins);
item.index.selectedIndex = 1;//index > 4 ? 4 : index;
item.off_text.text = list[index].Discount_rate + "%";
item.discount.visible = !GameHelper.IsAdModelOfPay() && list[index].Discount_rate > 0;
if (list[index].Discount_rate != 0) item.off_text.text = list[index].Discount_rate + "%";
if (time + list[index].receive_CD < GameHelper.GetNowTime())
{
item.btn_buy.can_buy.selectedIndex = 0;
if (!GameHelper.IsAdModelOfPay()){
item.btn_buy.pay_type.selectedIndex = 1;
item.text_ads.visible = false;
if (!is_paid)
{
item.btn_buy.btn_text.text = "Free";
item.discount.visible = false;
item.index.selectedIndex = 0;
}
else
{
decimal price = (decimal)list[index].Payment_amount2;
item.btn_buy.btn_text.text = GameHelper.getPrice(price);
}
item.btn_buy.SetClick(() =>
{
rd_Gold(index);
});
} else {
int myAds = AdExchangeManager.Instance.GetLookRewardADNum();
int count = (int)list[index].Payment_amount;
if (is_paid)
{
item.text_ads.SetVar("num", count.ToString()).FlushVars();
}
if (myAds >= count)
{
item.btn_buy.pay_type.selectedIndex = 1;
if (!is_paid)
{
item.btn_buy.btn_text.text = Language.GetContent("free");
item.discount.visible = false;
item.index.selectedIndex = 0;
}
else
{
item.btn_buy.btn_text.text = Language.GetContent("exchange");
}
item.btn_buy.SetClick(() =>
{
rd_Gold(index);
});
}
else if (SaveData.GetSaveObject()._watch_ad_cd > GameHelper.GetNowTime())
{
item.btn_buy.can_buy.selectedIndex = 1;
item.btn_buy.pay_type.selectedIndex = 1;
item.btn_buy.btn_text.text = CommonHelper.TimeFormat(SaveData.GetSaveObject()._watch_ad_cd - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
item.btn_buy.SetClick(() => { });
}
else
{
item.btn_buy.can_buy.selectedIndex = 0;
item.btn_buy.pay_type.selectedIndex = 0;
item.btn_buy.SetClick(() =>
{
GameHelper.ShowVideoAd("BuyGold", (issuccess) =>
{
if (issuccess)
{
SaveData.GetSaveObject()._watch_ad_cd = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().exchangeCD;
SaveData.SaveDataFunc();
initList();
}
});
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.shop_click_ + index);
});
}
}
} else {
if (!is_paid)
{
item.discount.visible = false;
item.index.selectedIndex = 0;
}
if (!GameHelper.IsAdModelOfPay())
{
item.text_ads.visible = false;
}
else
{
if (is_paid)
{
int count = (int)list[index].Payment_amount;
item.text_ads.SetVar("num", count.ToString()).FlushVars();
}
}
item.btn_buy.can_buy.selectedIndex = 1;
item.btn_buy.pay_type.selectedIndex = 1;
item.btn_buy.btn_text.text = CommonHelper.TimeFormat(time + list[index].receive_CD - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
item.btn_buy.SetClick(() =>{});
}
}
private void rd_Gold(int index)
{
// string _type = "buy_gold" + index.ToString();
bool is_paid = list[index].is_paid;
if (!is_paid)
{
SaveData.GetSaveObject()._goldtime[index] = (int)GameHelper.GetNowTime();
SaveData.SaveDataFunc();
GetAward(list[index].Actual_coins, index);
InitView();
return;
}
string _type = getShopName(index);
if (GameHelper.IsAdModelOfPay())
{
AdExchangeData test = new AdExchangeData()
{
ad_count = AdExchangeManager.Instance.GetCeilingNeedAds(_type),
type = _type,
shopName = $"buy_gold{index}"
};
AdExchangeManager.Instance.Exchange(test);
}
else
{
decimal price = (decimal)list[index].Payment_amount2;
ApplePayClass maxPayData = new ApplePayClass()
{
amount = (int)Math.Round(price * 100),
sku = _type,
currency = "USD",
shopName = $"buy_gold{index}"
};
MaxPayManager.Instance.Buy(maxPayData);
}
}
public string getShopName(int index)
{
string name;
// switch(index)
// {
// case 1:
// name = PurchasingManager.buy_gold_1;
// break;
// case 2:
// name = PurchasingManager.buy_gold_2;
// break;
// case 3:
// name = PurchasingManager.buy_gold_3;
// break;
// case 4:
// name = PurchasingManager.buy_gold_4;
// break;
// case 5:
// name = PurchasingManager.buy_gold_5;
// break;
// default:
// return "";
//
// }
name = list[index].SKU;
return name;
}
}
}
+144 -144
View File
@@ -1,145 +1,145 @@
using FGUI.ZM_Common_01;
using UnityEngine;
using FairyGUI;
using SGModule.NetKit;
using Spine.Unity;
using System;
namespace BallKingdomCrush
{
public class SubUnlockUI : BaseUI
{
private SubUnlockUICtrl ctrl;
private SubUnlockModel model;
private FGUI.LG_Unlock.com_SubUnlock ui;
public SubUnlockUI(SubUnlockUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.SubUnlockUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "LG_Unlock";
uiInfo.assetName = "com_SubUnlock";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.SubUnlockModel) as SubUnlockModel;
}
protected override void OnClose()
{
closeCallback?.Invoke();
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_Unlock.com_SubUnlock;
}
protected override void OnOpenBefore(object args)
{
InitView();
TrackKit.SendEvent(ADEventTrack.Subscription, ADEventTrack.Property.vip_show_sell);
}
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.BuyVip, refrsh);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, refrsh);
}
#endregion
private void refrsh(object a = null)
{
GameHelper.ShowTips("unlock_vip", true);
CtrlCloseUI();
}
private Action closeCallback;
//初始化页面逻辑
private void InitView()
{
ui.btn_close.SetClick(() =>
{
CtrlCloseUI();
});
SkeletonAnimation ske_pot = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_parent, Fx_Type.fx_chatphone, ref closeCallback);
ske_pot.state.SetAnimation(0, "animation", true);
var vip_list = ConfigSystem.GetConfig<VipClub>();
ui.text_unlockLive.SetVar("num", GameHelper.GetCommonModel().UnlockLive[1].ToString()).FlushVars();
ui.text_unlockAlbum.SetVar("num", GameHelper.GetCommonModel().UnlockSecret[1].ToString()).FlushVars();
ui.btn_vip0.text_price.text = GameHelper.getPrice((decimal)vip_list[0].DiscountPrice);
ui.btn_vip1.text_price.text = GameHelper.getPrice((decimal)vip_list[1].DiscountPrice);
ui.btn_vip2.text_price.text = GameHelper.getPrice((decimal)vip_list[2].DiscountPrice);
ui.btn_vip0.SetClick(() =>
{
string _type = "vip_club" + 0;
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)System.Math.Round(vip_list[0].DiscountPrice * 100),
sku = PurchasingManager.GetPaySku(PayType.weekly_subscription),
currency = "USD",
shopName = _type
};
MaxPayManager.Instance.Buy(maxPayData);
});
ui.btn_vip1.SetClick(() =>
{
string _type = "vip_club" + 1;
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)System.Math.Round(vip_list[1].DiscountPrice * 100),
sku = PurchasingManager.GetPaySku(PayType.monthly_subscription),
currency = "USD",
shopName = _type
};
MaxPayManager.Instance.Buy(maxPayData);
});
ui.btn_vip2.SetClick(() =>
{
string _type = "vip_club" + 2;
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)System.Math.Round(vip_list[2].DiscountPrice * 100),
sku = PurchasingManager.GetPaySku(PayType.yearly_subscription),
currency = "USD",
shopName = _type
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
}
using FGUI.ZM_Common_01;
using UnityEngine;
using FairyGUI;
using SGModule.NetKit;
using Spine.Unity;
using System;
namespace BallKingdomCrush
{
public class SubUnlockUI : BaseUI
{
private SubUnlockUICtrl ctrl;
private SubUnlockModel model;
private FGUI.LG_Unlock.com_SubUnlock ui;
public SubUnlockUI(SubUnlockUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.SubUnlockUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "LG_Unlock";
uiInfo.assetName = "com_SubUnlock";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.SubUnlockModel) as SubUnlockModel;
}
protected override void OnClose()
{
closeCallback?.Invoke();
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_Unlock.com_SubUnlock;
}
protected override void OnOpenBefore(object args)
{
InitView();
TrackKit.SendEvent(ADEventTrack.Subscription, ADEventTrack.Property.vip_show_sell);
}
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.BuyVip, refrsh);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, refrsh);
}
#endregion
private void refrsh(object a = null)
{
GameHelper.ShowTips("unlock_vip", true);
CtrlCloseUI();
}
private Action closeCallback;
//初始化页面逻辑
private void InitView()
{
ui.btn_close.SetClick(() =>
{
CtrlCloseUI();
});
SkeletonAnimation ske_pot = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_parent, Fx_Type.fx_chatphone, ref closeCallback);
ske_pot.state.SetAnimation(0, "animation", true);
var vip_list = ConfigSystem.GetConfig<VipClub>();
ui.text_unlockLive.SetVar("num", GameHelper.GetCommonModel().UnlockLive[1].ToString()).FlushVars();
ui.text_unlockAlbum.SetVar("num", GameHelper.GetCommonModel().UnlockSecret[1].ToString()).FlushVars();
ui.btn_vip0.text_price.text = GameHelper.getPrice((decimal)vip_list[0].DiscountPrice);
ui.btn_vip1.text_price.text = GameHelper.getPrice((decimal)vip_list[1].DiscountPrice);
ui.btn_vip2.text_price.text = GameHelper.getPrice((decimal)vip_list[2].DiscountPrice);
ui.btn_vip0.SetClick(() =>
{
string _type = "vip_club" + 0;
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)System.Math.Round(vip_list[0].DiscountPrice * 100),
sku = IAPPayManager.PRODUCT_VIP_WEEK,
currency = "USD",
shopName = _type
};
MaxPayManager.Instance.Buy(maxPayData);
});
ui.btn_vip1.SetClick(() =>
{
string _type = "vip_club" + 1;
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)System.Math.Round(vip_list[1].DiscountPrice * 100),
sku = IAPPayManager.PRODUCT_VIP_MONTH,
currency = "USD",
shopName = _type
};
MaxPayManager.Instance.Buy(maxPayData);
});
ui.btn_vip2.SetClick(() =>
{
string _type = "vip_club" + 2;
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)System.Math.Round(vip_list[2].DiscountPrice * 100),
sku = IAPPayManager.PRODUCT_VIP_YEAR,
currency = "USD",
shopName = _type
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
}
}
File diff suppressed because it is too large Load Diff
@@ -1,500 +1,500 @@
using System.Collections.Generic;
using FGUI.ZM_Common_01;
using UnityEngine;
using FairyGUI;
using FGUI.LG_Vip;
using SGModule.Common.Helper;
using SGModule.NetKit;
using SGModule.MarkdownKit;
using Newtonsoft.Json;
using SGModule.Net;
public enum VipDay
{
Week = 7,
Month = 30,
Year = 365
}
namespace BallKingdomCrush
{
public class VipClubViewUI : BaseUI
{
private VipClubViewUICtrl ctrl;
private VipClubViewModel model;
private FGUI.LG_Vip.com_vip ui;
public VipClubViewUI(VipClubViewUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.VipClubViewUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "LG_Vip";
uiInfo.assetName = "com_vip";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.VipClubViewModel) as VipClubViewModel;
}
protected override void OnClose()
{
if (_loader != null && !_loader.isDisposed && _loader.texture != null)
{
_loader.texture = null;
}
_loader = null;
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_Vip.com_vip;
}
private List<VipClub> vip_list = new List<VipClub>();
//这个要做下标,或者控制器的索引,所以从0开始(Vip是1,2,3)
private int _level = 2;
private GLoader _loader = new GLoader();
protected override void OnOpenBefore(object args)
{
_loader = ui.bg_loader;
setList();
if (GameHelper.IsGiftSwitch())
{
var fileName = GameHelper.GetBackgroundName(des_key.VIP.ToString());
TextureHelper.SetImgLoader(ui.bg_loader, fileName, null, "Background/", FolderNames.BackgroundName);
}
TrackKit.SendEvent(ADEventTrack.Subscription, ADEventTrack.Property.vip_show_page);
// 检查VIP是否过期
GameHelper.CheckVipExpiration();
_level = GameHelper.GetVipLevel() > 0 ? GameHelper.GetVipLevel() - 1 : 2;
if (args != null) _level = (int)args;
vip_list = ConfigSystem.GetConfig<VipClub>();
InitView();
// ui.text_terms.text=
// Debug.Log(MarkdownDataMgr.TryGetValue("user", out MarkdownData data));
// Debug.Log(JsonConvert.SerializeObject(data));
ui.btn_terns.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 1);
});
ui.btn_pri.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 0);
});
if (GameHelper.IsGiftSwitch())
{
int random_ = Random.Range(0, 100);
bool need_open = false;
if (random_ < GameHelper.GetCommonModel().VIPGuideRate)
{
if (GameHelper.GetVipLevel() > 0 && GameHelper.GetLevel() >= GameHelper.GetCommonModel().VIPGuide)
{
// List<int> unlocklist = new List<int>();
if ((GameHelper.GetCommonModel().Live == 1) &&
(GameHelper.GetLevel() >= GameHelper.GetCommonModel().LivePreview) &&
(GameHelper.GetLevel() < GameHelper.GetCommonModel().UnlockLive[1]))
{
// if (DataMgr.IsUnlockLive.Value < 0) //未解锁。
// {
// unlocklist.Add(0);
need_open = true;
// }
}
if ((GameHelper.GetCommonModel().Secret == 1) &&
(GameHelper.GetLevel() >= GameHelper.GetCommonModel().SecretPreview) &&
(GameHelper.GetLevel() < GameHelper.GetCommonModel().UnlockSecret[1]))
{
// if (DataMgr.IsUnlockSecret.Value < 0) //未解锁。
// {
// unlocklist.Add(1);
need_open = true;
// }
}
// if ((GameHelper.GetCommonModel().Assitant == 1) &&
// (GameHelper.GetLevel() >= GameHelper.GetCommonModel().AssitantPreview))
// {
// // if (DataMgr.IsUnlockSecret.Value < 0) //未解锁。
// // {
// // unlocklist.Add(1);
// need_open = true;
// // }
// }
}
if (need_open) uiCtrlDispatcher.Dispatch(UICtrlMsg.SubUnlockUI_Open);
else if (GameHelper.GetVipLevel() < 0 && GameHelper.GetLevel() >= GameHelper.GetCommonModel().VIPGuide)
{
uiCtrlDispatcher.Dispatch(UICtrlMsg.SubUnlockUI_Open);
}
}
}
}
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;
string purch_number = "";
if (type.StartsWith("vip_club"))
{
InitView();
}
}
//初始化页面逻辑
private void InitView()
{
ui.btn_week.text_price.text = GameHelper.getPrice((decimal)vip_list[0].DiscountPrice);
ui.btn_month.text_price.text = GameHelper.getPrice((decimal)vip_list[1].DiscountPrice);
ui.btn_year.text_price.text = GameHelper.getPrice((decimal)vip_list[2].DiscountPrice);
ui.btn_week.text_price_old.text = GameHelper.getPrice((decimal)vip_list[0].Price);
ui.btn_month.text_price_old.text = GameHelper.getPrice((decimal)vip_list[1].Price);
ui.btn_year.text_price_old.text = GameHelper.getPrice((decimal)vip_list[2].Price);
ui.btn_close.SetClick(CtrlCloseUI);
// ui.btn_restore.visible = !GameHelper.IsGiftSwitch();
// ui.btn_restore.SetClick(() =>
// {
// ApplePayManager.Instance.AppleRestore((success, message) =>
// {
// Debug.Log($"[barry] restore success message: {message}---- {JsonConvert.SerializeObject(message)}");
// if (success)
// {
// Debug.Log("[barry] restore success: " + success);
// GameHelper.ShowTips("Restore Purchases Success!");
// SaveData.GetSaveObject().have_slot = success;
// DataMgr.VipLevel.Value = 3;
// DataMgr.VipExpirationTime.Value = ServerClock.GetCurrentServerTime() + 7 * 24 * 60 * 60;
//
// InitView();
// }
// else
// {
// GameHelper.ShowTips("There are no recoverable transactions");
// }
// });
// });
SetSubBtnState(_level, (int)VipDay.Year);
ui.btn_week.SetClick(() => { SetSubBtnState(0, (int)VipDay.Week); });
ui.btn_month.SetClick(() => { SetSubBtnState(1, (int)VipDay.Month); });
ui.btn_year.SetClick(() => { SetSubBtnState(2, (int)VipDay.Year); });
ui.btn_sub.SetClick(() =>
{
if (ui.btn_sub.is_buy.selectedIndex == 1) return;
string _type = "vip_club" + _level;
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)System.Math.Round(vip_list[_level].DiscountPrice * 100),
sku = PurchasingManager.GetPaySku(GetTypeByIndex(_level)),
currency = "USD",
shopName = _type
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
private PayType GetTypeByIndex(int index)
{
return index switch
{
0 => PayType.weekly_subscription,
1 => PayType.monthly_subscription,
2 => PayType.yearly_subscription,
_ => PayType.weekly_subscription
};
}
private void SetSubBtnState(int index, int day)
{
Debug.Log($"lvele============{index}");
_level = index;
ui.btn_sub.title = Language.GetContentParams("vip_buy", new[] {GameHelper.getPrice((decimal)vip_list[index].DiscountPrice), day.ToString()});
ui.btn_week.img_select.visible = index == 0;
ui.btn_month.img_select.visible = index == 1;
ui.btn_year.img_select.visible = index == 2;
ui.list.itemRenderer = ItemRenderer;
if (GameHelper.IsGiftSwitch())
{
ui.list.numItems = _vipEquity.Count;
}
else
{
ui.list.numItems = _vipEquity1.Count;
}
//vip等级(1:7天 2:30天 3:365天)
var selectIndex = 0;
if (_level <= GameHelper.GetVipLevel() - 1) //比如:如果订阅了30天,则30天和7天的订阅按钮隐藏,显示已订阅
{
selectIndex = 1;
}
ui.btn_sub.is_buy.selectedIndex = selectIndex;
}
private void ItemRenderer(int index, GObject obj)
{
var item = (item_viplist)obj;
if (GameHelper.IsGiftSwitch())
{
item.title.text = _vipEquity[index];
var state = 0;
if (_level == 0)
{
state = index > 1 ? 0 : 1;
}
else if (_level == 1)
{
state = index > 0 ? 0 : 1;
}
item.have.selectedIndex = state;
}
else
{
item.title.text = _vipEquity1[index];
}
}
private void setList()
{
var lang = PlayerPrefsKit.ReadString("LangIdKey");
if (lang.IsNullOrWhiteSpace())
{
lang = "en";
}
if (lang == "en")
{
_vipEquity = new List<string>{
"Free access to VIP levels",
"Free access to Special levels",
"Double Chest Coins Reward",
"Image downloads ad-Free",
"Double level rewards",
"Remove the interstitial ads",
"Unlock the Secret Album and Enjoy some resources",
"Unlock the live and Enjoy some resources"
};
_vipEquity1 = new List<string>
{
"Double chest rewards",
"Double level rewards",
"Remove interstitial ads",
"Remove banner ads",
};
}
else if (lang == "fr")
{
_vipEquity = new List<string>{
"Accès gratuit aux niveaux VIP",
"Accès gratuit aux niveaux Spéciaux",
"Récompenses double de pièces du coffre",
"Téléchargements d'images sans publicité",
"Récompenses double des niveaux",
"Supprimer les publicités interstitielles",
"Déverrouiller l'album secret et profiter de ressources exclusives",
"Déverrouiller le direct et profiter de ressources exclusives",
};
_vipEquity1 = new List<string>
{
"Récompenses double du coffre",
"Récompenses double des niveaux",
"Supprimer les publicités interstitielles",
"Supprimer les bannières publicitaires",
};
}
else if (lang == "de")
{
_vipEquity = new List<string>{
"Kostenlosen Zugang zu VIP-Leveln",
"Kostenlosen Zugang zu Spezial-Leveln",
"Doppelte Schatzkisten-Münzenbelohnungen",
"Werbefreie Bilddownloads",
"Doppelte Levelbelohnungen",
"Zwischenanzeigen entfernen",
"Das geheime Album freischalten und exklusive Ressourcen genießen",
"Den Livestream freischalten und exklusive Ressourcen genießen",
};
_vipEquity1 = new List<string>
{
"Doppelte Schatzkistenbelohnungen",
"Doppelte Levelbelohnungen",
"Zwischenanzeigen entfernen",
"Banneranzeigen entfernen",
};
}
else if (lang == "es")
{
_vipEquity = new List<string>{
"Acceso gratuito a los niveles VIP",
"Acceso gratuito a los niveles Especiales",
"Recompensas dobles de monedas del cofre",
"Descargas de imágenes sin anuncios",
"Recompensas dobles de niveles",
"Eliminar los anuncios intersticiales",
"Desbloquear el álbum secreto y disfrutar de recursos exclusivos",
"Desbloquear la transmisión en directo y disfrutar de recursos exclusivos",
};
_vipEquity1 = new List<string>
{
"Recompensas dobles del cofre",
"Recompensas dobles de niveles",
"Eliminar los anuncios intersticiales",
"Eliminar los banners publicitarios",
};
}
else if (lang == "pt")
{
_vipEquity = new List<string>{
"Acesso gratuito aos níveis VIP",
"Acesso gratuito aos níveis Especiais",
"Recompensas em moedas do baú em dobro",
"Baixar imagens sem anúncios",
"Recompensas de nível em dobro",
"Remover anúncios intersticiais",
"Desbloquear o álbum secreto e aproveitar recursos exclusivos",
"Desbloquear a transmissão ao vivo e aproveitar recursos exclusivos",
};
_vipEquity1 = new List<string>
{
"Recompensas do baú em dobro",
"Recompensas de nível em dobro",
"Remover anúncios intersticiais",
"Remover banners publicitários",
};
}
else if (lang == "ja")
{
_vipEquity = new List<string>{
"VIP レベルへの無料アクセス",
"スペシャルレベルへの無料アクセス",
"チェストコインのダブル報酬",
"広告なしの画像ダウンロード",
"レベル報酬のダブル",
"インタースティシャル広告を削除",
"シークレットアルバムをアンロックし、専用リソースを享受",
"ライブ配信をアンロックし、専用リ소스を享受",
};
_vipEquity1 = new List<string>
{
"チェスト報酬のダブル",
"レベル報酬のダブル",
"インタースティシャル広告を削除",
"バナー広告を削除",
};
}
else if (lang == "ko")
{
_vipEquity = new List<string>{
"VIP 레벨 무료 접근",
"스페셜 레벨 무료 접근",
"상자 동전 더블 보상",
"광고 없는 이미지 다운로드",
"레벨 보상 더블",
"인터스티셜 광고 제거",
"비밀 앨범을 잠금 해제하고 전용 리소스 즐기기",
"라이브 스트림을 잠금 해제하고 전용 리소스 즐기기",
};
_vipEquity1 = new List<string>
{
"상자 보상 더블",
"레벨 보상 더블",
"인터스티셜 광고 제거",
"배너 광고 제거",
};
}
else if (lang == "ru")
{
_vipEquity = new List<string>{
"Бесплатный доступ к VIP-уровням",
"Бесплатный доступ к специальным уровням",
"Двойные награды монет из сундука",
"Скачивание изображений без рекламы",
"Двойные награды уровней",
"Удалить межстраничную рекламу",
"Разблокировать секретный альбом и наслаждаться эксклюзивными ресурсами",
"Разблокировать прямой эфир и наслаждаться эксклюзивными ресурсами",
};
_vipEquity1 = new List<string>
{
"Двойные награды из сундука",
"Двойные награды уровней",
"Удалить межстраничную рекламу",
"Удалить баннерную рекламу",
};
}
}
//Vip权益内容列表
private List<string> _vipEquity;
private List<string> _vipEquity1;
}
using System.Collections.Generic;
using FGUI.ZM_Common_01;
using UnityEngine;
using FairyGUI;
using FGUI.LG_Vip;
using SGModule.Common.Helper;
using SGModule.NetKit;
using SGModule.MarkdownKit;
using Newtonsoft.Json;
using SGModule.Net;
public enum VipDay
{
Week = 7,
Month = 30,
Year = 365
}
namespace BallKingdomCrush
{
public class VipClubViewUI : BaseUI
{
private VipClubViewUICtrl ctrl;
private VipClubViewModel model;
private FGUI.LG_Vip.com_vip ui;
public VipClubViewUI(VipClubViewUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.VipClubViewUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "LG_Vip";
uiInfo.assetName = "com_vip";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.VipClubViewModel) as VipClubViewModel;
}
protected override void OnClose()
{
if (_loader != null && !_loader.isDisposed && _loader.texture != null)
{
_loader.texture = null;
}
_loader = null;
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_Vip.com_vip;
}
private List<VipClub> vip_list = new List<VipClub>();
//这个要做下标,或者控制器的索引,所以从0开始(Vip是1,2,3)
private int _level = 2;
private GLoader _loader = new GLoader();
protected override void OnOpenBefore(object args)
{
_loader = ui.bg_loader;
setList();
if (GameHelper.IsGiftSwitch())
{
var fileName = GameHelper.GetBackgroundName(des_key.VIP.ToString());
TextureHelper.SetImgLoader(ui.bg_loader, fileName, null, "Background/", FolderNames.BackgroundName);
}
TrackKit.SendEvent(ADEventTrack.Subscription, ADEventTrack.Property.vip_show_page);
// 检查VIP是否过期
GameHelper.CheckVipExpiration();
_level = GameHelper.GetVipLevel() > 0 ? GameHelper.GetVipLevel() - 1 : 2;
if (args != null) _level = (int)args;
vip_list = ConfigSystem.GetConfig<VipClub>();
InitView();
// ui.text_terms.text=
// Debug.Log(MarkdownDataMgr.TryGetValue("user", out MarkdownData data));
// Debug.Log(JsonConvert.SerializeObject(data));
ui.btn_terns.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 1);
});
ui.btn_pri.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 0);
});
if (GameHelper.IsGiftSwitch())
{
int random_ = Random.Range(0, 100);
bool need_open = false;
if (random_ < GameHelper.GetCommonModel().VIPGuideRate)
{
if (GameHelper.GetVipLevel() > 0 && GameHelper.GetLevel() >= GameHelper.GetCommonModel().VIPGuide)
{
// List<int> unlocklist = new List<int>();
if ((GameHelper.GetCommonModel().Live == 1) &&
(GameHelper.GetLevel() >= GameHelper.GetCommonModel().LivePreview) &&
(GameHelper.GetLevel() < GameHelper.GetCommonModel().UnlockLive[1]))
{
// if (DataMgr.IsUnlockLive.Value < 0) //未解锁。
// {
// unlocklist.Add(0);
need_open = true;
// }
}
if ((GameHelper.GetCommonModel().Secret == 1) &&
(GameHelper.GetLevel() >= GameHelper.GetCommonModel().SecretPreview) &&
(GameHelper.GetLevel() < GameHelper.GetCommonModel().UnlockSecret[1]))
{
// if (DataMgr.IsUnlockSecret.Value < 0) //未解锁。
// {
// unlocklist.Add(1);
need_open = true;
// }
}
// if ((GameHelper.GetCommonModel().Assitant == 1) &&
// (GameHelper.GetLevel() >= GameHelper.GetCommonModel().AssitantPreview))
// {
// // if (DataMgr.IsUnlockSecret.Value < 0) //未解锁。
// // {
// // unlocklist.Add(1);
// need_open = true;
// // }
// }
}
if (need_open) uiCtrlDispatcher.Dispatch(UICtrlMsg.SubUnlockUI_Open);
else if (GameHelper.GetVipLevel() < 0 && GameHelper.GetLevel() >= GameHelper.GetCommonModel().VIPGuide)
{
uiCtrlDispatcher.Dispatch(UICtrlMsg.SubUnlockUI_Open);
}
}
}
}
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.IAP_PAY_SUCCESS, pay_success);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
string purch_number = "";
if (PurchasingManager._vipProductMap.ContainsKey(type))
{
InitView();
}
}
//初始化页面逻辑
private void InitView()
{
ui.btn_week.text_price.text = GameHelper.getPrice((decimal)vip_list[0].DiscountPrice);
ui.btn_month.text_price.text = GameHelper.getPrice((decimal)vip_list[1].DiscountPrice);
ui.btn_year.text_price.text = GameHelper.getPrice((decimal)vip_list[2].DiscountPrice);
ui.btn_week.text_price_old.text = GameHelper.getPrice((decimal)vip_list[0].Price);
ui.btn_month.text_price_old.text = GameHelper.getPrice((decimal)vip_list[1].Price);
ui.btn_year.text_price_old.text = GameHelper.getPrice((decimal)vip_list[2].Price);
ui.btn_close.SetClick(CtrlCloseUI);
// ui.btn_restore.visible = !GameHelper.IsGiftSwitch();
// ui.btn_restore.SetClick(() =>
// {
// ApplePayManager.Instance.AppleRestore((success, message) =>
// {
// Debug.Log($"[barry] restore success message: {message}---- {JsonConvert.SerializeObject(message)}");
// if (success)
// {
// Debug.Log("[barry] restore success: " + success);
// GameHelper.ShowTips("Restore Purchases Success!");
// SaveData.GetSaveObject().have_slot = success;
// DataMgr.VipLevel.Value = 3;
// DataMgr.VipExpirationTime.Value = ServerClock.GetCurrentServerTime() + 7 * 24 * 60 * 60;
//
// InitView();
// }
// else
// {
// GameHelper.ShowTips("There are no recoverable transactions");
// }
// });
// });
SetSubBtnState(_level, (int)VipDay.Year);
ui.btn_week.SetClick(() => { SetSubBtnState(0, (int)VipDay.Week); });
ui.btn_month.SetClick(() => { SetSubBtnState(1, (int)VipDay.Month); });
ui.btn_year.SetClick(() => { SetSubBtnState(2, (int)VipDay.Year); });
ui.btn_sub.SetClick(() =>
{
if (ui.btn_sub.is_buy.selectedIndex == 1) return;
string _type = "vip_club" + _level;
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)System.Math.Round(vip_list[_level].DiscountPrice * 100),
sku = GetTypeByIndex(_level),
currency = "USD",
shopName = _type
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
private string GetTypeByIndex(int index)
{
return index switch
{
0 => IAPPayManager.PRODUCT_VIP_WEEK,
1 => IAPPayManager.PRODUCT_VIP_MONTH,
2 => IAPPayManager.PRODUCT_VIP_YEAR,
_ => IAPPayManager.PRODUCT_VIP_WEEK
};
}
private void SetSubBtnState(int index, int day)
{
Debug.Log($"lvele============{index}");
_level = index;
ui.btn_sub.title = Language.GetContentParams("vip_buy", new[] {GameHelper.getPrice((decimal)vip_list[index].DiscountPrice), day.ToString()});
ui.btn_week.img_select.visible = index == 0;
ui.btn_month.img_select.visible = index == 1;
ui.btn_year.img_select.visible = index == 2;
ui.list.itemRenderer = ItemRenderer;
if (GameHelper.IsGiftSwitch())
{
ui.list.numItems = _vipEquity.Count;
}
else
{
ui.list.numItems = _vipEquity1.Count;
}
//vip等级(1:7天 2:30天 3:365天)
var selectIndex = 0;
if (_level <= GameHelper.GetVipLevel() - 1) //比如:如果订阅了30天,则30天和7天的订阅按钮隐藏,显示已订阅
{
selectIndex = 1;
}
ui.btn_sub.is_buy.selectedIndex = selectIndex;
}
private void ItemRenderer(int index, GObject obj)
{
var item = (item_viplist)obj;
if (GameHelper.IsGiftSwitch())
{
item.title.text = _vipEquity[index];
var state = 0;
if (_level == 0)
{
state = index > 1 ? 0 : 1;
}
else if (_level == 1)
{
state = index > 0 ? 0 : 1;
}
item.have.selectedIndex = state;
}
else
{
item.title.text = _vipEquity1[index];
}
}
private void setList()
{
var lang = PlayerPrefsKit.ReadString("LangIdKey");
if (lang.IsNullOrWhiteSpace())
{
lang = "en";
}
if (lang == "en")
{
_vipEquity = new List<string>{
"Free access to VIP levels",
"Free access to Special levels",
"Double Chest Coins Reward",
"Image downloads ad-Free",
"Double level rewards",
"Remove the interstitial ads",
"Unlock the Secret Album and Enjoy some resources",
"Unlock the live and Enjoy some resources"
};
_vipEquity1 = new List<string>
{
"Double chest rewards",
"Double level rewards",
"Remove interstitial ads",
"Remove banner ads",
};
}
else if (lang == "fr")
{
_vipEquity = new List<string>{
"Accès gratuit aux niveaux VIP",
"Accès gratuit aux niveaux Spéciaux",
"Récompenses double de pièces du coffre",
"Téléchargements d'images sans publicité",
"Récompenses double des niveaux",
"Supprimer les publicités interstitielles",
"Déverrouiller l'album secret et profiter de ressources exclusives",
"Déverrouiller le direct et profiter de ressources exclusives",
};
_vipEquity1 = new List<string>
{
"Récompenses double du coffre",
"Récompenses double des niveaux",
"Supprimer les publicités interstitielles",
"Supprimer les bannières publicitaires",
};
}
else if (lang == "de")
{
_vipEquity = new List<string>{
"Kostenlosen Zugang zu VIP-Leveln",
"Kostenlosen Zugang zu Spezial-Leveln",
"Doppelte Schatzkisten-Münzenbelohnungen",
"Werbefreie Bilddownloads",
"Doppelte Levelbelohnungen",
"Zwischenanzeigen entfernen",
"Das geheime Album freischalten und exklusive Ressourcen genießen",
"Den Livestream freischalten und exklusive Ressourcen genießen",
};
_vipEquity1 = new List<string>
{
"Doppelte Schatzkistenbelohnungen",
"Doppelte Levelbelohnungen",
"Zwischenanzeigen entfernen",
"Banneranzeigen entfernen",
};
}
else if (lang == "es")
{
_vipEquity = new List<string>{
"Acceso gratuito a los niveles VIP",
"Acceso gratuito a los niveles Especiales",
"Recompensas dobles de monedas del cofre",
"Descargas de imágenes sin anuncios",
"Recompensas dobles de niveles",
"Eliminar los anuncios intersticiales",
"Desbloquear el álbum secreto y disfrutar de recursos exclusivos",
"Desbloquear la transmisión en directo y disfrutar de recursos exclusivos",
};
_vipEquity1 = new List<string>
{
"Recompensas dobles del cofre",
"Recompensas dobles de niveles",
"Eliminar los anuncios intersticiales",
"Eliminar los banners publicitarios",
};
}
else if (lang == "pt")
{
_vipEquity = new List<string>{
"Acesso gratuito aos níveis VIP",
"Acesso gratuito aos níveis Especiais",
"Recompensas em moedas do baú em dobro",
"Baixar imagens sem anúncios",
"Recompensas de nível em dobro",
"Remover anúncios intersticiais",
"Desbloquear o álbum secreto e aproveitar recursos exclusivos",
"Desbloquear a transmissão ao vivo e aproveitar recursos exclusivos",
};
_vipEquity1 = new List<string>
{
"Recompensas do baú em dobro",
"Recompensas de nível em dobro",
"Remover anúncios intersticiais",
"Remover banners publicitários",
};
}
else if (lang == "ja")
{
_vipEquity = new List<string>{
"VIP レベルへの無料アクセス",
"スペシャルレベルへの無料アクセス",
"チェストコインのダブル報酬",
"広告なしの画像ダウンロード",
"レベル報酬のダブル",
"インタースティシャル広告を削除",
"シークレットアルバムをアンロックし、専用リソースを享受",
"ライブ配信をアンロックし、専用リ소스を享受",
};
_vipEquity1 = new List<string>
{
"チェスト報酬のダブル",
"レベル報酬のダブル",
"インタースティシャル広告を削除",
"バナー広告を削除",
};
}
else if (lang == "ko")
{
_vipEquity = new List<string>{
"VIP 레벨 무료 접근",
"스페셜 레벨 무료 접근",
"상자 동전 더블 보상",
"광고 없는 이미지 다운로드",
"레벨 보상 더블",
"인터스티셜 광고 제거",
"비밀 앨범을 잠금 해제하고 전용 리소스 즐기기",
"라이브 스트림을 잠금 해제하고 전용 리소스 즐기기",
};
_vipEquity1 = new List<string>
{
"상자 보상 더블",
"레벨 보상 더블",
"인터스티셜 광고 제거",
"배너 광고 제거",
};
}
else if (lang == "ru")
{
_vipEquity = new List<string>{
"Бесплатный доступ к VIP-уровням",
"Бесплатный доступ к специальным уровням",
"Двойные награды монет из сундука",
"Скачивание изображений без рекламы",
"Двойные награды уровней",
"Удалить межстраничную рекламу",
"Разблокировать секретный альбом и наслаждаться эксклюзивными ресурсами",
"Разблокировать прямой эфир и наслаждаться эксклюзивными ресурсами",
};
_vipEquity1 = new List<string>
{
"Двойные награды из сундука",
"Двойные награды уровней",
"Удалить межстраничную рекламу",
"Удалить баннерную рекламу",
};
}
}
//Vip权益内容列表
private List<string> _vipEquity;
private List<string> _vipEquity1;
}
}