fix:1、添加支付,使用sdk的支付方案

This commit is contained in:
2026-05-21 10:56:37 +08:00
parent d8b41f25ba
commit 8144a27fdb
34 changed files with 4555 additions and 3840 deletions
+158 -158
View File
@@ -1,158 +1,158 @@
using System;
using FGUI.ZM_Common_01;
using SGModule.NetKit;
using Spine.Unity;
namespace RedHotRoast
{
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;
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 (need_call) GameHelper.CallShowTurn();
}
private bool need_call;
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_AddCell_12.com_addView;
}
protected override void OnOpenBefore(object args)
{
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.buy_one_show);
if (args != null) need_call = (bool)args;
// ad_cool_down = ConfigSystem.GetConfig<CommonModel>().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);
});
}
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 Action closeCallback = null;
//初始化页面逻辑
private void InitView()
{
// var add = FXManager.Instance.SetFx<SkeletonAnimation>(ui.anim_bg, Fx_Type.fx_add_box, ref closeCallback);
// add.state.SetAnimation(0, "animation", true);
//
ui.btn_close.SetClick(() =>
{
CtrlCloseUI();
});
// HallManager.Instance.UpdateSecondEvent += updateWatchCD;
// updateWatchCD();
// checkBtnState();
}
public void SetTextString()
{
var need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.buy_one));
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.text_watch_ad.SetVar("needNum", need.ToString()).FlushVars();
ui.tips.SetVar("needAds", need.ToString()).FlushVars();
ui.tips.SetVar("myAds", myAd.ToString()).FlushVars();
}
}
}
using System;
using FGUI.ZM_Common_01;
using SGModule.NetKit;
using Spine.Unity;
namespace RedHotRoast
{
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;
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 (need_call) GameHelper.CallShowTurn();
}
private bool need_call;
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_AddCell_12.com_addView;
}
protected override void OnOpenBefore(object args)
{
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.buy_one_show);
if (args != null) need_call = (bool)args;
// ad_cool_down = ConfigSystem.GetConfig<CommonModel>().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,
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);
}
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 Action closeCallback = null;
//初始化页面逻辑
private void InitView()
{
// var add = FXManager.Instance.SetFx<SkeletonAnimation>(ui.anim_bg, Fx_Type.fx_add_box, ref closeCallback);
// add.state.SetAnimation(0, "animation", true);
//
ui.btn_close.SetClick(() =>
{
CtrlCloseUI();
});
// HallManager.Instance.UpdateSecondEvent += updateWatchCD;
// updateWatchCD();
// checkBtnState();
}
public void SetTextString()
{
var need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_SPACE_BONUS);
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.text_watch_ad.SetVar("needNum", need.ToString()).FlushVars();
ui.tips.SetVar("needAds", need.ToString()).FlushVars();
ui.tips.SetVar("myAds", myAd.ToString()).FlushVars();
}
}
}
+221 -221
View File
@@ -1,221 +1,221 @@
using System;
using System.Collections.Generic;
using DG.Tweening;
using FGUI.ZM_Common_01;
using Spine.Unity;
using UnityEngine;
using Random = UnityEngine.Random;
namespace RedHotRoast
{
public class BroadcastUI : BaseUI
{
private BroadcastUICtrl ctrl;
private BroadcastModel model;
private com_broadcast1 ui;
public BroadcastUI(BroadcastUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.BroadcastUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_Common_01";
uiInfo.assetName = "com_broadcast1";
uiInfo.layerType = UILayerType.Highest;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = false;
}
#region
protected override void OnInit()
{
}
protected override void OnClose()
{
}
protected override void OnBind()
{
ui = baseUI as com_broadcast1;
}
protected override void OnOpenBefore(object args)
{
InitView();
//ui.y = 241;
if (UIManager.Instance.IsExistUI(UIConst.RainPlayUI))
{
Settop();
}
else
{
Setbuttom();
}
// ui.visible = false;
// if (Screen.safeArea.y != 0)
// {//刘海屏
// ui.y += Screen.safeArea.y;
// }
text_ui = ui.broad_cast_text;
text_ui.btn_broad.SetClick(OpenRecord);
if (ConfigSystem.GetConfig<SubscribePodcast>() == null) return;
config_name_list = SubscribePodcastModel.config_name_list;
config_vip_level_list = SubscribePodcastModel.config_vip_level_list;
GameDispatcher.Instance.AddListener(GameMsg.hideBroadCast, hideEvent);
GameDispatcher.Instance.AddListener(GameMsg.showBroadCast, showEvent);
UICtrlDispatcher.Instance.AddListener(UICtrlMsg.MainUI_Open, Setbuttom);
UICtrlDispatcher.Instance.AddListener(UICtrlMsg.RainPlayUI_Open, Settop);
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
}
protected override void RemoveListener()
{
}
#endregion
private int time_count = 11;
private com_broadcast_text1 text_ui;
private List<string> config_name_list;
private List<string> config_vip_level_list;
private bool main_ui_show = true;
//初始化页面逻辑
private Action closeCallback;
private void InitView()
{
HallManager.Instance.UpdateSecondEvent += timeEvent;
var sk = FXManager.Instance.SetFx<SkeletonAnimation>(ui.broad_cast_text.bg_panel, Fx_Type.fx_broad, ref closeCallback);
sk.state.SetAnimation(0, "animation", true);
ui.broad_cast_text.bg_panel.SetScale(1.45f, 1.1f);
}
private void OpenRecord()
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.RecordViewUI_Open);
}
private void hideEvent(object sender = null)
{
Debug.Log("hide");
main_ui_show = false;
ui.visible = false;
}
private void showEvent(object sender = null)
{
Debug.Log("show");
main_ui_show = true;
ui.visible = true;
}
private void Settop(object sender = null)
{
ui.group_.y = 350;
if (Screen.safeArea.y != 0)
{//刘海屏
ui.group_.y += 68;
}
}
private void Setbuttom(object sender = null)
{
ui.group_.y = 170;
if (Screen.safeArea.y != 0)
{//刘海屏
ui.group_.y += 68;
}
}
# if GAME_RELEASE
private const int MaxTime = 300;
#else
private const int MaxTime = 10;
#endif
void timeEvent()
{
time_count++;
Debug.Log(time_count);
Debug.Log(MaxTime);
if (time_count > MaxTime)
{
time_count = 0;
var name_index = Random.Range(0, config_name_list.Count);
var money_index = Random.Range(0, config_vip_level_list.Count);
Debug.Log(text_ui.cast_text.text);
string name = config_name_list[name_index];
if (name.Length > 8)
{
name = name[..8] + "..";
}
string broad_text = String.Format(text_ui.hide_text.text, name,
config_vip_level_list[money_index], DateTimeManager.Instance.GetCurrDateTime());
text_ui.cast_text.text = broad_text;
var lv = GetVipLevelFromName(config_vip_level_list[money_index]);
text_ui.broad_icon_loader.url = $"ui://LG_Common/vip_{lv}";
// Tweener tweener = DOTween.To(() => ui.broad.x,
// x => ui.broad.x = x, 200, 0.5f);
ui.t0.Play();
DOVirtual.DelayedCall(3.5f, () =>
{
// Tweener tweener = DOTween.To(() => ui.broad.x,
// x => ui.broad.x = x, 1080, 0.5f);
ui.t1.Play();
});
string str = name + "#" + config_vip_level_list[money_index] + "#" + DateTimeManager.Instance.GetCurrDateTime();
GameDispatcher.Instance.Dispatch(GameMsg.updateRecordList, str);
}
}
private int GetVipLevelFromName(string name)
{
var vip_level = 1;
switch (name)
{
case "Gold":
vip_level = 1;
break;
case "Platinum":
vip_level = 2;
break;
case "Diamond":
vip_level = 3;
break;
}
return vip_level;
}
}
}
using System;
using System.Collections.Generic;
using DG.Tweening;
using FGUI.ZM_Common_01;
using Spine.Unity;
using UnityEngine;
using Random = UnityEngine.Random;
namespace RedHotRoast
{
public class BroadcastUI : BaseUI
{
private BroadcastUICtrl ctrl;
private BroadcastModel model;
private com_broadcast1 ui;
public BroadcastUI(BroadcastUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.BroadcastUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_Common_01";
uiInfo.assetName = "com_broadcast1";
uiInfo.layerType = UILayerType.Highest;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = false;
}
#region
protected override void OnInit()
{
}
protected override void OnClose()
{
}
protected override void OnBind()
{
ui = baseUI as com_broadcast1;
}
protected override void OnOpenBefore(object args)
{
InitView();
//ui.y = 241;
if (UIManager.Instance.IsExistUI(UIConst.RainPlayUI))
{
Settop();
}
else
{
Setbuttom();
}
// ui.visible = false;
// if (Screen.safeArea.y != 0)
// {//刘海屏
// ui.y += Screen.safeArea.y;
// }
text_ui = ui.broad_cast_text;
text_ui.btn_broad.SetClick(OpenRecord);
if (ConfigSystem.GetConfig<SubscribePodcast>() == null) return;
config_name_list = SubscribePodcastModel.config_name_list;
config_vip_level_list = SubscribePodcastModel.config_vip_level_list;
GameDispatcher.Instance.AddListener(GameMsg.hideBroadCast, hideEvent);
GameDispatcher.Instance.AddListener(GameMsg.showBroadCast, showEvent);
UICtrlDispatcher.Instance.AddListener(UICtrlMsg.MainUI_Open, Setbuttom);
UICtrlDispatcher.Instance.AddListener(UICtrlMsg.RainPlayUI_Open, Settop);
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
}
protected override void RemoveListener()
{
}
#endregion
private int time_count = 11;
private com_broadcast_text1 text_ui;
private List<string> config_name_list;
private List<string> config_vip_level_list;
private bool main_ui_show = true;
//初始化页面逻辑
private Action closeCallback;
private void InitView()
{
HallManager.Instance.UpdateSecondEvent += timeEvent;
var sk = FXManager.Instance.SetFx<SkeletonAnimation>(ui.broad_cast_text.bg_panel, Fx_Type.fx_broad, ref closeCallback);
sk.state.SetAnimation(0, "animation", true);
ui.broad_cast_text.bg_panel.SetScale(1.45f, 1.1f);
}
private void OpenRecord()
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.RecordViewUI_Open);
}
private void hideEvent(object sender = null)
{
Debug.Log("hide");
main_ui_show = false;
ui.visible = false;
}
private void showEvent(object sender = null)
{
Debug.Log("show");
main_ui_show = true;
ui.visible = true;
}
private void Settop(object sender = null)
{
ui.group_.y = 350;
if (Screen.safeArea.y != 0)
{//刘海屏
ui.group_.y += 68;
}
}
private void Setbuttom(object sender = null)
{
ui.group_.y = 170;
if (Screen.safeArea.y != 0)
{//刘海屏
ui.group_.y += 68;
}
}
# if GAME_RELEASE
private const int MaxTime = 300;
#else
private const int MaxTime = 10;
#endif
void timeEvent()
{
time_count++;
// Debug.Log(time_count);
// Debug.Log(MaxTime);
if (time_count > MaxTime)
{
time_count = 0;
var name_index = Random.Range(0, config_name_list.Count);
var money_index = Random.Range(0, config_vip_level_list.Count);
Debug.Log(text_ui.cast_text.text);
string name = config_name_list[name_index];
if (name.Length > 8)
{
name = name[..8] + "..";
}
string broad_text = String.Format(text_ui.hide_text.text, name,
config_vip_level_list[money_index], DateTimeManager.Instance.GetCurrDateTime());
text_ui.cast_text.text = broad_text;
var lv = GetVipLevelFromName(config_vip_level_list[money_index]);
text_ui.broad_icon_loader.url = $"ui://LG_Common/vip_{lv}";
// Tweener tweener = DOTween.To(() => ui.broad.x,
// x => ui.broad.x = x, 200, 0.5f);
ui.t0.Play();
DOVirtual.DelayedCall(3.5f, () =>
{
// Tweener tweener = DOTween.To(() => ui.broad.x,
// x => ui.broad.x = x, 1080, 0.5f);
ui.t1.Play();
});
string str = name + "#" + config_vip_level_list[money_index] + "#" + DateTimeManager.Instance.GetCurrDateTime();
GameDispatcher.Instance.Dispatch(GameMsg.updateRecordList, str);
}
}
private int GetVipLevelFromName(string name)
{
var vip_level = 1;
switch (name)
{
case "Gold":
vip_level = 1;
break;
case "Platinum":
vip_level = 2;
break;
case "Diamond":
vip_level = 3;
break;
}
return vip_level;
}
}
}
+4 -1
View File
@@ -511,8 +511,9 @@ namespace RedHotRoast
ui.btn_live.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretUnlockUI_Open);
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LiveUI_Open);
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LiveUI_Open);
});
ui.btn_secret.title = "LV." + GameHelper.GetCommonModel().UnlockSecret[1];
@@ -593,6 +594,8 @@ namespace RedHotRoast
ui.btn_task.SetClick(() => { OnClickTask(false); });
ui.btn_restore.SetClick(() =>
{
IAPPayManager.Instance.OnRestoreButtonClicked();
// ApplePayManager.Instance.AppleRestore((success, message) =>
// {
// Debug.Log($"[barry] restore success message: {message}---- {JsonConvert.SerializeObject(message)}");
+362 -362
View File
@@ -1,362 +1,362 @@
using System.Collections.Generic;
using FairyGUI;
using DG.Tweening;
using FGUI.ZM_Common_01;
using System;
using SGModule.NetKit;
using UnityEngine;
namespace RedHotRoast
{
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;
}
protected override void OnClose()
{
AdExchangeManager.Instance.Destroy();
GameHelper.showGameUI = true;
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();
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_LuckyGift.com_lucky;
}
protected override void OnOpenBefore(object args)
{
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;
ui.gift_switch.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;
Debug.Log($"needScroll============={needScroll}= {ui.type.selectedIndex}");
TrackKit.SendEvent(GameHelper.GetEventName(), needScroll ? ADEventTrack.Property.gift_show : ADEventTrack.Property.first_pack_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;
});
InitView();
// var fileName = GameHelper.GetBackgroundName(1);
// Debug.Log($"fileName======{fileName}");
// TextureHelper.SetImgLoader(ui.no_ad_pic.picture, fileName, null, "Background/");
//
// var fileName1 = GameHelper.GetBackgroundName(2);
// Debug.Log($"fileName1======{fileName1}");
//
// TextureHelper.SetImgLoader(ui.lucky_pic.picture, fileName1, null, "Background/");
// var fileName = GameHelper.GetBackgroundName(1);
// var task = new List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)>();
// task.Add((ui.lucky_pic.picture, fileName, null, "Background/", FolderNames.BackgroundName));
// var fileName1 = GameHelper.GetBackgroundName(2);
// task.Add((ui.no_ad_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.GetChild("icon"));
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); });
});
});
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.GetChild("icon"));
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); });
});
});
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.btn_luck_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.SetClick(() => { });
}
else
{
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.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
{
ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.Start();
SetTextString1();
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)
{
}
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
{
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 SGModule.NetKit;
using UnityEngine;
namespace RedHotRoast
{
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;
}
protected override void OnClose()
{
AdExchangeManager.Instance.Destroy();
GameHelper.showGameUI = true;
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();
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_LuckyGift.com_lucky;
}
protected override void OnOpenBefore(object args)
{
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;
ui.gift_switch.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;
Debug.Log($"needScroll============={needScroll}= {ui.type.selectedIndex}");
TrackKit.SendEvent(GameHelper.GetEventName(), needScroll ? ADEventTrack.Property.gift_show : ADEventTrack.Property.first_pack_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;
});
InitView();
// var fileName = GameHelper.GetBackgroundName(1);
// Debug.Log($"fileName======{fileName}");
// TextureHelper.SetImgLoader(ui.no_ad_pic.picture, fileName, null, "Background/");
//
// var fileName1 = GameHelper.GetBackgroundName(2);
// Debug.Log($"fileName1======{fileName1}");
//
// TextureHelper.SetImgLoader(ui.lucky_pic.picture, fileName1, null, "Background/");
// var fileName = GameHelper.GetBackgroundName(1);
// var task = new List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)>();
// task.Add((ui.lucky_pic.picture, fileName, null, "Background/", FolderNames.BackgroundName));
// var fileName1 = GameHelper.GetBackgroundName(2);
// task.Add((ui.no_ad_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.GetChild("icon"));
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); });
});
});
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.GetChild("icon"));
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); });
});
});
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.btn_luck_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.SetClick(() => { });
}
else
{
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.SetClick(() =>
{
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price_remove * 100),
sku = IAPPayManager.PRODUCT_REMOVE_ADS,
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
}
else
{
ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.Start();
SetTextString1();
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)
{
}
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
{
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();
}
}
}
+3 -1
View File
@@ -65,7 +65,7 @@ namespace RedHotRoast
ui.com_gold.y += Screen.safeArea.y;
}
ui.gift_switch.selectedIndex = 1;
ui.gift_switch.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;
total_item = 8;
selectIndex = DataMgr.PlayerAvatarId.Value;
@@ -143,6 +143,8 @@ namespace RedHotRoast
// ui.btn_credits.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 2); });
ui.btn_restore.SetClick(() =>
{
//恢复购买按钮
IAPPayManager.Instance.OnRestoreButtonClicked();
// ApplePayManager.Instance.AppleRestore((success, message) =>
// {
// if (success)
File diff suppressed because it is too large Load Diff
+146 -146
View File
@@ -1,146 +1,146 @@
using System;
using System.Collections.Generic;
using FGUI.ZM_Common_01;
using SGModule.NetKit;
namespace RedHotRoast
{
public class PassunlockUI : BaseUI
{
private PassunlockUICtrl ctrl;
private PassunlockModel model;
private FGUI.ZM_Pack_16.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_Pack_16";
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();
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_Pack_16.com_passunlock;
}
protected override void OnOpenBefore(object args)
{
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);
});
}
ui.gift_switch.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;
InitView();
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.master_pass_show);
var fileName = GameHelper.GetBackgroundName(3);
TextureHelper.SetImgLoader(ui.loader.picture, fileName, null, "Background/", FolderNames.BackgroundName);
}
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);
// ui.btn_buypass.GetChild("title").text = "$" + ConfigSystem.GetConfig<CommonModel>().Passportgift;
}
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 FGUI.ZM_Common_01;
using SGModule.NetKit;
namespace RedHotRoast
{
public class PassunlockUI : BaseUI
{
private PassunlockUICtrl ctrl;
private PassunlockModel model;
private FGUI.ZM_Pack_16.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_Pack_16";
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();
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_Pack_16.com_passunlock;
}
protected override void OnOpenBefore(object args)
{
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);
});
}
ui.gift_switch.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;
InitView();
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.master_pass_show);
var fileName = GameHelper.GetBackgroundName(3);
TextureHelper.SetImgLoader(ui.loader.picture, fileName, null, "Background/", FolderNames.BackgroundName);
}
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);
// ui.btn_buypass.GetChild("title").text = "$" + ConfigSystem.GetConfig<CommonModel>().Passportgift;
}
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();
}
}
}
+76 -64
View File
@@ -60,14 +60,14 @@ namespace RedHotRoast
{
uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
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.apple_pay_success, pay_success);
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
@@ -102,30 +102,24 @@ namespace RedHotRoast
bool is_maxPay = false; // 第三方支付
string type = (string)str;
string purch_number = "";
if (type.Contains("buy_gold"))
if (PurchasingManager.ShopProductMap.TryGetValue(type, out var shopIdx))
{
if (type.StartsWith("buy_gold"))
int suffix_num = int.Parse(shopIdx);
purch_number = ConfigSystem.GetConfig<Paidcoins>()[suffix_num].Payment_amount2.ToString();
if (!UIManager.Instance.IsExistUI(UIConst.BuygoldUI))
{
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);
}
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))
else if (type == IAPPayManager.PRODUCT_PASS_BONUS)
{
SaveData.GetSaveObject().is_get_battlepass = true;
int gold = 0;
@@ -158,7 +152,7 @@ namespace RedHotRoast
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
}
}
else if (type == PurchasingManager.GetPaySku(PayType.buy_one))
else if (type == IAPPayManager.PRODUCT_SPACE_BONUS)
{
SaveData.GetSaveObject().have_slot = true;
SaveData.SaveDataFunc();
@@ -167,7 +161,7 @@ namespace RedHotRoast
purch_number = GameHelper.GetCommonModel().addspace2.ToString();
}
else if (type == PurchasingManager.GetPaySku(PayType.remove_ad))
else if (type == IAPPayManager.PRODUCT_REMOVE_ADS)
{
SaveData.GetSaveObject().remove_ad_time = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().RemoveADsPackDuration * 3600;
SaveData.GetSaveObject().is_get_removead = true;
@@ -179,7 +173,7 @@ namespace RedHotRoast
GameHelper.ShowTips("purchase_succ", true);
purch_number = ConfigSystem.GetConfig<Paidgift>()[1].Paid_price2.ToString();
}
else if (type == PurchasingManager.GetPaySku(PayType.pack_reward))
else if (type == IAPPayManager.PRODUCT_FIRST_GIFT)
{
List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
int gold_num = list[0].coins_quantity;
@@ -199,40 +193,38 @@ namespace RedHotRoast
GameHelper.ShowTips("purchase_succ", true);
purch_number = ConfigSystem.GetConfig<Paidgift>()[0].Paid_price2.ToString();
}
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<PaidgiftModel>().DataList[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"))
// 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<PaidgiftModel>().DataList[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 (PurchasingManager.VipProductMap.TryGetValue(type, out var vipIdx))
{
is_maxPay = true;
int startIndex = "vip_club".Length;
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffixNum = int.Parse(suffix);
int suffixNum = int.Parse(vipIdx);
if (!MaxPayManager.isIOSPay)
{
@@ -287,16 +279,36 @@ namespace RedHotRoast
// 付费上报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);
// 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);
TrackKit.SendEvent(AfPurchaseTrack.Event, AfPurchaseTrack.Property.af_revenue, (int)(purch_number.As<decimal>() * 10000));
var payData = new ApplePayData
{
sku = type,
currency = "USD",
amount = (int)(purch_number.As<decimal>() * 100),
isCompleted = true
};
//上报给服务器,用来做数据分析
PurchasingManager.ApplePayCreate<ApplePayData>(payData, (response) =>
{
Debug.Log($"[付费收益] Purchase-----type--{type}----{response.IsSuccess}");
if (response.IsSuccess)
{
}
});
}
}
@@ -307,9 +307,9 @@ namespace RedHotRoast
{
if (Screen.safeArea.y != 0)
{
ui.btn_gold.y += 68;
ui.btn_close.y += 68;
ui.sc_list.y += 68;
ui.btn_gold.y += 58;
ui.btn_close.y += 58;
ui.sc_list.y += 38;
}
var eventName = GameHelper.IsAdModelOfPay() ? ADEventTrack.Event : ADEventTrack.MaxPayEvent;
@@ -1,423 +1,423 @@
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 RedHotRoast
{
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.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();
HallManager.Instance.UpdateSecondEvent += UpWatchAdsBtn;
ui.btn_close.SetClick(CtrlCloseUI);
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() > 0)
{
ui.has_vip.selectedIndex = 1;
ui.btn_vip.x = 540;
// ui.btn_vip.y -= 10;
}
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.Event, eventName);
InitView();
}
});
}
});
ui.btn_vip.SetClick(() =>
{
TrackKit.SendEvent(ADEventTrack.SecretAlbums, ADEventTrack.Property.secret_albums_click_ + (_albumPreviewData.Index + 1));
if (GameHelper.GetVipLevel() > 0)
{
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 RedHotRoast
{
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.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();
HallManager.Instance.UpdateSecondEvent += UpWatchAdsBtn;
ui.btn_close.SetClick(CtrlCloseUI);
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() > 0)
{
ui.has_vip.selectedIndex = 1;
ui.btn_vip.x = 540;
// ui.btn_vip.y -= 10;
}
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.Event, eventName);
InitView();
}
});
}
});
ui.btn_vip.SetClick(() =>
{
TrackKit.SendEvent(ADEventTrack.SecretAlbums, ADEventTrack.Property.secret_albums_click_ + (_albumPreviewData.Index + 1));
if (GameHelper.GetVipLevel() > 0)
{
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;
}
}
File diff suppressed because it is too large Load Diff
+150 -150
View File
@@ -1,150 +1,150 @@
using FGUI.ZM_Common_01;
using UnityEngine;
using FairyGUI;
namespace RedHotRoast
{
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()
{
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_Unlock.com_SubUnlock;
}
protected override void OnOpenBefore(object args)
{
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.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 void InitView()
{
ui.btn_close.SetClick(() =>
{
CtrlCloseUI();
});
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);
if (GameHelper.GetVipLevel() - 1 >= 0)
{
ui.btn_vip0.enabled = false;
}
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);
});
if (GameHelper.GetVipLevel() - 1 >= 1)
{
ui.btn_vip1.enabled = false;
}
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);
});
if (GameHelper.GetVipLevel() - 1 >= 2)
{
ui.btn_vip2.enabled = false;
}
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;
namespace RedHotRoast
{
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()
{
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_Unlock.com_SubUnlock;
}
protected override void OnOpenBefore(object args)
{
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.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 void InitView()
{
ui.btn_close.SetClick(() =>
{
CtrlCloseUI();
});
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);
if (GameHelper.GetVipLevel() - 1 >= 0)
{
ui.btn_vip0.enabled = false;
}
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);
});
if (GameHelper.GetVipLevel() - 1 >= 1)
{
ui.btn_vip1.enabled = false;
}
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);
});
if (GameHelper.GetVipLevel() - 1 >= 2)
{
ui.btn_vip2.enabled = false;
}
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);
});
}
}
}
@@ -1,430 +1,430 @@
using System.Collections.Generic;
using FairyGUI;
using FGUI.threeDaysGift;
using Spine.Unity;
using DG.Tweening;
using System;
using SGModule.NetKit;
namespace RedHotRoast
{
public class ThreeDaysGiftUI : BaseUI
{
private ThreeDaysGiftUICtrl ctrl;
private ThreeDaysGiftModel model;
private FGUI.threeDaysGift.com_three_days ui;
public ThreeDaysGiftUI(ThreeDaysGiftUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.ThreeDaysGiftUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "threeDaysGift";
uiInfo.assetName = "com_three_days";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
}
protected override void OnClose()
{
HallManager.Instance.UpdateSecondEvent -= InitView;
GameHelper.showGameUI = true;
GameDispatcher.Instance.Dispatch(GameMsg.pack_close);
GameHelper.CallShowTurn();
}
protected override void OnBind()
{
ui = baseUI as FGUI.threeDaysGift.com_three_days;
}
private Action closeCallback;
protected override void OnOpenBefore(object args)
{
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.three_days_gift_show);
list = ConfigSystem.GetConfig<Multigift>();
ui.btn_close.SetClick(() =>
{
GameDispatcher.Instance.Dispatch(GameMsg.ThreeDaysGiftUIClose);
CtrlCloseUI();
});
ui.groups.visible = false;
var ske_bg = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_bg, Fx_Type.fx_three_gift, ref closeCallback);
ske_bg.state.SetAnimation(0, "3_days", false);
ske_bg.state.Complete += (a) =>
{
ske_bg.state.SetAnimation(0, "3_days_dj", false);
};
DOVirtual.DelayedCall(0.5f, () =>
{
ui.groups.visible = true;
});
InitView();
HallManager.Instance.UpdateSecondEvent += 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.rewardMul_close, rewardMul_close);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
GameDispatcher.Instance.RemoveListener(GameMsg.rewardMul_close, rewardMul_close);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
if (type == PurchasingManager.GetPaySku(PayType.three_days_gift))
{
// var start = Vector2.zero;
// if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day1) {
// start = GameHelper.GetUICenterPosition(ui.day1.item1.lab_num);
// } else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day2) {
// start = GameHelper.GetUICenterPosition(ui.day2.item1.lab_num);
// } else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day3) {
// start = GameHelper.GetUICenterPosition(ui.day3.item1.lab_num);
// }
//
// var rewardData = new RewardData();
// var end = GameHelper.GetUICenterPosition(ui.node_end);
//
// var rewardSingleData = new RewardSingleData(101, list[1].coins_quantity, RewardOrigin.AdTask)
// {
// startPosition = start,
// endPosition = end
// };
//
// rewardData.AddReward(rewardSingleData);
// rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
// rewardData.AddCompleted(success =>
// {
// // if (success)
// // {
// // RefreshGold(awardNum);
// // }
// });
//
// GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
// // DataMgr.Coin.Value -= list[1].coins_quantity;
//
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AdcomingUI_Close);
// SaveData.GetSaveObject().is_get_removead = true;
// InitView();
ui.pay_type.selectedIndex = 2;
}
// GameDispatcher.Instance.Dispatch(GameMsg.noads_refresh);
}
void rewardMul_close(object str)
{
if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day1)
{
TrackKit.SendEvent(ThreeDaysGiftEventTrack.Event, ThreeDaysGiftEventTrack.Property.three_day1_success);
}
else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day2)
{
TrackKit.SendEvent(ThreeDaysGiftEventTrack.Event, ThreeDaysGiftEventTrack.Property.three_day2_success);
}
else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day3)
{
TrackKit.SendEvent(ThreeDaysGiftEventTrack.Event, ThreeDaysGiftEventTrack.Property.three_day3_success);
}
SaveData.GetSaveObject().three_gift_got_index++;
SaveData.GetSaveObject().last_got_three_gift_time = GameHelper.GetNowTime();
}
private List<Multigift> list;
// int adNums = AdExchangeManager.Instance.GetLookRewardADNum();
// adNums++;
// AdExchangeManager.Instance.SetLookRewardADNum(adNums);
private void InitView()
{
ui.text_have.text = Language.GetContentParams("owner_ad", AdExchangeManager.Instance.GetLookRewardADNum());
ui.need_text.text = Language.GetContentParams("need_ad", list[0].Paid_price);
initItem(0);
initItem(1);
initItem(2);
FGUI.threeDaysGift.btn_watchAd btn_buypack = (ui.btn_buypack as FGUI.threeDaysGift.btn_watchAd);
GObject pack_title = ui.btn_buypack.GetChild("btn_text");
if (SaveData.GetSaveObject().is_get_ThreeDaysGift)
{
ui.pay_type.selectedIndex = 2;
var isToday = GameHelper.InToday(SaveData.GetSaveObject().last_got_three_gift_time, 0, true);
int three_gift_got_index = SaveData.GetSaveObject().three_gift_got_index;
if (isToday || (three_gift_got_index > (int)rewardState.day3))
{
ui.btn_get.grayed = true;
ui.btn_get.SetClick(() =>
{
if (three_gift_got_index < (int)rewardState.day3)
{
GameHelper.ShowTips("pick_tomorrow",true);
}
});
}
else
{
ui.btn_get.SetClick(() =>
{
getReward();
ui.btn_get.SetClick(() => { });
});
}
}
else
{
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_ThreeDaysGift;
if (is_get)
{
ui.btn_max_pack.enabled = false;
ui.btn_max_pack.SetClick(() => { });
}
else
{
ui.btn_max_pack.SetClick(() =>
{
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price_pack * 100),
sku =PurchasingManager.GetPaySku(PayType.three_days_gift),
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
}
else
{
ui.pay_type.selectedIndex = 0;
bool is_get = SaveData.GetSaveObject().is_get_ThreeDaysGift;
if (is_get)
{
btn_buypack.buy_state.selectedIndex = 0;
btn_buypack.can_buy.selectedIndex = 1;
ui.btn_buypack.grayed = true;
pack_title.text = Language.GetContent("claimed");
ui.btn_buypack.SetClick(() =>
{
});
}
else if (AdExchangeManager.Instance.GetLookRewardADNum() >= list[0].Paid_price)
{
btn_buypack.buy_state.selectedIndex = 1;
btn_buypack.can_buy.selectedIndex = 0;
btn_buypack.SetClick(() =>
{
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.three_days_gift_buy_success);
// SaveData.GetSaveObject().look_ad_numbers
int adNums = AdExchangeManager.Instance.GetLookRewardADNum();
adNums -= (int)list[0].Paid_price;
AdExchangeManager.Instance.SetLookRewardADNum(adNums);
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, PurchasingManager.GetPaySku(PayType.three_days_gift));
// getReward();
ui.btn_buypack.SetClick(() => { });
});
}
else if (SaveData.GetSaveObject()._watch_ad_cd > GameHelper.GetNowTime())
{
btn_buypack.buy_state.selectedIndex = 0;
btn_buypack.can_buy.selectedIndex = 1;
pack_title.text = CommonHelper.TimeFormat(SaveData.GetSaveObject()._watch_ad_cd - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
btn_buypack.SetClick(() => { });
}
else
{
btn_buypack.buy_state.selectedIndex = 0;
btn_buypack.can_buy.selectedIndex = 0;
pack_title.text = Language.GetContent("watch_ad");
btn_buypack.SetClick(() =>
{
GameHelper.ShowVideoAd("ThreeDaysGift", (issuccess) =>
{
if (issuccess)
{
SaveData.GetSaveObject()._watch_ad_cd = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().exchangeCD;
InitView();
}
});
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.three_days_gift_click);
});
}
}
}
}
private void initItem(int index)
{
com_item day = null;
if (index == 0)
{
day = ui.day1;
}
else if (index == 1)
{
day = ui.day2;
}
else if (index == 2)
{
day = ui.day3;
}
if (SaveData.GetSaveObject().three_gift_got_index - 1 > index)
{
day.img_select.visible = true;
if (SaveData.GetSaveObject().three_gift_got_index - 1 > 2)
{
day.img_select2.visible = true;
}
}
if (index == 2)
{
day.state.selectedIndex = 3;
for (int i = 0; i < 3; i++)
{
item_reward item = day.GetChild("item" + (i + 2)) as item_reward;
item.visible = false;
}
}
else
{
day.state.selectedIndex = list[index].props_quantity.Length;
}
setItemUrl(day.item1.loader_, GiftType.coin);
day.item1.lab_num.text = "x" + list[index].coins_quantity;
for (int i = 0; i < list[index].props_quantity.Length; i++)
{
item_reward item = (day.GetChild("item" + (i + 2)) as item_reward);
setItemUrl(item.loader_, (GiftType)list[index].props_type[i]);
item.visible = true;
item.lab_num.text = "x" + list[index].props_quantity[i];
}
}
private void setItemUrl(GLoader loader, GiftType urltype)
{
if (urltype == GiftType.coin) loader.url = "ui://threeDaysGift/3DAYS_prs_001";
else if (urltype == GiftType.move_out) loader.url = "ui://threeDaysGift/3DAYS_prs_003";
else if (urltype == GiftType.refresh) loader.url = "ui://threeDaysGift/3DAYS_prs_002";
else if (urltype == GiftType.undo) loader.url = "ui://threeDaysGift/3DAYS_prs_004";
}
private void getReward()
{
int index = SaveData.GetSaveObject().three_gift_got_index;
com_item item = null;
if (index == (int)rewardState.day1)
{
item = ui.day1;
}
else if (index == (int)rewardState.day2)
{
item = ui.day2;
}
else if (index == (int)rewardState.day3)
{
item = ui.day3;
}
item.img_select.visible = true;
List<int> types = new List<int>();
List<int> rewards = new List<int>();
types.Add((int)GiftType.coin);
rewards.Add(list[index - 1].coins_quantity);
for (int i = 0; i < list[index - 1].props_quantity.Length; i++)
{
types.Add(list[index - 1].props_type[i]); // GiftType 类型
rewards.Add(list[index - 1].props_quantity[i]);
}
GiftData data = new GiftData();
data.type = types;
data.reward = rewards;
uiCtrlDispatcher.Dispatch(UICtrlMsg.RewardMulNewUI_Open, data);
}
}
}
enum rewardState
{
day1 = 1,
day2,
day3
}
public class GiftData
{
public List<int> type;
public List<int> reward;
public string uiName;
}
public enum GiftType : int
{
coin = 101,
move_out = 0,
undo = 1,
refresh = 2,
}
using System.Collections.Generic;
using FairyGUI;
using FGUI.threeDaysGift;
using Spine.Unity;
using DG.Tweening;
using System;
using SGModule.NetKit;
namespace RedHotRoast
{
public class ThreeDaysGiftUI : BaseUI
{
private ThreeDaysGiftUICtrl ctrl;
private ThreeDaysGiftModel model;
private FGUI.threeDaysGift.com_three_days ui;
public ThreeDaysGiftUI(ThreeDaysGiftUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.ThreeDaysGiftUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "threeDaysGift";
uiInfo.assetName = "com_three_days";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
}
protected override void OnClose()
{
HallManager.Instance.UpdateSecondEvent -= InitView;
GameHelper.showGameUI = true;
GameDispatcher.Instance.Dispatch(GameMsg.pack_close);
GameHelper.CallShowTurn();
}
protected override void OnBind()
{
ui = baseUI as FGUI.threeDaysGift.com_three_days;
}
private Action closeCallback;
protected override void OnOpenBefore(object args)
{
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.three_days_gift_show);
list = ConfigSystem.GetConfig<Multigift>();
ui.btn_close.SetClick(() =>
{
GameDispatcher.Instance.Dispatch(GameMsg.ThreeDaysGiftUIClose);
CtrlCloseUI();
});
ui.groups.visible = false;
var ske_bg = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_bg, Fx_Type.fx_three_gift, ref closeCallback);
ske_bg.state.SetAnimation(0, "3_days", false);
ske_bg.state.Complete += (a) =>
{
ske_bg.state.SetAnimation(0, "3_days_dj", false);
};
DOVirtual.DelayedCall(0.5f, () =>
{
ui.groups.visible = true;
});
InitView();
HallManager.Instance.UpdateSecondEvent += 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.rewardMul_close, rewardMul_close);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
// GameDispatcher.Instance.RemoveListener(GameMsg.rewardMul_close, rewardMul_close);
}
#endregion
void pay_success(object str)
{
// string type = (string)str;
// if (type == PurchasingManager.GetPaySku(PayType.three_days_gift))
// {
//
// // var start = Vector2.zero;
// // if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day1) {
// // start = GameHelper.GetUICenterPosition(ui.day1.item1.lab_num);
// // } else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day2) {
// // start = GameHelper.GetUICenterPosition(ui.day2.item1.lab_num);
// // } else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day3) {
// // start = GameHelper.GetUICenterPosition(ui.day3.item1.lab_num);
// // }
// //
// // var rewardData = new RewardData();
// // var end = GameHelper.GetUICenterPosition(ui.node_end);
// //
// // var rewardSingleData = new RewardSingleData(101, list[1].coins_quantity, RewardOrigin.AdTask)
// // {
// // startPosition = start,
// // endPosition = end
// // };
// //
// // rewardData.AddReward(rewardSingleData);
// // rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
// // rewardData.AddCompleted(success =>
// // {
// // // if (success)
// // // {
// // // RefreshGold(awardNum);
// // // }
// // });
// //
// // GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
// // // DataMgr.Coin.Value -= list[1].coins_quantity;
// //
// // UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AdcomingUI_Close);
// // SaveData.GetSaveObject().is_get_removead = true;
// // InitView();
//
// ui.pay_type.selectedIndex = 2;
// }
// // GameDispatcher.Instance.Dispatch(GameMsg.noads_refresh);
//
}
void rewardMul_close(object str)
{
if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day1)
{
TrackKit.SendEvent(ThreeDaysGiftEventTrack.Event, ThreeDaysGiftEventTrack.Property.three_day1_success);
}
else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day2)
{
TrackKit.SendEvent(ThreeDaysGiftEventTrack.Event, ThreeDaysGiftEventTrack.Property.three_day2_success);
}
else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day3)
{
TrackKit.SendEvent(ThreeDaysGiftEventTrack.Event, ThreeDaysGiftEventTrack.Property.three_day3_success);
}
SaveData.GetSaveObject().three_gift_got_index++;
SaveData.GetSaveObject().last_got_three_gift_time = GameHelper.GetNowTime();
}
private List<Multigift> list;
// int adNums = AdExchangeManager.Instance.GetLookRewardADNum();
// adNums++;
// AdExchangeManager.Instance.SetLookRewardADNum(adNums);
private void InitView()
{
ui.text_have.text = Language.GetContentParams("owner_ad", AdExchangeManager.Instance.GetLookRewardADNum());
ui.need_text.text = Language.GetContentParams("need_ad", list[0].Paid_price);
initItem(0);
initItem(1);
initItem(2);
FGUI.threeDaysGift.btn_watchAd btn_buypack = (ui.btn_buypack as FGUI.threeDaysGift.btn_watchAd);
GObject pack_title = ui.btn_buypack.GetChild("btn_text");
if (SaveData.GetSaveObject().is_get_ThreeDaysGift)
{
ui.pay_type.selectedIndex = 2;
var isToday = GameHelper.InToday(SaveData.GetSaveObject().last_got_three_gift_time, 0, true);
int three_gift_got_index = SaveData.GetSaveObject().three_gift_got_index;
if (isToday || (three_gift_got_index > (int)rewardState.day3))
{
ui.btn_get.grayed = true;
ui.btn_get.SetClick(() =>
{
if (three_gift_got_index < (int)rewardState.day3)
{
GameHelper.ShowTips("pick_tomorrow",true);
}
});
}
else
{
ui.btn_get.SetClick(() =>
{
getReward();
ui.btn_get.SetClick(() => { });
});
}
}
else
{
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_ThreeDaysGift;
if (is_get)
{
ui.btn_max_pack.enabled = false;
ui.btn_max_pack.SetClick(() => { });
}
else
{
ui.btn_max_pack.SetClick(() =>
{
// ApplePayClass maxPayData = new ApplePayClass
// {
// amount = (int)Math.Round(price_pack * 100),
// sku =PurchasingManager.GetPaySku(PayType.three_days_gift),
// currency = "USD"
// };
// MaxPayManager.Instance.Buy(maxPayData);
});
}
}
else
{
ui.pay_type.selectedIndex = 0;
bool is_get = SaveData.GetSaveObject().is_get_ThreeDaysGift;
if (is_get)
{
btn_buypack.buy_state.selectedIndex = 0;
btn_buypack.can_buy.selectedIndex = 1;
ui.btn_buypack.grayed = true;
pack_title.text = Language.GetContent("claimed");
ui.btn_buypack.SetClick(() =>
{
});
}
else if (AdExchangeManager.Instance.GetLookRewardADNum() >= list[0].Paid_price)
{
btn_buypack.buy_state.selectedIndex = 1;
btn_buypack.can_buy.selectedIndex = 0;
btn_buypack.SetClick(() =>
{
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.three_days_gift_buy_success);
// SaveData.GetSaveObject().look_ad_numbers
int adNums = AdExchangeManager.Instance.GetLookRewardADNum();
adNums -= (int)list[0].Paid_price;
AdExchangeManager.Instance.SetLookRewardADNum(adNums);
// GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, PurchasingManager.GetPaySku(PayType.three_days_gift));
// getReward();
ui.btn_buypack.SetClick(() => { });
});
}
else if (SaveData.GetSaveObject()._watch_ad_cd > GameHelper.GetNowTime())
{
btn_buypack.buy_state.selectedIndex = 0;
btn_buypack.can_buy.selectedIndex = 1;
pack_title.text = CommonHelper.TimeFormat(SaveData.GetSaveObject()._watch_ad_cd - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
btn_buypack.SetClick(() => { });
}
else
{
btn_buypack.buy_state.selectedIndex = 0;
btn_buypack.can_buy.selectedIndex = 0;
pack_title.text = Language.GetContent("watch_ad");
btn_buypack.SetClick(() =>
{
GameHelper.ShowVideoAd("ThreeDaysGift", (issuccess) =>
{
if (issuccess)
{
SaveData.GetSaveObject()._watch_ad_cd = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().exchangeCD;
InitView();
}
});
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.three_days_gift_click);
});
}
}
}
}
private void initItem(int index)
{
com_item day = null;
if (index == 0)
{
day = ui.day1;
}
else if (index == 1)
{
day = ui.day2;
}
else if (index == 2)
{
day = ui.day3;
}
if (SaveData.GetSaveObject().three_gift_got_index - 1 > index)
{
day.img_select.visible = true;
if (SaveData.GetSaveObject().three_gift_got_index - 1 > 2)
{
day.img_select2.visible = true;
}
}
if (index == 2)
{
day.state.selectedIndex = 3;
for (int i = 0; i < 3; i++)
{
item_reward item = day.GetChild("item" + (i + 2)) as item_reward;
item.visible = false;
}
}
else
{
day.state.selectedIndex = list[index].props_quantity.Length;
}
setItemUrl(day.item1.loader_, GiftType.coin);
day.item1.lab_num.text = "x" + list[index].coins_quantity;
for (int i = 0; i < list[index].props_quantity.Length; i++)
{
item_reward item = (day.GetChild("item" + (i + 2)) as item_reward);
setItemUrl(item.loader_, (GiftType)list[index].props_type[i]);
item.visible = true;
item.lab_num.text = "x" + list[index].props_quantity[i];
}
}
private void setItemUrl(GLoader loader, GiftType urltype)
{
if (urltype == GiftType.coin) loader.url = "ui://threeDaysGift/3DAYS_prs_001";
else if (urltype == GiftType.move_out) loader.url = "ui://threeDaysGift/3DAYS_prs_003";
else if (urltype == GiftType.refresh) loader.url = "ui://threeDaysGift/3DAYS_prs_002";
else if (urltype == GiftType.undo) loader.url = "ui://threeDaysGift/3DAYS_prs_004";
}
private void getReward()
{
int index = SaveData.GetSaveObject().three_gift_got_index;
com_item item = null;
if (index == (int)rewardState.day1)
{
item = ui.day1;
}
else if (index == (int)rewardState.day2)
{
item = ui.day2;
}
else if (index == (int)rewardState.day3)
{
item = ui.day3;
}
item.img_select.visible = true;
List<int> types = new List<int>();
List<int> rewards = new List<int>();
types.Add((int)GiftType.coin);
rewards.Add(list[index - 1].coins_quantity);
for (int i = 0; i < list[index - 1].props_quantity.Length; i++)
{
types.Add(list[index - 1].props_type[i]); // GiftType 类型
rewards.Add(list[index - 1].props_quantity[i]);
}
GiftData data = new GiftData();
data.type = types;
data.reward = rewards;
uiCtrlDispatcher.Dispatch(UICtrlMsg.RewardMulNewUI_Open, data);
}
}
}
enum rewardState
{
day1 = 1,
day2,
day3
}
public class GiftData
{
public List<int> type;
public List<int> reward;
public string uiName;
}
public enum GiftType : int
{
coin = 101,
move_out = 0,
undo = 1,
refresh = 2,
}
@@ -182,13 +182,13 @@ namespace RedHotRoast
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
GameDispatcher.Instance.AddListener(GameMsg.IAP_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.IAP_PAY_SUCCESS, pay_success);
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, InitView);
}
@@ -221,6 +221,8 @@ namespace RedHotRoast
ui.btn_restore.visible = !GameHelper.IsGiftSwitch();
ui.btn_restore.SetClick(() =>
{
IAPPayManager.Instance.OnRestoreButtonClicked();
// ApplePayManager.Instance.AppleRestore((success, message) =>
// {
// Debug.Log($"[barry] restore success message: {message}---- {JsonConvert.SerializeObject(message)}");
@@ -258,7 +260,7 @@ namespace RedHotRoast
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)System.Math.Round(vip_list[_level].DiscountPrice * 100),
sku = PurchasingManager.GetPaySku(GetTypeByIndex(_level)),
sku = GetTypeByIndex(_level),
currency = "USD",
shopName = _type
};
@@ -278,14 +280,14 @@ namespace RedHotRoast
ui.vip_icon_loader.url = $"ui://LG_Common/vip_{lv}";
}
private PayType GetTypeByIndex(int index)
private string GetTypeByIndex(int index)
{
return index switch
{
0 => PayType.weekly_subscription,
1 => PayType.monthly_subscription,
2 => PayType.yearly_subscription,
_ => PayType.weekly_subscription
0 => IAPPayManager.PRODUCT_VIP_WEEK,
1 => IAPPayManager.PRODUCT_VIP_MONTH,
2 => IAPPayManager.PRODUCT_VIP_YEAR,
_ => IAPPayManager.PRODUCT_VIP_WEEK
};
}