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
File diff suppressed because one or more lines are too long
@@ -1,68 +1,68 @@
namespace RedHotRoast namespace RedHotRoast
{ {
public static partial class GameMsg public static partial class GameMsg
{ {
public static readonly uint OpenGame = ++Cursor_BASE; public static readonly uint OpenGame = ++Cursor_BASE;
public static readonly uint Update111Completed = ++Cursor_BASE; public static readonly uint Update111Completed = ++Cursor_BASE;
public static readonly uint BackMainScene = ++Cursor_BASE; public static readonly uint BackMainScene = ++Cursor_BASE;
public static readonly uint Update101Completed = ++Cursor_BASE; public static readonly uint Update101Completed = ++Cursor_BASE;
public static readonly uint Update102 = ++Cursor_BASE; public static readonly uint Update102 = ++Cursor_BASE;
public static uint Slot_refresh = ++Cursor_BASE; public static uint Slot_refresh = ++Cursor_BASE;
public static uint Remake_state = ++Cursor_BASE; public static uint Remake_state = ++Cursor_BASE;
public static readonly uint MakeupSuccess = ++Cursor_BASE; public static readonly uint MakeupSuccess = ++Cursor_BASE;
public static readonly uint Update102Completed = ++Cursor_BASE; public static readonly uint Update102Completed = ++Cursor_BASE;
public static uint PaySuccess = ++Cursor_BASE; public static uint PaySuccess = ++Cursor_BASE;
public static uint Ad_success = ++Cursor_BASE; public static uint Ad_success = ++Cursor_BASE;
public static uint UpdateHotFixMax = ++Cursor_BASE; public static uint UpdateHotFixMax = ++Cursor_BASE;
public static uint UpdateHotFixProgress = ++Cursor_BASE; public static uint UpdateHotFixProgress = ++Cursor_BASE;
public static readonly uint RefreshMakeupData = ++Cursor_BASE; public static readonly uint RefreshMakeupData = ++Cursor_BASE;
public static uint Gold_refresh = ++Cursor_BASE; public static uint Gold_refresh = ++Cursor_BASE;
public static uint Sheep_item_refresh = ++Cursor_BASE; public static uint Sheep_item_refresh = ++Cursor_BASE;
public static uint card_click = ++Cursor_BASE; public static uint card_click = ++Cursor_BASE;
public static uint UpdateCurrency102 = ++Cursor_BASE; public static uint UpdateCurrency102 = ++Cursor_BASE;
public static uint RefreshADTask = ++Cursor_BASE; public static uint RefreshADTask = ++Cursor_BASE;
public static readonly uint GetReward = ++Cursor_BASE; public static readonly uint GetReward = ++Cursor_BASE;
public static readonly uint ProcessReward = ++Cursor_BASE; public static readonly uint ProcessReward = ++Cursor_BASE;
public static readonly uint Update101 = ++Cursor_BASE; public static readonly uint Update101 = ++Cursor_BASE;
public static readonly uint MakeUpConfirmUIClosed = ++Cursor_BASE; public static readonly uint MakeUpConfirmUIClosed = ++Cursor_BASE;
public static readonly uint Update111 = ++Cursor_BASE; public static readonly uint Update111 = ++Cursor_BASE;
public static uint reset_game = ++Cursor_BASE; public static uint reset_game = ++Cursor_BASE;
public static uint GetTaskReward = ++Cursor_BASE; public static uint GetTaskReward = ++Cursor_BASE;
public static uint pack_close = ++Cursor_BASE; public static uint pack_close = ++Cursor_BASE;
public static uint RefreshRedDot = ++Cursor_BASE; public static uint RefreshRedDot = ++Cursor_BASE;
public static uint resetH5progress = ++Cursor_BASE; public static uint resetH5progress = ++Cursor_BASE;
public static uint RefreshGame = ++Cursor_BASE; public static uint RefreshGame = ++Cursor_BASE;
public static uint RewardUIClosed = ++Cursor_BASE; public static uint RewardUIClosed = ++Cursor_BASE;
public static uint H5ViewClickBtn = ++Cursor_BASE; public static uint H5ViewClickBtn = ++Cursor_BASE;
public static uint apple_pay_success = ++Cursor_BASE; public static uint IAP_PAY_SUCCESS = ++Cursor_BASE;
public static uint ExitGame = ++Cursor_BASE; public static uint ExitGame = ++Cursor_BASE;
public static uint UpdateNoads = ++Cursor_BASE; public static uint UpdateNoads = ++Cursor_BASE;
public static uint Network_reconnection = ++Cursor_BASE; public static uint Network_reconnection = ++Cursor_BASE;
public static uint resurgence = ++Cursor_BASE; public static uint resurgence = ++Cursor_BASE;
public static uint resurgence_close = ++Cursor_BASE; public static uint resurgence_close = ++Cursor_BASE;
public static uint RefreshSaveingPot = ++Cursor_BASE; public static uint RefreshSaveingPot = ++Cursor_BASE;
public static uint hideBroadCast = ++Cursor_BASE; public static uint hideBroadCast = ++Cursor_BASE;
public static uint showBroadCast = ++Cursor_BASE; public static uint showBroadCast = ++Cursor_BASE;
public static uint updateRecordList = ++Cursor_BASE; public static uint updateRecordList = ++Cursor_BASE;
public static uint ThreeDaysGiftUIClose = ++Cursor_BASE; public static uint ThreeDaysGiftUIClose = ++Cursor_BASE;
public static uint rewardMul_close = ++Cursor_BASE; public static uint rewardMul_close = ++Cursor_BASE;
public static uint RefreshConfig = ++Cursor_BASE; public static uint RefreshConfig = ++Cursor_BASE;
public static uint UnlockLevelsuccess = ++Cursor_BASE; public static uint UnlockLevelsuccess = ++Cursor_BASE;
public static uint creatCARD = ++Cursor_BASE; public static uint creatCARD = ++Cursor_BASE;
public static uint LiveChange = ++Cursor_BASE; public static uint LiveChange = ++Cursor_BASE;
public static uint liveDetailClose = ++Cursor_BASE; public static uint liveDetailClose = ++Cursor_BASE;
public static uint UnlockSecretSuccess = ++Cursor_BASE; public static uint UnlockSecretSuccess = ++Cursor_BASE;
public static uint UnlockAlbums = ++Cursor_BASE; public static uint UnlockAlbums = ++Cursor_BASE;
public static uint BuyVip = ++Cursor_BASE; public static uint BuyVip = ++Cursor_BASE;
public static uint CheckEnd = ++Cursor_BASE; public static uint CheckEnd = ++Cursor_BASE;
public static uint AddChatNum = ++Cursor_BASE; public static uint AddChatNum = ++Cursor_BASE;
public static uint Setbg = ++Cursor_BASE; public static uint Setbg = ++Cursor_BASE;
public static uint liveVideoLoaded = ++Cursor_BASE; public static uint liveVideoLoaded = ++Cursor_BASE;
} }
} }
+15 -2
View File
@@ -1404,7 +1404,7 @@ namespace RedHotRoast
/// <returns>true:广告兑换 -- false:三方支付</returns> /// <returns>true:广告兑换 -- false:三方支付</returns>
public static bool IsAdModelOfPay() public static bool IsAdModelOfPay()
{ {
return true;//zhushi // return true;//zhushi
var isAd = GetLoginModel().Enwp != 1; var isAd = GetLoginModel().Enwp != 1;
return isAd; return isAd;
} }
@@ -1750,7 +1750,20 @@ namespace RedHotRoast
} }
#endregion #endregion
public static string getTrackEvenName()
{
string event_ = ADEventTrack.Event;
if (GetLoginModel().Enwp == 1)
{
int rate = GetCommonModel().PayRate;
if (!IsGiftSwitch() || GetCommonModel().PayRate == 100)
{
MaxPayManager.isIOSPay = true;
}
event_ = MaxPayManager.isIOSPay ? ADEventTrack.IOS_Pay_Event : ADEventTrack.MaxPayEvent;
}
return event_;
}
} }
} }
+4 -1
View File
@@ -75,7 +75,10 @@ namespace RedHotRoast
shopName = "", shopName = "",
type = "" type = ""
}; };
List<ApplePay2> listA = ConfigSystem.GetConfig<ApplePay2>(); // List<ApplePay2> listA = ConfigSystem.GetConfig<ApplePay2>();
//更新map中的value,与配置表的id对应
PurchasingManager.SetShopMapValue();
// // 方式一:LINQ Select // // 方式一:LINQ Select
// List<ProductConfig> listB = listA // List<ProductConfig> listB = listA
Binary file not shown.

Before

Width:  |  Height:  |  Size: 470 KiB

After

Width:  |  Height:  |  Size: 502 KiB

+45
View File
@@ -1893,6 +1893,50 @@ SpriteRenderer:
m_WasSpriteAssigned: 1 m_WasSpriteAssigned: 1
m_MaskInteraction: 0 m_MaskInteraction: 0
m_SpriteSortPoint: 0 m_SpriteSortPoint: 0
--- !u!1 &1659410217
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1659410219}
- component: {fileID: 1659410218}
m_Layer: 0
m_Name: IAPPayManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1659410218
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1659410217}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4b5c2a375fb4610a0417b408c252104, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1659410219
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1659410217}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -21.708763, y: 1.0219306, z: 3152.2478}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1667672678 --- !u!1 &1667672678
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -2342,3 +2386,4 @@ SceneRoots:
- {fileID: 392099410} - {fileID: 392099410}
- {fileID: 29401442} - {fileID: 29401442}
- {fileID: 292594112} - {fileID: 292594112}
- {fileID: 1659410219}
+437 -439
View File
@@ -1,439 +1,437 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using RedHotRoast; using RedHotRoast;
using DG.Tweening; using DG.Tweening;
using FGUI.ZM_Common_01; using FGUI.ZM_Common_01;
using UnityEngine; using UnityEngine;
using Newtonsoft.Json; using Newtonsoft.Json;
using SGModule.Common.Helper; using SGModule.Common.Helper;
using SGModule.NetKit; using SGModule.NetKit;
using System.Linq; using System.Linq;
public class AdExchangeManager public class AdExchangeManager
{ {
public static readonly AdExchangeManager Instance = new AdExchangeManager(); public static readonly AdExchangeManager Instance = new AdExchangeManager();
AdExchangeManager() AdExchangeManager()
{ {
} }
// public const string buy_one = "com.rainforestworld.space.24.99"; // public const string buy_one = "com.rainforestworld.space.24.99";
// // public const string buy_gold_1 = "com.rainforestworld.shop.1.99"; // // public const string buy_gold_1 = "com.rainforestworld.shop.1.99";
// // public const string buy_gold_2 = "com.rainforestworld.shop.3.99"; // // public const string buy_gold_2 = "com.rainforestworld.shop.3.99";
// // public const string buy_gold_3 = "com.rainforestworld.shop.19.99"; // // public const string buy_gold_3 = "com.rainforestworld.shop.19.99";
// // public const string buy_gold_4 = "com.rainforestworld.shop.39.99"; // // public const string buy_gold_4 = "com.rainforestworld.shop.39.99";
// public const string remove_ad = "com.rainforestworld.remove.2.99"; // public const string remove_ad = "com.rainforestworld.remove.2.99";
// public const string battle_pass = "com.rainforestworld.pass.9.99"; // public const string battle_pass = "com.rainforestworld.pass.9.99";
// public const string pack_reward = "com.rainforestworld.reward.1.99"; // public const string pack_reward = "com.rainforestworld.reward.1.99";
// public const string fail_pack = "com.rainforestworld.fail.1.99"; // public const string fail_pack = "com.rainforestworld.fail.1.99";
// public const string three_days_gift = "com.rainforestworld.three.1.99"; // public const string three_days_gift = "com.rainforestworld.three.1.99";
// public const string secret_albnums = "com.rainforestworld.secret_albnums.3.99"; // public const string secret_albnums = "com.rainforestworld.secret_albnums.3.99";
// private static readonly Dictionary<string, EventTrackMapping> _trackMappings = new() // private static readonly Dictionary<string, EventTrackMapping> _trackMappings = new()
// { // {
// [pack_reward] = new EventTrackMapping // [pack_reward] = new EventTrackMapping
// { // {
// EventKey = ADEventTrack.Event, // EventKey = ADEventTrack.Event,
// ClickProperty = _ => ADEventTrack.Property.lucky_gift_click, // ClickProperty = _ => ADEventTrack.Property.lucky_gift_click,
// SuccessProperty = _ => ADEventTrack.Property.lucky_gift_receive // SuccessProperty = _ => ADEventTrack.Property.lucky_gift_receive
// }, // },
// [remove_ad] = new EventTrackMapping // [remove_ad] = new EventTrackMapping
// { // {
// EventKey = ADEventTrack.Event, // EventKey = ADEventTrack.Event,
// ClickProperty = _ => ADEventTrack.Property.remove_ad_click, // ClickProperty = _ => ADEventTrack.Property.remove_ad_click,
// SuccessProperty = _ => ADEventTrack.Property.remove_ad_receive // SuccessProperty = _ => ADEventTrack.Property.remove_ad_receive
// }, // },
// [battle_pass] = new EventTrackMapping // [battle_pass] = new EventTrackMapping
// { // {
// EventKey = ADEventTrack.Event, // EventKey = ADEventTrack.Event,
// ClickProperty = _ => ADEventTrack.Property.master_pass_click, // ClickProperty = _ => ADEventTrack.Property.master_pass_click,
// SuccessProperty = _ => ADEventTrack.Property.master_pass_receive // SuccessProperty = _ => ADEventTrack.Property.master_pass_receive
// }, // },
// [buy_one] = new EventTrackMapping // [buy_one] = new EventTrackMapping
// { // {
// EventKey = ADEventTrack.Event, // EventKey = ADEventTrack.Event,
// ClickProperty = _ => ADEventTrack.Property.buy_one_click, // ClickProperty = _ => ADEventTrack.Property.buy_one_click,
// SuccessProperty = _ => ADEventTrack.Property.buy_one_success // SuccessProperty = _ => ADEventTrack.Property.buy_one_success
// }, // },
// ["buy_gold"] = new EventTrackMapping // ["buy_gold"] = new EventTrackMapping
// { // {
// EventKey = ADEventTrack.Event, // EventKey = ADEventTrack.Event,
// ClickProperty = suffix => ADEventTrack.Property.gold_click_ + suffix, // ClickProperty = suffix => ADEventTrack.Property.gold_click_ + suffix,
// SuccessProperty = suffix => ADEventTrack.Property.shop_receive_ + suffix // SuccessProperty = suffix => ADEventTrack.Property.shop_receive_ + suffix
// } // }
// }; // };
public void Exchange(AdExchangeData _data) public void Exchange(AdExchangeData _data)
{ {
if (Time.time - SaveData.rm_time < 5) if (Time.time - SaveData.rm_time < 5)
{ {
GameHelper.ShowTips("click_too_frequent", true); GameHelper.ShowTips("click_too_frequent", true);
return; return;
} }
SaveData.rm_time = Time.time; SaveData.rm_time = Time.time;
int myAdNum = GetLookRewardADNum(); int myAdNum = GetLookRewardADNum();
if (myAdNum >= _data.ad_count) if (myAdNum >= _data.ad_count)
{ {
SetLookRewardADNum(myAdNum - _data.ad_count); SetLookRewardADNum(myAdNum - _data.ad_count);
SendEventClickByName(_data.type, "success"); SendEventClickByName(_data.type, "success");
DOVirtual.DelayedCall(0.1f, () => DOVirtual.DelayedCall(0.1f, () =>
{ {
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _data.type); GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, _data.type);
}); });
} }
else else
{ {
GameHelper.ShowTips("no_ad_count", true); GameHelper.ShowTips("no_ad_count", true);
} }
} }
public void ShowVideoAd(string adName, Action _action) public void ShowVideoAd(string adName, Action _action)
{ {
GameHelper.ShowVideoAd(adName, isSuccess => GameHelper.ShowVideoAd(adName, isSuccess =>
{ {
if (isSuccess) if (isSuccess)
{ {
_action?.Invoke(); _action?.Invoke();
} }
}); });
} }
// private btn_watchAd btn_WatchAd = null; // private btn_watchAd btn_WatchAd = null;
private Dictionary<string, btn_watchAd> btn_WatchAd = new Dictionary<string, btn_watchAd>(); private Dictionary<string, btn_watchAd> btn_WatchAd = new Dictionary<string, btn_watchAd>();
private Dictionary<string, Action> ActionSetText = new Dictionary<string, Action>(); //广告数量的显示 private Dictionary<string, Action> ActionSetText = new Dictionary<string, Action>(); //广告数量的显示
public void SetWatchAd(string key, btn_watchAd _btn, Action action) public void SetWatchAd(string key, btn_watchAd _btn, Action action)
{ {
if (!btn_WatchAd.ContainsKey(key)) if (!btn_WatchAd.ContainsKey(key))
{ {
btn_WatchAd.Add(key, _btn); btn_WatchAd.Add(key, _btn);
} }
else else
{ {
btn_WatchAd[key] = _btn; btn_WatchAd[key] = _btn;
} }
if (!ActionSetText.ContainsKey(key)) if (!ActionSetText.ContainsKey(key))
{ {
ActionSetText.Add(key, action); ActionSetText.Add(key, action);
} }
else else
{ {
ActionSetText[key] = action; ActionSetText[key] = action;
} }
} }
private void removeWatchAd() private void removeWatchAd()
{ {
btn_WatchAd.Clear(); btn_WatchAd.Clear();
} }
private int ad_cool_down = ConfigSystem.GetCommonConf().exchangeCD; private int ad_cool_down = ConfigSystem.GetCommonConf().exchangeCD;
private void updateWatchCD() private void updateWatchCD()
{ {
var lastTimes = SaveData.GetSaveObject()._watch_ad_cd; var lastTimes = SaveData.GetSaveObject()._watch_ad_cd;
foreach (var item in btn_WatchAd) foreach (var item in btn_WatchAd)
{ {
bool is_get = item.Key == PurchasingManager.GetPaySku(PayType.pack_reward) && SaveData.GetSaveObject().is_get_packreward; bool is_get = item.Key == IAPPayManager.PRODUCT_FIRST_GIFT && SaveData.GetSaveObject().is_get_packreward;
bool is_get1 = item.Key == PurchasingManager.GetPaySku(PayType.remove_ad) && SaveData.GetSaveObject().is_get_removead; bool is_get1 = item.Key == IAPPayManager.PRODUCT_REMOVE_ADS && SaveData.GetSaveObject().is_get_removead;
if (is_get || is_get1) if (is_get || is_get1)
{ {
item.Value.enabled = false; item.Value.enabled = false;
} }
else if (GameHelper.GetNowTime() < lastTimes && !checkIsCanReceive(item.Key)) else if (GameHelper.GetNowTime() < lastTimes && !checkIsCanReceive(item.Key))
{ {
item.Value.enabled = false; item.Value.enabled = false;
item.Value.can_buy.selectedIndex = btn_watchAd.Can_buy_cd; item.Value.can_buy.selectedIndex = btn_watchAd.Can_buy_cd;
item.Value.btn_text.text = CommonHelper.TimeFormat(lastTimes - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour); item.Value.btn_text.text = CommonHelper.TimeFormat(lastTimes - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
} }
else else
{ {
// stopAction(); // stopAction();
item.Value.enabled = true; item.Value.enabled = true;
item.Value.can_buy.selectedIndex = btn_watchAd.Can_buy_can; item.Value.can_buy.selectedIndex = btn_watchAd.Can_buy_can;
checkBtnState(item.Value, item.Key); checkBtnState(item.Value, item.Key);
} }
} }
} }
private CommonModel config = ConfigSystem.GetCommonConf(); private CommonModel config = ConfigSystem.GetCommonConf();
private List<Paidgift> packdata = ConfigSystem.GetConfig<Paidgift>(); private List<Paidgift> packdata = ConfigSystem.GetConfig<Paidgift>();
private List<Multigift> threeDayData = ConfigSystem.GetConfig<Multigift>(); private List<Multigift> threeDayData = ConfigSystem.GetConfig<Multigift>();
public int GetCeilingNeedAds(string name) public int GetCeilingNeedAds(string name)
{ {
int needAds = -1; int needAds = -1;
if (name == PurchasingManager.GetPaySku(PayType.buy_one)) if (name == IAPPayManager.PRODUCT_SPACE_BONUS)
{ {
double addspace = config.addspace; double addspace = config.addspace;
needAds = (int)Math.Ceiling(addspace); needAds = (int)Math.Ceiling(addspace);
} }
// else if (name == PurchasingManager.GetPaySku(PayType.buy_one_off)) // else if (name == PurchasingManager.GetPaySku(PayType.buy_one_off))
// { // {
// double addspace1 = config.AddDiscount; // double addspace1 = config.AddDiscount;
// needAds = (int)Math.Ceiling(addspace1); // needAds = (int)Math.Ceiling(addspace1);
// } // }
else if (name == PurchasingManager.GetPaySku(PayType.battle_pass)) else if (name == IAPPayManager.PRODUCT_PASS_BONUS)
{ {
double Passportgift = config.Passportgift; double Passportgift = config.Passportgift;
needAds = (int)Math.Ceiling(Passportgift); needAds = (int)Math.Ceiling(Passportgift);
} }
else if (name == PurchasingManager.GetPaySku(PayType.pack_reward)) else if (name == IAPPayManager.PRODUCT_FIRST_GIFT)
{ {
double Paid_price = packdata[0].Paid_price; double Paid_price = packdata[0].Paid_price;
needAds = (int)Math.Ceiling(Paid_price); needAds = (int)Math.Ceiling(Paid_price);
} }
else if (name == PurchasingManager.GetPaySku(PayType.remove_ad)) else if (name == IAPPayManager.PRODUCT_REMOVE_ADS)
{ {
double move_price = packdata[1].Paid_price; double move_price = packdata[1].Paid_price;
needAds = (int)Math.Ceiling(move_price); needAds = (int)Math.Ceiling(move_price);
} }
else if (name == PurchasingManager.GetPaySku(PayType.three_days_gift)) // else if (name == PurchasingManager.GetPaySku(PayType.three_days_gift))
{ // {
double move_price = threeDayData[2].Paid_price; // double move_price = threeDayData[2].Paid_price;
needAds = (int)Math.Ceiling(move_price); // needAds = (int)Math.Ceiling(move_price);
} // }
else if (name == PurchasingManager.GetPaySku(PayType.buy_gold_1)) else if (name == IAPPayManager.PRODUCT_SHOP_1)
{ {
needAds = (int)Math.Ceiling(getCoinNeedAds(name)); needAds = (int)Math.Ceiling(getCoinNeedAds(name));
} }
else if (name == PurchasingManager.GetPaySku(PayType.buy_gold_2)) else if (name == IAPPayManager.PRODUCT_SHOP_2)
{ {
needAds = (int)Math.Ceiling(getCoinNeedAds(name)); needAds = (int)Math.Ceiling(getCoinNeedAds(name));
} }
else if (name == PurchasingManager.GetPaySku(PayType.buy_gold_3)) else if (name == IAPPayManager.PRODUCT_SHOP_3)
{ {
needAds = (int)Math.Ceiling(getCoinNeedAds(name)); needAds = (int)Math.Ceiling(getCoinNeedAds(name));
} }
else if (name == PurchasingManager.GetPaySku(PayType.buy_gold_4)) else if (name == IAPPayManager.PRODUCT_SHOP_4)
{ {
needAds = (int)Math.Ceiling(getCoinNeedAds(name)); needAds = (int)Math.Ceiling(getCoinNeedAds(name));
} }
else if (name == PurchasingManager.GetPaySku(PayType.buy_gold_5)) else if (name == IAPPayManager.PRODUCT_SHOP_5)
{ {
needAds = (int)Math.Ceiling(getCoinNeedAds(name)); needAds = (int)Math.Ceiling(getCoinNeedAds(name));
} }
return needAds; return needAds;
} }
private List<Paidcoins> coinList = ConfigSystem.GetConfig<Paidcoins>(); private List<Paidcoins> coinList = ConfigSystem.GetConfig<Paidcoins>();
private double getCoinNeedAds(string sku) private double getCoinNeedAds(string sku)
{ {
Paidcoins result = coinList.FirstOrDefault(c => c.SKU == sku); Paidcoins result = coinList.FirstOrDefault(c => c.SKU == sku);
if (result != null) if (result != null)
{ {
return result.Payment_amount; return result.Payment_amount;
} }
return 0; return 0;
} }
private bool checkIsCanReceive(string name) private bool checkIsCanReceive(string name)
{ {
int myAd = GetLookRewardADNum(); int myAd = GetLookRewardADNum();
return myAd >= GetCeilingNeedAds(name); return myAd >= GetCeilingNeedAds(name);
} }
private void checkBtnState(btn_watchAd item, string key) private void checkBtnState(btn_watchAd item, string key)
{ {
// stopAction(); // stopAction();
// foreach (var item in btn_WatchAd) // foreach (var item in btn_WatchAd)
// { // {
item.SetClick(() => { }); item.SetClick(() => { });
if (checkIsCanReceive(key)) if (checkIsCanReceive(key))
{ {
item.buy_state.selectedIndex = btn_watchAd.Buy_state_buy; item.buy_state.selectedIndex = btn_watchAd.Buy_state_buy;
item.SetClick(() => item.SetClick(() =>
{ {
item.enabled = false; item.enabled = false;
AdExchangeData adExchangeData = new AdExchangeData() AdExchangeData adExchangeData = new AdExchangeData()
{ {
type = key, type = key,
ad_count = GetCeilingNeedAds(key) ad_count = GetCeilingNeedAds(key)
}; };
Exchange(adExchangeData); Exchange(adExchangeData);
}); });
} }
else else
{ {
item.buy_state.selectedIndex = btn_watchAd.Buy_state_ad; item.buy_state.selectedIndex = btn_watchAd.Buy_state_ad;
bool is_get = key == PurchasingManager.GetPaySku(PayType.pack_reward) && SaveData.GetSaveObject().is_get_packreward; bool is_get = key == IAPPayManager.PRODUCT_FIRST_GIFT && SaveData.GetSaveObject().is_get_packreward;
bool is_get1 = key == PurchasingManager.GetPaySku(PayType.remove_ad) && SaveData.GetSaveObject().is_get_removead; bool is_get1 = key == IAPPayManager.PRODUCT_REMOVE_ADS && SaveData.GetSaveObject().is_get_removead;
if (is_get || is_get1) if (is_get || is_get1)
{ {
item.enabled = false; item.enabled = false;
item.SetClick(() => { }); item.SetClick(() => { });
} }
else else
{ {
item.SetClick(() => item.SetClick(() =>
{ {
SendEventClickByName(key, "click"); SendEventClickByName(key, "click");
ShowVideoAd("buy_add_one", () => ShowVideoAd("buy_add_one", () =>
{ {
RunAllAction(); RunAllAction();
item.enabled = false; item.enabled = false;
TimerHelper.mEasy.AddTimer(0.1f, () => TimerHelper.mEasy.AddTimer(0.1f, () =>
{ {
var ad_times = Convert.ToInt32(GameHelper.GetNowTime()); var ad_times = Convert.ToInt32(GameHelper.GetNowTime());
SaveData.GetSaveObject()._watch_ad_cd = ad_times + ad_cool_down; SaveData.GetSaveObject()._watch_ad_cd = ad_times + ad_cool_down;
startAction(); startAction();
}); });
}); });
}); });
} }
// } // }
} }
} }
private void RunAllAction() private void RunAllAction()
{ {
foreach (var item in ActionSetText) foreach (var item in ActionSetText)
{ {
item.Value?.Invoke(); item.Value?.Invoke();
} }
} }
private void startAction() private void startAction()
{ {
stopAction(); stopAction();
HallManager.Instance.UpdateSecondEvent += updateWatchCD; HallManager.Instance.UpdateSecondEvent += updateWatchCD;
} }
private void stopAction() private void stopAction()
{ {
HallManager.Instance.UpdateSecondEvent -= updateWatchCD; HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
} }
public int GetLookRewardADNum() public int GetLookRewardADNum()
{ {
return DataMgr.AdWatchCount.Value; return DataMgr.AdWatchCount.Value;
} }
public void SetLookRewardADNum(int nums) public void SetLookRewardADNum(int nums)
{ {
DataMgr.AdWatchCount.Value = nums; DataMgr.AdWatchCount.Value = nums;
} }
public void Start() public void Start()
{ {
startAction(); startAction();
updateWatchCD(); updateWatchCD();
} }
public void Destroy() public void Destroy()
{ {
stopAction(); stopAction();
removeWatchAd(); removeWatchAd();
ActionSetText.Clear(); ActionSetText.Clear();
} }
public void SendEventClickByName(string name, string type) public void SendEventClickByName(string name, string type)
{ {
string eventClickName = ""; string eventClickName = "";
string eventSuccName = ""; string eventSuccName = "";
if (name == PurchasingManager.GetPaySku(PayType.pack_reward)) if (name == IAPPayManager.PRODUCT_FIRST_GIFT)
{ {
eventClickName = ADEventTrack.Property.lucky_gift_click; eventClickName = ADEventTrack.Property.lucky_gift_click;
eventSuccName = ADEventTrack.Property.lucky_gift_receive; eventSuccName = ADEventTrack.Property.lucky_gift_receive;
} }
else if (name == PurchasingManager.GetPaySku(PayType.remove_ad)) else if (name == IAPPayManager.PRODUCT_REMOVE_ADS)
{ {
eventClickName = ADEventTrack.Property.remove_ad_click; eventClickName = ADEventTrack.Property.remove_ad_click;
eventSuccName = ADEventTrack.Property.remove_ad_receive; eventSuccName = ADEventTrack.Property.remove_ad_receive;
} }
else if (name == PurchasingManager.GetPaySku(PayType.battle_pass)) else if (name == IAPPayManager.PRODUCT_PASS_BONUS)
{ {
eventClickName = ADEventTrack.Property.master_pass_click; eventClickName = ADEventTrack.Property.master_pass_click;
eventSuccName = ADEventTrack.Property.master_pass_receive; eventSuccName = ADEventTrack.Property.master_pass_receive;
} }
else if (name == PurchasingManager.GetPaySku(PayType.buy_one)) else if (name == IAPPayManager.PRODUCT_SPACE_BONUS)
{ {
eventClickName = ADEventTrack.Property.buy_one_click; eventClickName = ADEventTrack.Property.buy_one_click;
eventSuccName = ADEventTrack.Property.buy_one_success; eventSuccName = ADEventTrack.Property.buy_one_success;
} }
// else if (name == PurchasingManager.GetPaySku(PayType.buy_one_off)) // else if (name == PurchasingManager.GetPaySku(PayType.buy_one_off))
// { // {
// eventClickName = ADEventTrack.Property.BuyOneOffClick; // eventClickName = ADEventTrack.Property.BuyOneOffClick;
// eventSuccName = ADEventTrack.Property.BuyOneOffSuccess; // eventSuccName = ADEventTrack.Property.BuyOneOffSuccess;
// } // }
else if (name == PurchasingManager.GetPaySku(PayType.three_days_gift)) // else if (name == PurchasingManager.GetPaySku(PayType.three_days_gift))
{ // {
eventClickName = ADEventTrack.Property.three_days_gift_click; // eventClickName = ADEventTrack.Property.three_days_gift_click;
eventSuccName = ADEventTrack.Property.three_days_gift_buy_success; // eventSuccName = ADEventTrack.Property.three_days_gift_buy_success;
} // }
else if (name.StartsWith("buy_gold")) else if (PurchasingManager.ShopProductMap.TryGetValue(name, out var idx))
{ {
int startIndex = "buy_gold".Length; eventClickName = ADEventTrack.Property.gold_click_ + idx;
string suffix = name[startIndex..]; // 截取 "gold" 后的所有字符 eventSuccName = ADEventTrack.Property.shop_receive_ + idx;
eventClickName = ADEventTrack.Property.gold_click_ + suffix; }
eventSuccName = ADEventTrack.Property.shop_receive_ + suffix;
} if (type == "success" && eventSuccName != "")
{
if (type == "success" && eventSuccName != "") TrackKit.SendEvent(ADEventTrack.Event, eventSuccName);
{ }
TrackKit.SendEvent(ADEventTrack.Event, eventSuccName); else if (type == "click" && eventClickName != "")
} {
else if (type == "click" && eventClickName != "") TrackKit.SendEvent(ADEventTrack.Event, eventClickName);
{ }
TrackKit.SendEvent(ADEventTrack.Event, eventClickName);
} }
}
}
} public class EventTrackMapping
{
public class EventTrackMapping public string EventKey
{ {
public string EventKey get;
{ set;
get; }
set;
} public Func<string, string> ClickProperty
{
public Func<string, string> ClickProperty get;
{ set;
get; }
set;
} public Func<string, string> SuccessProperty
{
public Func<string, string> SuccessProperty get;
{ set;
get; }
set; }
} public class AdExchangeData
} {
public class AdExchangeData [JsonProperty("type")]
{ public string type;
[JsonProperty("type")] [JsonProperty("ad_count")]
public string type; public int ad_count;
[JsonProperty("ad_count")] [JsonProperty("shopName")]
public int ad_count; public string shopName;
[JsonProperty("shopName")]
public string shopName; }
public class orderState
} {
public class orderState [JsonProperty("order_id")]
{ public string order_id;
[JsonProperty("order_id")] [JsonProperty("status")]
public string order_id; public int status;
[JsonProperty("status")]
public int status; }
public class orderData
} {
public class orderData [JsonProperty("order_id")]
{ public string order_id;
[JsonProperty("order_id")] [JsonProperty("pay_url")]
public string order_id; public string pay_url;
[JsonProperty("pay_url")]
public string pay_url; }
}
+601
View File
@@ -0,0 +1,601 @@
// ============================================================
// IAPPayManager.cs
// IAP 接入使用(MonoBehaviour
//
// 将此脚本挂到场景中的任意 GameObject 即可运行示例。
// 请将商品 ID 替换为你在 App Store Connect / Google Play Console 中配置的真实 ID。
// ============================================================
using System;
using System.Collections;
using System.Collections.Generic;
using RedHotRoast;
using SDK_IAP;
using UnityEngine;
using UnityEngine.Purchasing;
namespace RedHotRoast
{
public class IAPPayManager : MonoBehaviour
{
// ──────────────────────────────────────────────────────────
// 单例实例
// ──────────────────────────────────────────────────────────
private static IAPPayManager _instance;
public static IAPPayManager Instance
{
get
{
if (_instance == null)
{
_instance = FindObjectOfType<IAPPayManager>();
}
return _instance;
}
}
// ──────────────────────────────────────────────────────────
// 商品 ID 常量(替换为真实 ID)
// ──────────────────────────────────────────────────────────
public static string PRODUCT_FIRST_GIFT = "comtronwingameredhotroastgift199"; //首充 消耗品
public static string PRODUCT_REMOVE_ADS = "comtronwingameredhotroastremove299"; //移除广告 消耗品
public static string PRODUCT_PASS_BONUS = "comtronwingameredhotroastpass999"; //通行证礼包 消耗品
public static string PRODUCT_SPACE_BONUS = "comtronwingameredhotroastspace24999"; //加一格礼包 非消耗品
public static string PRODUCT_SHOP_1 = "comtronwingameredhotroastshop199"; //商店档位1 消耗品
public static string PRODUCT_SHOP_2 = "comtronwingameredhotroastshop399"; //商店档位2 消耗品
public static string PRODUCT_SHOP_3= "comtronwingameredhotroastshop999"; //商店档位3 消耗品
public static string PRODUCT_SHOP_4 = "comtronwingameredhotroastshop1999"; //商店档位4 消耗品
public static string PRODUCT_SHOP_5 = "comtronwingameredhotroastshop3999"; //商店档位5 消耗品
// public static string PRODUCT_THREE_DAY = "comwackyllamagamethreeday399"; //三天礼包 消耗品
public static string PRODUCT_VIP_WEEK = "comtronwingameredhotroastsub999"; // 周订阅 Subscription
public static string PRODUCT_VIP_MONTH = "comtronwingameredhotroastsub2999"; // 月订阅 Subscription
public static string PRODUCT_VIP_YEAR = "comtronwingameredhotroastsub9999"; // 年订阅 Subscription
// ──────────────────────────────────────────────────────────
// 生命周期
// ──────────────────────────────────────────────────────────
private void Awake()
{
// 确保单例唯一性
if (_instance != null && _instance != this)
{
Debug.LogWarning("[IAP IOS] 检测到多个 IAPGoogleManager 实例,销毁重复对象");
Destroy(gameObject);
return;
}
_instance = this;
// 订阅发货事件(持续监听,全局处理发货逻辑)
IAPManager.OnDeliver += HandleDeliver;
IAPManager.OnInitialized += HandleInitialized;
}
private void Start()
{
InitIAP();
//StartCoroutine(Test());
}
//private IEnumerator Test()
//{
// int index = 0;
// while (true)
// {
// yield return new WaitForSeconds(1f);
// Analytics.OnTrackEvent?.Invoke($"test{index}", new Dictionary<string, string>());
// index++;
// }
//}
private void OnDestroy()
{
IAPManager.OnDeliver -= HandleDeliver;
IAPManager.OnInitialized -= HandleInitialized;
IAPManager.Dispose();
}
// ──────────────────────────────────────────────────────────
// 初始化
// ──────────────────────────────────────────────────────────
private void InitIAP()
{
var products = new List<ProductDefine>
{
// 消耗品
ProductDefine.Simple(PRODUCT_FIRST_GIFT, ProductType.Consumable),
ProductDefine.Simple(PRODUCT_REMOVE_ADS, ProductType.Consumable),
ProductDefine.Simple(PRODUCT_PASS_BONUS, ProductType.Consumable),
ProductDefine.Simple(PRODUCT_SHOP_1, ProductType.Consumable),
ProductDefine.Simple(PRODUCT_SHOP_2, ProductType.Consumable),
ProductDefine.Simple(PRODUCT_SHOP_3, ProductType.Consumable),
ProductDefine.Simple(PRODUCT_SHOP_4, ProductType.Consumable),
ProductDefine.Simple(PRODUCT_SHOP_5, ProductType.Consumable),
// ProductDefine.Simple(PRODUCT_THREE_DAY, ProductType.Consumable),
// 非消耗品
ProductDefine.Simple(PRODUCT_SPACE_BONUS, ProductType.NonConsumable),
// 订阅
ProductDefine.Simple(PRODUCT_VIP_WEEK, ProductType.Subscription),
ProductDefine.Simple(PRODUCT_VIP_MONTH, ProductType.Subscription),
ProductDefine.Simple(PRODUCT_VIP_YEAR, ProductType.Subscription),
};
Debug.Log("[IAP IOS] 开始初始化...");
IAPManager.Init(products, OnInitCallback);
}
// Init 完成回调(与 OnInitialized 事件等价,二选一即可)
private void OnInitCallback(bool success)
{
if (success)
{
Debug.Log("[IAP IOS] 初始化成功!");
ShowProductPrices();
}
else
{
Debug.LogError("[IAP IOS] 初始化失败,请检查网络或 App Store / Google Play 配置。");
}
}
// 也可以通过静态事件监听(适合多个 Manager 分散处理)
private void HandleInitialized(bool success)
{
// 此处可做更新 UI 等操作
}
// ──────────────────────────────────────────────────────────
// 显示商品价格(初始化成功后调用)
// ──────────────────────────────────────────────────────────
public void ShowProductPrices()
{
var products = IAPManager.GetProducts();
foreach (var p in products)
{
Debug.Log($"[IAP IOS] 商品: {p.definition.id} | 价格: {p.metadata.localizedPriceString}");
}
}
// ──────────────────────────────────────────────────────────
// 购买
// ──────────────────────────────────────────────────────────
/// <summary>通用购买方法 - 适用于消耗品和非消耗品</summary>
/// <param name="productId">商品ID</param>
/// <param name="productName">商品名称(用于日志)</param>
/// <param name="onSuccess">购买成功后的回调</param>
public void BuyProduct(string productId, string productName, System.Action onSuccess = null)
{
IAPManager.Buy(productId, result =>
{
if (result.success)
{
Debug.Log($"[IAP IOS] 购买成功: {productName} ({result.productId}) | tid={result.transactionId}");
onSuccess?.Invoke();
}
else
{
Debug.LogWarning($"[IAP IOS] 购买失败: {productName} ({result.productId}) - {result.error}");
PurchasingManager.SendEventClickByName(productId, "open");
}
});
}
/// <summary>通用订阅方法 - 适用于订阅类型商品</summary>
/// <param name="productId">商品ID</param>
/// <param name="subscriptionName">订阅名称(用于日志)</param>
/// <param name="onSuccess">订阅成功后的回调</param>
public void SubscribeProduct(string productId, string subscriptionName, System.Action onSuccess = null)
{
IAPManager.Buy(productId, result =>
{
if (result.success)
{
Debug.Log($"[IAP IOS] 订阅成功: {subscriptionName} ({result.productId}) | tid={result.transactionId}");
// ShowSubscriptionInfo();
onSuccess?.Invoke();
}
else
{
Debug.LogWarning($"[IAP IOS] 订阅失败: {subscriptionName} ({result.productId}) - {result.error}");
PurchasingManager.SendEventClickByName(productId, "open");
}
});
}
// ──────────────────────────────────────────────────────────
// 恢复购买(iOS 界面上必须提供此按钮)
// ──────────────────────────────────────────────────────────
public void OnRestoreButtonClicked()
{
// UI 控制:仅在需要时显示此按钮
// if (!IAPManager.NeedShowRestoreButton()) return;
IAPManager.Restore(result =>
{
if (result.success)
{
Debug.Log("[IAP IOS] 恢复购买流程完成(实际恢复内容通过 OnDeliver 发放)");
Debug.Log("[IAP IOS] restore success: " + result.success);
GameHelper.ShowTips("Restore_pur", true);
// SaveData.GetSaveObject().have_slot = success;
// DataMgr.VipLevel.Value = 3;
// DataMgr.VipExpirationTime.Value = ServerClock.GetCurrentServerTime() + 7 * 24 * 60 * 60;
}
else
{
Debug.LogWarning($"[IAP IOS] 恢复购买失败: {result.error}");
GameHelper.ShowTips("recoverable_tips", true);
}
});
}
// ──────────────────────────────────────────────────────────
// 权益检查
// ──────────────────────────────────────────────────────────
/// <summary>通用权益检查方法 - 适用于非消耗品和订阅</summary>
/// <param name="productId">商品ID</param>
/// <param name="productName">商品名称(用于日志)</param>
/// <param name="onResult">检查结果回调</param>
public void CheckEntitlement(string productId, string productName, System.Action<EntitlementStatus> onResult = null)
{
IAPManager.CheckEntitlement(productId, status =>
{
Debug.Log($"[IAP IOS] {productName} 权益状态: {status}");
onResult?.Invoke(status);
});
}
/// <summary>检查加一格礼包权益</summary>
public void CheckSpaceBonusEntitlement()
{
CheckEntitlement(PRODUCT_SPACE_BONUS, "加一格礼包", state =>
{
if (state == EntitlementStatus.FullyEntitled)
{
// 激活加一格权限
}
});
}
/// <summary>检查VIP订阅权益</summary>
public void CheckVipEntitlement()
{
CheckEntitlement(PRODUCT_VIP_MONTH, "VIP月卡", status =>
{
if (status == EntitlementStatus.FullyEntitled)
{
// 激活VIP权限
}
});
}
// ──────────────────────────────────────────────────────────
// 订阅信息查询
// ──────────────────────────────────────────────────────────
/// <summary>显示指定商品的订阅信息</summary>
/// <param name="productId">商品ID</param>
public void ShowSubscriptionInfo(string productId)
{
var info = IAPManager.GetSubscriptionInfo(productId);
Debug.Log($"[IAP IOS] VIP 订阅状态 ({productId}):");
Debug.Log($" isSubscribed = {info.isSubscribed}");
Debug.Log($" isExpired = {info.isExpired}");
Debug.Log($" expireDate = {info.expireDate}");
Debug.Log($" isAutoRenewing= {info.isAutoRenewing}");
if (info.isSubscribed && !info.isExpired)
{
int vipLevel = GetVipLevelByProductId(productId);
if (vipLevel > 0)
{
DataMgr.VipLevel.Value = vipLevel;
Debug.Log($"[IAP IOS] 设置 VIP 等级: {vipLevel}");
}
if (info.expireDate.Year > 1970 && info.expireDate.Year < 10000)
{
var expireTimestamp = ((DateTimeOffset)info.expireDate).ToUnixTimeSeconds();
Debug.Log($"Expire timestamp: {expireTimestamp}");
DataMgr.VipExpirationTime.Value = Math.Max(DataMgr.VipExpirationTime.Value, expireTimestamp);
}
else
{
Debug.LogWarning($"[IAP IOS] 无效的到期时间: {info.expireDate}");
}
}
else
{
Debug.Log($"[IAP IOS] 用户未订阅或订阅已过期");
}
}
/// <summary>根据商品ID获取VIP等级</summary>
/// <param name="productId">商品ID</param>
/// <returns>VIP等级:周订阅=1,月订阅=2,年订阅=3,其他=0</returns>
private int GetVipLevelByProductId(string productId)
{
if (productId == PRODUCT_VIP_WEEK)
return 1;
else if (productId == PRODUCT_VIP_MONTH)
return 2;
else if (productId == PRODUCT_VIP_YEAR)
return 3;
return 0;
}
// ──────────────────────────────────────────────────────────
// 全局发货处理(OnDeliver 事件接收)
// ──────────────────────────────────────────────────────────
/// <summary>
/// 统一发货处理入口。
/// 无论是新购买、补单、还是恢复购买,都会触发此方法。
/// ⚠️ 幂等保护已由 DeliverGuardLite 处理,此处无需再判重。
/// </summary>
private void HandleDeliver(string productId)
{
Debug.Log($"[IAP IOS] 收到统一发货通知: {productId}");
if (!IsValidProduct(productId))
{
Debug.LogWarning($"[IAP IOS] 非法商品ID,拒绝发货: {productId}");
return;
}
if (productId == PRODUCT_VIP_WEEK || productId == PRODUCT_VIP_MONTH || productId == PRODUCT_VIP_YEAR)
{
// 订阅商品:需要先获取有效的订阅信息,成功后才会分发支付成功消息
StartCoroutine(DelayedGetSubscriptionInfo(productId));
}
else
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
// 非订阅商品(消耗品):直接发货
Debug.Log($"[IAP IOS] 发货通知: {productId}");
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, productId);
PurchasingManager.SendEventClickByName(productId, "open");
PurchasingManager.SendEventClickByName(productId, "success");
}
}
private IEnumerator DelayedGetSubscriptionInfo(string productId)
{
Debug.Log($"[IAP IOS] 开始获取订阅信息: {productId}");
// 先尝试立即获取一次
var immediateInfo = IAPManager.GetSubscriptionInfo(productId);
// 检查是否是无效数据
bool isInvalid = immediateInfo.expireDate == default(DateTime) ||
(immediateInfo.expireDate.Year == 1 && !immediateInfo.isSubscribed);
if (!isInvalid && immediateInfo.isSubscribed)
{
// 立即获取到了有效数据,直接处理
bool success = ProcessSubscriptionInfo(immediateInfo, productId);
if (success)
{
DispatchPaySuccess(productId);
}
yield break;
}
// 无效数据,开始重试
Debug.Log($"[IAP IOS] 订阅信息未就绪,开始重试...");
int maxRetries = 5;
float waitTime = 1.5f;
for (int i = 0; i < maxRetries; i++)
{
yield return new WaitForSeconds(waitTime); // 每次等待0.5秒
var info = IAPManager.GetSubscriptionInfo(productId);
if (info.isSubscribed && !info.isExpired && info.expireDate.Year > 1970)
{
Debug.Log($"[IAP IOS] 订阅信息获取成功 (重试 {i + 1} 次)");
bool success = ProcessSubscriptionInfo(info, productId);
if (success)
{
DispatchPaySuccess(productId);
}
yield break;
}
Debug.Log($"[IAP IOS] 第 {i + 1} 次重试: isSubscribed={info.isSubscribed}, isExpired={info.isExpired}, expireDate={info.expireDate}");
}
// 所有重试都失败了,使用降级方案
Debug.LogError($"[IAP IOS] 无法获取订阅信息,使用降级方案");
bool fallbackSuccess = ProcessFallbackSubscription(productId);
if (fallbackSuccess)
{
DispatchPaySuccess(productId);
}
else
{
// 降级也失败了,上报错误,不分发支付成功
Debug.LogError($"[IAP IOS] 降级方案也失败,支付成功消息将不分发,请检查配置");
PurchasingManager.SendEventClickByName(productId, "open");
// 可选:向用户显示错误提示
}
}
/// <summary>
/// 处理订阅信息,设置VIP等级和过期时间
/// </summary>
/// <returns>是否设置成功</returns>
private bool ProcessSubscriptionInfo(SubscriptionInfoLite info, string productId)
{
try
{
Debug.Log($"[IAP IOS] VIP 订阅状态 ({productId}):");
Debug.Log($" isSubscribed = {info.isSubscribed}");
Debug.Log($" isExpired = {info.isExpired}");
Debug.Log($" expireDate = {info.expireDate}");
Debug.Log($" isAutoRenewing= {info.isAutoRenewing}");
// 获取VIP等级
int vipLevel = GetVipLevelByProductId(productId);
if (vipLevel <= 0)
{
Debug.LogError($"[IAP IOS] 无法获取VIP等级,商品ID: {productId}");
return false;
}
// 获取过期时间戳
long expireTimestamp = 0;
if (info.expireDate.Year > 1970 && info.expireDate.Year < 10000)
{
expireTimestamp = ((DateTimeOffset)info.expireDate).ToUnixTimeSeconds();
}
else
{
Debug.LogWarning($"[IAP IOS] 无效的到期时间: {info.expireDate},使用预估时间");
expireTimestamp = GetEstimatedExpireTimestamp(productId);
}
if (expireTimestamp <= 0)
{
Debug.LogError($"[IAP IOS] 无法获取有效的过期时间戳");
return false;
}
// 保存数据(使用前后对比,确保设置成功)
int oldVipLevel = DataMgr.VipLevel.Value;
long oldExpireTime = DataMgr.VipExpirationTime.Value;
DataMgr.VipLevel.Value = Math.Max(DataMgr.VipLevel.Value, vipLevel);
DataMgr.VipExpirationTime.Value = Math.Max(DataMgr.VipExpirationTime.Value, expireTimestamp);
// 验证设置是否成功
bool vipLevelSuccess = DataMgr.VipLevel.Value >= vipLevel;
bool expireTimeSuccess = DataMgr.VipExpirationTime.Value >= expireTimestamp;
if (vipLevelSuccess && expireTimeSuccess)
{
Debug.Log($"[IAP IOS] VIP设置成功 - 等级: {vipLevel} (原:{oldVipLevel}), 过期时间: {expireTimestamp} (原:{oldExpireTime})");
// 可选:触发VIP状态更新事件
return true;
}
else
{
Debug.LogError($"[IAP IOS] VIP设置失败 - 等级设置: {vipLevelSuccess}, 过期时间设置: {expireTimeSuccess}");
return false;
}
}
catch (Exception e)
{
Debug.LogError($"[IAP IOS] 处理订阅信息时发生异常: {e.Message}\n{e.StackTrace}");
return false;
}
}
/// <summary>
/// 降级方案:当无法从商店获取订阅信息时,根据商品类型估算VIP信息
/// </summary>
private bool ProcessFallbackSubscription(string productId)
{
try
{
Debug.LogWarning($"[IAP IOS] 执行降级方案: {productId}");
int vipLevel = GetVipLevelByProductId(productId);
if (vipLevel <= 0)
{
Debug.LogError($"[IAP IOS] 降级方案失败 - 无法获取VIP等级");
return false;
}
long expireTimestamp = GetEstimatedExpireTimestamp(productId);
if (expireTimestamp <= 0)
{
Debug.LogError($"[IAP IOS] 降级方案失败 - 无法获取预估过期时间");
return false;
}
// 设置VIP信息
DataMgr.VipLevel.Value = Math.Max(DataMgr.VipLevel.Value, vipLevel);
DataMgr.VipExpirationTime.Value = Math.Max(DataMgr.VipExpirationTime.Value, expireTimestamp);
Debug.Log($"[IAP IOS] 降级方案成功 - 等级: {vipLevel}, 过期时间: {expireTimestamp}");
return true;
}
catch (Exception e)
{
Debug.LogError($"[IAP IOS] 降级方案异常: {e.Message}");
return false;
}
}
/// <summary>
/// 获取预估的过期时间戳
/// </summary>
private long GetEstimatedExpireTimestamp(string productId)
{
TimeSpan duration;
if (productId == PRODUCT_VIP_WEEK)
{
duration = TimeSpan.FromDays(7);
}
else if (productId == PRODUCT_VIP_MONTH)
{
duration = TimeSpan.FromDays(30);
}
else if (productId == PRODUCT_VIP_YEAR)
{
duration = TimeSpan.FromDays(365);
}
else
{
duration = TimeSpan.FromDays(30);
}
var expireDate = DateTime.UtcNow.Add(duration);
return ((DateTimeOffset)expireDate).ToUnixTimeSeconds();
}
/// <summary>
/// 分发支付成功消息(统一出口)
/// </summary>
private void DispatchPaySuccess(string productId)
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
Debug.Log($"[IAP IOS] 支付成功并完成发货: {productId}");
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, productId);
PurchasingManager.SendEventClickByName(productId, "open");
PurchasingManager.SendEventClickByName(productId, "success");
}
/// <summary>验证商品ID是否为已定义的有效商品</summary>
/// <param name="productId">商品ID</param>
/// <returns>是否为有效商品</returns>
private bool IsValidProduct(string productId)
{
return productId == PRODUCT_FIRST_GIFT ||
productId == PRODUCT_REMOVE_ADS ||
productId == PRODUCT_PASS_BONUS ||
productId == PRODUCT_SPACE_BONUS ||
productId == PRODUCT_SHOP_1 ||
productId == PRODUCT_SHOP_2 ||
productId == PRODUCT_SHOP_3 ||
productId == PRODUCT_SHOP_4 ||
productId == PRODUCT_SHOP_5 ||
// productId == PRODUCT_THREE_DAY ||
productId == PRODUCT_VIP_WEEK ||
productId == PRODUCT_VIP_MONTH ||
productId == PRODUCT_VIP_YEAR;
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f4b5c2a375fb4610a0417b408c252104
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+70 -64
View File
@@ -97,15 +97,17 @@ public class MaxPayManager
// Debug.Log("barry ios pay"); // Debug.Log("barry ios pay");
// 调用官方支付逻辑 // 调用官方支付逻辑
isIOSPay = true; isIOSPay = true;
// var appleData = new ApplePayData #if UNITY_IOS
// { var appleData = new ApplePayData
// sku = _data.sku, {
// amount = _data.amount, sku = _data.sku,
// currency = _data.currency, amount = _data.amount,
// shopName = _data.shopName, currency = _data.currency,
// type = _data.type shopName = _data.shopName,
// }; type = _data.type
// PurchasingManager.Purchase(appleData); };
PurchasingManager.Purchase(appleData);
#endif
} }
else else
{ {
@@ -128,52 +130,47 @@ public class MaxPayManager
ApplePayClass paydata = data_; ApplePayClass paydata = data_;
SaveData.pay_time = Time.time; SaveData.pay_time = Time.time;
if (data_.sku == PurchasingManager.GetPaySku(PayType.buy_one)) if (data_.sku == IAPPayManager.PRODUCT_SPACE_BONUS)
{ {
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.buy_one_click); TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.buy_one_click);
} }
else if (data_.sku == PurchasingManager.GetPaySku(PayType.buy_one_off)) // else if (data_.sku == PurchasingManager.GetPaySku(PayType.buy_one_off))
{ // {
// TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.BuyOneOffClick); // // TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.BuyOneOffClick);
} // }
else if (data_.sku != null && data_.sku == PurchasingManager.GetPaySku(PayType.remove_ad)) else if (data_.sku != null && data_.sku == IAPPayManager.PRODUCT_REMOVE_ADS)
{ {
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.remove_ad_click); TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.remove_ad_click);
} }
else if (data_.sku == PurchasingManager.GetPaySku(PayType.pack_reward)) else if (data_.sku == IAPPayManager.PRODUCT_FIRST_GIFT)
{ {
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.lucky_gift_click); TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.lucky_gift_click);
} }
else if (data_.shopName != null && data_.shopName.StartsWith("buy_gold")) else if (data_.sku != null && PurchasingManager.ShopProductMap.TryGetValue(data_.sku, out var idx))
{ {
int startIndex = "buy_gold".Length; TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.gold_click_ + idx);
string suffix = paydata.shopName[startIndex..]; // 截取 "gold" 后的所有字符
string eventClickName = $"gold_click_{suffix}";
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.gold_click_ + suffix);
} }
else if (data_.sku.StartsWith("secret_albnums")) else if (data_.sku.StartsWith("secret_albnums"))
{ {
string suffix = data_.sku["secret_albnums".Length..]; string suffix = data_.sku["secret_albnums".Length..];
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.secret_albums_click_ + suffix); TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.secret_albums_click_ + suffix);
} }
else if (data_.sku.StartsWith("vip_club")) else if (data_.sku != null && PurchasingManager.VipProductMap.TryGetValue(data_.sku, out var vipIdx))
{ {
string suffix = data_.sku["vip_club".Length..]; TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.vip_click_ + vipIdx);
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.vip_click_ + suffix);
} }
else if (data_.sku == PurchasingManager.GetPaySku(PayType.battle_pass)) else if (data_.sku == IAPPayManager.PRODUCT_PASS_BONUS)
{ {
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.master_pass_click); TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.master_pass_click);
} }
else if (data_.sku == PurchasingManager.GetPaySku(PayType.fail_pack)) // else if (data_.sku == PurchasingManager.GetPaySku(PayType.fail_pack))
{ // {
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.fail_click); // TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.fail_click);
} // }
else if (data_.sku == PurchasingManager.GetPaySku(PayType.three_days_gift)) // else if (data_.sku == PurchasingManager.GetPaySku(PayType.three_days_gift))
{ // {
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.three_days_gift_click); // TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.three_days_gift_click);
} // }
PayerData requestData = new PayerData() PayerData requestData = new PayerData()
{ {
@@ -348,7 +345,7 @@ public class MaxPayManager
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close); UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
bool isOpen = false; bool isOpen = false;
if (paydata.sku == PurchasingManager.GetPaySku(PayType.buy_one)) if (paydata.sku == IAPPayManager.PRODUCT_SPACE_BONUS)
{ {
isOpen = HandleSku(paydata.sku, UIConst.AddViewUI, ADEventTrack.Property.buy_one_success); isOpen = HandleSku(paydata.sku, UIConst.AddViewUI, ADEventTrack.Property.buy_one_success);
} }
@@ -356,35 +353,33 @@ public class MaxPayManager
// { // {
// isOpen = HandleSku(paydata.sku, UIConst.AddViewUI, ADEventTrack.Property.BuyOneOffSuccess); // isOpen = HandleSku(paydata.sku, UIConst.AddViewUI, ADEventTrack.Property.BuyOneOffSuccess);
// } // }
else if (paydata.sku != null && paydata.sku == PurchasingManager.GetPaySku(PayType.remove_ad)) else if (paydata.sku != null && paydata.sku == IAPPayManager.PRODUCT_REMOVE_ADS)
{ {
isOpen = HandleSku(paydata.sku, UIConst.PackrewardUI, ADEventTrack.Property.remove_ad_receive); isOpen = HandleSku(paydata.sku, UIConst.PackrewardUI, ADEventTrack.Property.remove_ad_receive);
} }
else if (paydata.sku == PurchasingManager.GetPaySku(PayType.pack_reward)) else if (paydata.sku == IAPPayManager.PRODUCT_FIRST_GIFT)
{ {
isOpen = HandleSku(paydata.sku, UIConst.PackrewardUI, ADEventTrack.Property.lucky_gift_receive); isOpen = HandleSku(paydata.sku, UIConst.PackrewardUI, ADEventTrack.Property.lucky_gift_receive);
} }
else if (paydata.shopName != null && paydata.shopName.StartsWith("buy_gold")) else if (paydata.sku != null && PurchasingManager.ShopProductMap.TryGetValue(paydata.sku, out var idx))
{ {
int startIndex = "buy_gold".Length; string eventSuccessName = ADEventTrack.Property.shop_receive_ + idx;
string suffix = paydata.shopName[startIndex..]; // 截取 "gold" 后的所有字符
string eventSuccessName = ADEventTrack.Property.shop_receive_ + suffix;
isOpen = HandleSku(paydata.sku, UIConst.BuygoldUI, eventSuccessName); isOpen = HandleSku(paydata.sku, UIConst.BuygoldUI, eventSuccessName);
} }
else if (paydata.sku == PurchasingManager.GetPaySku(PayType.battle_pass)) else if (paydata.sku == IAPPayManager.PRODUCT_PASS_BONUS)
{ {
isOpen = HandleSku(paydata.sku, UIConst.PassViewUI, ADEventTrack.Property.master_pass_receive); isOpen = HandleSku(paydata.sku, UIConst.PassViewUI, ADEventTrack.Property.master_pass_receive);
} }
else if (paydata.sku == PurchasingManager.GetPaySku(PayType.fail_pack)) // else if (paydata.sku == PurchasingManager.GetPaySku(PayType.fail_pack))
{ // {
isOpen = HandleSku(paydata.sku, UIConst.PackrewardUI, ADEventTrack.Property.fail_buy_success); // isOpen = HandleSku(paydata.sku, UIConst.PackrewardUI, ADEventTrack.Property.fail_buy_success);
} // }
else if (paydata.sku == PurchasingManager.GetPaySku(PayType.three_days_gift)) // else if (paydata.sku == PurchasingManager.GetPaySku(PayType.three_days_gift))
{ // {
isOpen = HandleSku(paydata.sku, UIConst.ThreeDaysGiftUI, ADEventTrack.Property.three_days_gift_buy_success); // isOpen = HandleSku(paydata.sku, UIConst.ThreeDaysGiftUI, ADEventTrack.Property.three_days_gift_buy_success);
} // }
else if (paydata.sku.StartsWith("secret_albnums")) else if (paydata.sku.StartsWith("secret_albnums"))
{ {
int startIndex = "secret_albnums".Length; int startIndex = "secret_albnums".Length;
@@ -393,11 +388,9 @@ public class MaxPayManager
isOpen = HandleSku(paydata.sku, UIConst.SecretAlbumsNextUI, eventSuccessName); isOpen = HandleSku(paydata.sku, UIConst.SecretAlbumsNextUI, eventSuccessName);
} }
else if (paydata.shopName != null && paydata.shopName.StartsWith("vip_club")) else if (paydata.sku != null && PurchasingManager.VipProductMap.TryGetValue(paydata.sku, out var vipIdx))
{ {
int startIndex = "vip_club".Length; string eventSuccessName = ADEventTrack.Property.vip_success_ + vipIdx;
string suffix = paydata.shopName[startIndex..]; // 截取 "vip_club" 后的所有字符
string eventSuccessName = ADEventTrack.Property.vip_success_ + suffix;
isOpen = HandleSku(paydata.sku, UIConst.VipClubViewUI, eventSuccessName); isOpen = HandleSku(paydata.sku, UIConst.VipClubViewUI, eventSuccessName);
} }
else else
@@ -408,16 +401,16 @@ public class MaxPayManager
} }
string sku = ""; string sku = "";
if (paydata.sku.Contains("shop") || paydata.sku.Contains("sub")) // if (paydata.sku.Contains("shop") || paydata.sku.Contains("sub"))
{ // {
sku = paydata.shopName; // sku = paydata.shopName;
} // }
else // else
{ // {
sku = paydata.sku; sku = paydata.sku;
} // }
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, sku); GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, sku);
DOVirtual.DelayedCall(1, () => DOVirtual.DelayedCall(1, () =>
{ {
@@ -466,7 +459,7 @@ public class MaxPayManager
{ {
sku = paydata.sku; sku = paydata.sku;
} }
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, paydata.sku); GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, paydata.sku);
}); });
} }
} }
@@ -567,18 +560,27 @@ public class MaxPayManager
public class maxOrder public class maxOrder
{ {
[JsonProperty("order_id")]
public string order_id; public string order_id;
} }
public class ApplePayClass public class ApplePayClass
{ {
[JsonProperty("innerOrderId")]
public string innerOrderId; public string innerOrderId;
[JsonProperty("transactionId")]
public string transactionId; public string transactionId;
[JsonProperty("amount")]
public int amount; public int amount;
[JsonProperty("sku")]
public string sku; public string sku;
[JsonProperty("currency")]
public string currency = "USD"; public string currency = "USD";
[JsonProperty("status")]
public int status; public int status;
[JsonProperty("shopName")]
public string shopName; public string shopName;
[JsonProperty("type")]
public string type; public string type;
} }
@@ -594,9 +596,13 @@ public class ApplePayClass
public class PayerData public class PayerData
{ {
[JsonProperty("name")]
public string name; public string name;
[JsonProperty("tel")]
public string tel; public string tel;
[JsonProperty("email")]
public string email; public string email;
[JsonProperty("amount")]
public int amount; public int amount;
} }
+158 -158
View File
@@ -1,158 +1,158 @@
using System; using System;
using FGUI.ZM_Common_01; using FGUI.ZM_Common_01;
using SGModule.NetKit; using SGModule.NetKit;
using Spine.Unity; using Spine.Unity;
namespace RedHotRoast namespace RedHotRoast
{ {
public class AddViewUI : BaseUI public class AddViewUI : BaseUI
{ {
private AddViewUICtrl ctrl; private AddViewUICtrl ctrl;
private AddViewModel model; private AddViewModel model;
private FGUI.ZM_AddCell_12.com_addView ui; private FGUI.ZM_AddCell_12.com_addView ui;
public int ad_cool_down = 120; public int ad_cool_down = 120;
public btn_watchAd btn_WatchAd; public btn_watchAd btn_WatchAd;
public AddViewUI(AddViewUICtrl ctrl) : base(ctrl) public AddViewUI(AddViewUICtrl ctrl) : base(ctrl)
{ {
uiName = UIConst.AddViewUI; uiName = UIConst.AddViewUI;
this.ctrl = ctrl; this.ctrl = ctrl;
} }
protected override void SetUIInfo(UIInfo uiInfo) protected override void SetUIInfo(UIInfo uiInfo)
{ {
uiInfo.packageName = "ZM_AddCell_12"; uiInfo.packageName = "ZM_AddCell_12";
uiInfo.assetName = "com_addView"; uiInfo.assetName = "com_addView";
uiInfo.layerType = UILayerType.Popup; uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false; uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false; uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true; uiInfo.isNeedUIMask = true;
} }
#region #region
protected override void OnInit() protected override void OnInit()
{ {
//model = ModuleManager.Instance.GetModel(ModelConst.AddViewModel) as AddViewModel; //model = ModuleManager.Instance.GetModel(ModelConst.AddViewModel) as AddViewModel;
} }
protected override void OnClose() protected override void OnClose()
{ {
GameHelper.showGameUI = true; GameHelper.showGameUI = true;
// HallManager.Instance.UpdateSecondEvent -= updateWatchCD; // HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
if (GameHelper.IsAdModelOfPay()) if (GameHelper.IsAdModelOfPay())
{ {
AdExchangeManager.Instance.Destroy(); AdExchangeManager.Instance.Destroy();
} }
if (need_call) GameHelper.CallShowTurn(); if (need_call) GameHelper.CallShowTurn();
} }
private bool need_call; private bool need_call;
protected override void OnBind() protected override void OnBind()
{ {
ui = baseUI as FGUI.ZM_AddCell_12.com_addView; ui = baseUI as FGUI.ZM_AddCell_12.com_addView;
} }
protected override void OnOpenBefore(object args) protected override void OnOpenBefore(object args)
{ {
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.buy_one_show); TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.buy_one_show);
if (args != null) need_call = (bool)args; if (args != null) need_call = (bool)args;
// ad_cool_down = ConfigSystem.GetConfig<CommonModel>().exchangeCD; // ad_cool_down = ConfigSystem.GetConfig<CommonModel>().exchangeCD;
// btn_WatchAd = ui.btn_watch as btn_watchAd; // btn_WatchAd = ui.btn_watch as btn_watchAd;
if (GameHelper.IsAdModelOfPay()) if (GameHelper.IsAdModelOfPay())
{ {
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.buy_one), ui.btn_watch as btn_watchAd, SetTextString); AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_SPACE_BONUS, ui.btn_watch as btn_watchAd, SetTextString);
ui.pay_type.selectedIndex = 0; ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.Start(); AdExchangeManager.Instance.Start();
SetTextString(); SetTextString();
} }
else else
{ {
ui.pay_type.selectedIndex = 1; ui.pay_type.selectedIndex = 1;
decimal price = (decimal)GameHelper.GetCommonModel().addspace2; decimal price = (decimal)GameHelper.GetCommonModel().addspace2;
ui.btn_max_pay.title = GameHelper.getPrice(price); ui.btn_max_pay.title = GameHelper.getPrice(price);
ui.btn_max_pay.SetClick(() => ui.btn_max_pay.SetClick(() =>
{ {
ApplePayClass maxPayData = new ApplePayClass ApplePayClass maxPayData = new ApplePayClass
{ {
amount = (int)Math.Round(price * 100), amount = (int)Math.Round(price * 100),
sku =PurchasingManager.GetPaySku(PayType.buy_one), sku =IAPPayManager.PRODUCT_SPACE_BONUS,
currency = "USD" currency = "USD"
}; };
MaxPayManager.Instance.Buy(maxPayData); MaxPayManager.Instance.Buy(maxPayData);
}); });
} }
InitView(); InitView();
} }
protected override void OnOpen(object args) protected override void OnOpen(object args)
{ {
} }
protected override void OnHide() protected override void OnHide()
{ {
} }
protected override void OnDisplay(object args) protected override void OnDisplay(object args)
{ {
} }
#endregion #endregion
#region #region
protected override void AddListener() protected override void AddListener()
{ {
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success); GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
} }
protected override void RemoveListener() protected override void RemoveListener()
{ {
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success); GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
} }
#endregion #endregion
void pay_success(object str) void pay_success(object str)
{ {
string type = (string)str; string type = (string)str;
if (type == PurchasingManager.GetPaySku(PayType.buy_one)) if (type == IAPPayManager.PRODUCT_SPACE_BONUS)
{ {
CtrlCloseUI(); CtrlCloseUI();
} }
} }
private Action closeCallback = null; private Action closeCallback = null;
//初始化页面逻辑 //初始化页面逻辑
private void InitView() private void InitView()
{ {
// var add = FXManager.Instance.SetFx<SkeletonAnimation>(ui.anim_bg, Fx_Type.fx_add_box, ref closeCallback); // var add = FXManager.Instance.SetFx<SkeletonAnimation>(ui.anim_bg, Fx_Type.fx_add_box, ref closeCallback);
// add.state.SetAnimation(0, "animation", true); // add.state.SetAnimation(0, "animation", true);
// //
ui.btn_close.SetClick(() => ui.btn_close.SetClick(() =>
{ {
CtrlCloseUI(); CtrlCloseUI();
}); });
// HallManager.Instance.UpdateSecondEvent += updateWatchCD; // HallManager.Instance.UpdateSecondEvent += updateWatchCD;
// updateWatchCD(); // updateWatchCD();
// checkBtnState(); // checkBtnState();
} }
public void SetTextString() public void SetTextString()
{ {
var need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.buy_one)); var need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_SPACE_BONUS);
var myAd = AdExchangeManager.Instance.GetLookRewardADNum(); var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.text_watch_ad.SetVar("needNum", need.ToString()).FlushVars(); ui.text_watch_ad.SetVar("needNum", need.ToString()).FlushVars();
ui.tips.SetVar("needAds", need.ToString()).FlushVars(); ui.tips.SetVar("needAds", need.ToString()).FlushVars();
ui.tips.SetVar("myAds", myAd.ToString()).FlushVars(); ui.tips.SetVar("myAds", myAd.ToString()).FlushVars();
} }
} }
} }
+221 -221
View File
@@ -1,221 +1,221 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using DG.Tweening; using DG.Tweening;
using FGUI.ZM_Common_01; using FGUI.ZM_Common_01;
using Spine.Unity; using Spine.Unity;
using UnityEngine; using UnityEngine;
using Random = UnityEngine.Random; using Random = UnityEngine.Random;
namespace RedHotRoast namespace RedHotRoast
{ {
public class BroadcastUI : BaseUI public class BroadcastUI : BaseUI
{ {
private BroadcastUICtrl ctrl; private BroadcastUICtrl ctrl;
private BroadcastModel model; private BroadcastModel model;
private com_broadcast1 ui; private com_broadcast1 ui;
public BroadcastUI(BroadcastUICtrl ctrl) : base(ctrl) public BroadcastUI(BroadcastUICtrl ctrl) : base(ctrl)
{ {
uiName = UIConst.BroadcastUI; uiName = UIConst.BroadcastUI;
this.ctrl = ctrl; this.ctrl = ctrl;
} }
protected override void SetUIInfo(UIInfo uiInfo) protected override void SetUIInfo(UIInfo uiInfo)
{ {
uiInfo.packageName = "ZM_Common_01"; uiInfo.packageName = "ZM_Common_01";
uiInfo.assetName = "com_broadcast1"; uiInfo.assetName = "com_broadcast1";
uiInfo.layerType = UILayerType.Highest; uiInfo.layerType = UILayerType.Highest;
uiInfo.isNeedOpenAnim = false; uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false; uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = false; uiInfo.isNeedUIMask = false;
} }
#region #region
protected override void OnInit() protected override void OnInit()
{ {
} }
protected override void OnClose() protected override void OnClose()
{ {
} }
protected override void OnBind() protected override void OnBind()
{ {
ui = baseUI as com_broadcast1; ui = baseUI as com_broadcast1;
} }
protected override void OnOpenBefore(object args) protected override void OnOpenBefore(object args)
{ {
InitView(); InitView();
//ui.y = 241; //ui.y = 241;
if (UIManager.Instance.IsExistUI(UIConst.RainPlayUI)) if (UIManager.Instance.IsExistUI(UIConst.RainPlayUI))
{ {
Settop(); Settop();
} }
else else
{ {
Setbuttom(); Setbuttom();
} }
// ui.visible = false; // ui.visible = false;
// if (Screen.safeArea.y != 0) // if (Screen.safeArea.y != 0)
// {//刘海屏 // {//刘海屏
// ui.y += Screen.safeArea.y; // ui.y += Screen.safeArea.y;
// } // }
text_ui = ui.broad_cast_text; text_ui = ui.broad_cast_text;
text_ui.btn_broad.SetClick(OpenRecord); text_ui.btn_broad.SetClick(OpenRecord);
if (ConfigSystem.GetConfig<SubscribePodcast>() == null) return; if (ConfigSystem.GetConfig<SubscribePodcast>() == null) return;
config_name_list = SubscribePodcastModel.config_name_list; config_name_list = SubscribePodcastModel.config_name_list;
config_vip_level_list = SubscribePodcastModel.config_vip_level_list; config_vip_level_list = SubscribePodcastModel.config_vip_level_list;
GameDispatcher.Instance.AddListener(GameMsg.hideBroadCast, hideEvent); GameDispatcher.Instance.AddListener(GameMsg.hideBroadCast, hideEvent);
GameDispatcher.Instance.AddListener(GameMsg.showBroadCast, showEvent); GameDispatcher.Instance.AddListener(GameMsg.showBroadCast, showEvent);
UICtrlDispatcher.Instance.AddListener(UICtrlMsg.MainUI_Open, Setbuttom); UICtrlDispatcher.Instance.AddListener(UICtrlMsg.MainUI_Open, Setbuttom);
UICtrlDispatcher.Instance.AddListener(UICtrlMsg.RainPlayUI_Open, Settop); UICtrlDispatcher.Instance.AddListener(UICtrlMsg.RainPlayUI_Open, Settop);
} }
protected override void OnOpen(object args) protected override void OnOpen(object args)
{ {
} }
protected override void OnHide() protected override void OnHide()
{ {
} }
protected override void OnDisplay(object args) protected override void OnDisplay(object args)
{ {
} }
#endregion #endregion
#region #region
protected override void AddListener() protected override void AddListener()
{ {
} }
protected override void RemoveListener() protected override void RemoveListener()
{ {
} }
#endregion #endregion
private int time_count = 11; private int time_count = 11;
private com_broadcast_text1 text_ui; private com_broadcast_text1 text_ui;
private List<string> config_name_list; private List<string> config_name_list;
private List<string> config_vip_level_list; private List<string> config_vip_level_list;
private bool main_ui_show = true; private bool main_ui_show = true;
//初始化页面逻辑 //初始化页面逻辑
private Action closeCallback; private Action closeCallback;
private void InitView() private void InitView()
{ {
HallManager.Instance.UpdateSecondEvent += timeEvent; HallManager.Instance.UpdateSecondEvent += timeEvent;
var sk = FXManager.Instance.SetFx<SkeletonAnimation>(ui.broad_cast_text.bg_panel, Fx_Type.fx_broad, ref closeCallback); var sk = FXManager.Instance.SetFx<SkeletonAnimation>(ui.broad_cast_text.bg_panel, Fx_Type.fx_broad, ref closeCallback);
sk.state.SetAnimation(0, "animation", true); sk.state.SetAnimation(0, "animation", true);
ui.broad_cast_text.bg_panel.SetScale(1.45f, 1.1f); ui.broad_cast_text.bg_panel.SetScale(1.45f, 1.1f);
} }
private void OpenRecord() private void OpenRecord()
{ {
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.RecordViewUI_Open); UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.RecordViewUI_Open);
} }
private void hideEvent(object sender = null) private void hideEvent(object sender = null)
{ {
Debug.Log("hide"); Debug.Log("hide");
main_ui_show = false; main_ui_show = false;
ui.visible = false; ui.visible = false;
} }
private void showEvent(object sender = null) private void showEvent(object sender = null)
{ {
Debug.Log("show"); Debug.Log("show");
main_ui_show = true; main_ui_show = true;
ui.visible = true; ui.visible = true;
} }
private void Settop(object sender = null) private void Settop(object sender = null)
{ {
ui.group_.y = 350; ui.group_.y = 350;
if (Screen.safeArea.y != 0) if (Screen.safeArea.y != 0)
{//刘海屏 {//刘海屏
ui.group_.y += 68; ui.group_.y += 68;
} }
} }
private void Setbuttom(object sender = null) private void Setbuttom(object sender = null)
{ {
ui.group_.y = 170; ui.group_.y = 170;
if (Screen.safeArea.y != 0) if (Screen.safeArea.y != 0)
{//刘海屏 {//刘海屏
ui.group_.y += 68; ui.group_.y += 68;
} }
} }
# if GAME_RELEASE # if GAME_RELEASE
private const int MaxTime = 300; private const int MaxTime = 300;
#else #else
private const int MaxTime = 10; private const int MaxTime = 10;
#endif #endif
void timeEvent() void timeEvent()
{ {
time_count++; time_count++;
Debug.Log(time_count); // Debug.Log(time_count);
Debug.Log(MaxTime); // Debug.Log(MaxTime);
if (time_count > MaxTime) if (time_count > MaxTime)
{ {
time_count = 0; time_count = 0;
var name_index = Random.Range(0, config_name_list.Count); var name_index = Random.Range(0, config_name_list.Count);
var money_index = Random.Range(0, config_vip_level_list.Count); var money_index = Random.Range(0, config_vip_level_list.Count);
Debug.Log(text_ui.cast_text.text); Debug.Log(text_ui.cast_text.text);
string name = config_name_list[name_index]; string name = config_name_list[name_index];
if (name.Length > 8) if (name.Length > 8)
{ {
name = name[..8] + ".."; name = name[..8] + "..";
} }
string broad_text = String.Format(text_ui.hide_text.text, name, string broad_text = String.Format(text_ui.hide_text.text, name,
config_vip_level_list[money_index], DateTimeManager.Instance.GetCurrDateTime()); config_vip_level_list[money_index], DateTimeManager.Instance.GetCurrDateTime());
text_ui.cast_text.text = broad_text; text_ui.cast_text.text = broad_text;
var lv = GetVipLevelFromName(config_vip_level_list[money_index]); var lv = GetVipLevelFromName(config_vip_level_list[money_index]);
text_ui.broad_icon_loader.url = $"ui://LG_Common/vip_{lv}"; text_ui.broad_icon_loader.url = $"ui://LG_Common/vip_{lv}";
// Tweener tweener = DOTween.To(() => ui.broad.x, // Tweener tweener = DOTween.To(() => ui.broad.x,
// x => ui.broad.x = x, 200, 0.5f); // x => ui.broad.x = x, 200, 0.5f);
ui.t0.Play(); ui.t0.Play();
DOVirtual.DelayedCall(3.5f, () => DOVirtual.DelayedCall(3.5f, () =>
{ {
// Tweener tweener = DOTween.To(() => ui.broad.x, // Tweener tweener = DOTween.To(() => ui.broad.x,
// x => ui.broad.x = x, 1080, 0.5f); // x => ui.broad.x = x, 1080, 0.5f);
ui.t1.Play(); ui.t1.Play();
}); });
string str = name + "#" + config_vip_level_list[money_index] + "#" + DateTimeManager.Instance.GetCurrDateTime(); string str = name + "#" + config_vip_level_list[money_index] + "#" + DateTimeManager.Instance.GetCurrDateTime();
GameDispatcher.Instance.Dispatch(GameMsg.updateRecordList, str); GameDispatcher.Instance.Dispatch(GameMsg.updateRecordList, str);
} }
} }
private int GetVipLevelFromName(string name) private int GetVipLevelFromName(string name)
{ {
var vip_level = 1; var vip_level = 1;
switch (name) switch (name)
{ {
case "Gold": case "Gold":
vip_level = 1; vip_level = 1;
break; break;
case "Platinum": case "Platinum":
vip_level = 2; vip_level = 2;
break; break;
case "Diamond": case "Diamond":
vip_level = 3; vip_level = 3;
break; break;
} }
return vip_level; return vip_level;
} }
} }
} }
+4 -1
View File
@@ -511,8 +511,9 @@ namespace RedHotRoast
ui.btn_live.SetClick(() => 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]; ui.btn_secret.title = "LV." + GameHelper.GetCommonModel().UnlockSecret[1];
@@ -593,6 +594,8 @@ namespace RedHotRoast
ui.btn_task.SetClick(() => { OnClickTask(false); }); ui.btn_task.SetClick(() => { OnClickTask(false); });
ui.btn_restore.SetClick(() => ui.btn_restore.SetClick(() =>
{ {
IAPPayManager.Instance.OnRestoreButtonClicked();
// ApplePayManager.Instance.AppleRestore((success, message) => // ApplePayManager.Instance.AppleRestore((success, message) =>
// { // {
// Debug.Log($"[barry] restore success message: {message}---- {JsonConvert.SerializeObject(message)}"); // Debug.Log($"[barry] restore success message: {message}---- {JsonConvert.SerializeObject(message)}");
+362 -362
View File
@@ -1,362 +1,362 @@
using System.Collections.Generic; using System.Collections.Generic;
using FairyGUI; using FairyGUI;
using DG.Tweening; using DG.Tweening;
using FGUI.ZM_Common_01; using FGUI.ZM_Common_01;
using System; using System;
using SGModule.NetKit; using SGModule.NetKit;
using UnityEngine; using UnityEngine;
namespace RedHotRoast namespace RedHotRoast
{ {
public class LuckyPackUI : BaseUI public class LuckyPackUI : BaseUI
{ {
private LuckyPackUICtrl ctrl; private LuckyPackUICtrl ctrl;
private LuckyPackModel model; private LuckyPackModel model;
private FGUI.LG_LuckyGift.com_lucky ui; private FGUI.LG_LuckyGift.com_lucky ui;
private List<Paidgift> list; private List<Paidgift> list;
public LuckyPackUI(LuckyPackUICtrl ctrl) : base(ctrl) public LuckyPackUI(LuckyPackUICtrl ctrl) : base(ctrl)
{ {
uiName = UIConst.LuckyPackUI; uiName = UIConst.LuckyPackUI;
this.ctrl = ctrl; this.ctrl = ctrl;
} }
protected override void SetUIInfo(UIInfo uiInfo) protected override void SetUIInfo(UIInfo uiInfo)
{ {
uiInfo.packageName = "LG_LuckyGift"; uiInfo.packageName = "LG_LuckyGift";
uiInfo.assetName = "com_lucky"; uiInfo.assetName = "com_lucky";
uiInfo.layerType = UILayerType.Popup; uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false; uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false; uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true; uiInfo.isNeedUIMask = true;
} }
#region #region
protected override void OnInit() protected override void OnInit()
{ {
//model = ModuleManager.Instance.GetModel(ModelConst.PackrewardModel) as LuckyPackModel; //model = ModuleManager.Instance.GetModel(ModelConst.PackrewardModel) as LuckyPackModel;
} }
protected override void OnClose() protected override void OnClose()
{ {
AdExchangeManager.Instance.Destroy(); AdExchangeManager.Instance.Destroy();
GameHelper.showGameUI = true; GameHelper.showGameUI = true;
GameDispatcher.Instance.Dispatch(GameMsg.pack_close); GameDispatcher.Instance.Dispatch(GameMsg.pack_close);
int three_gift_got_index = SaveData.GetSaveObject().three_gift_got_index; int three_gift_got_index = SaveData.GetSaveObject().three_gift_got_index;
// if (GameHelper.isAutoPop && (three_gift_got_index <= (int)rewardState.day3)) // if (GameHelper.isAutoPop && (three_gift_got_index <= (int)rewardState.day3))
// { // {
// uiCtrlDispatcher.Dispatch(UICtrlMsg.ThreeDaysGiftUI_Open); // uiCtrlDispatcher.Dispatch(UICtrlMsg.ThreeDaysGiftUI_Open);
// GameHelper.isAutoPop = false; // GameHelper.isAutoPop = false;
// } // }
GameHelper.CallShowTurn(); GameHelper.CallShowTurn();
} }
protected override void OnBind() protected override void OnBind()
{ {
ui = baseUI as FGUI.LG_LuckyGift.com_lucky; ui = baseUI as FGUI.LG_LuckyGift.com_lucky;
} }
protected override void OnOpenBefore(object args) protected override void OnOpenBefore(object args)
{ {
ui.gold.GetChild("text_gold").text = GameHelper.Get101Str(GameHelper.GetGoldNumber()); ui.gold.GetChild("text_gold").text = GameHelper.Get101Str(GameHelper.GetGoldNumber());
var needScroll = false; var needScroll = false;
if (args != null) needScroll = (bool)args; if (args != null) needScroll = (bool)args;
ui.type.selectedIndex = needScroll ? 1 : 0; ui.type.selectedIndex = needScroll ? 1 : 0;
ui.gift_switch.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0; ui.gift_switch.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;
Debug.Log($"needScroll============={needScroll}= {ui.type.selectedIndex}"); Debug.Log($"needScroll============={needScroll}= {ui.type.selectedIndex}");
TrackKit.SendEvent(GameHelper.GetEventName(), needScroll ? ADEventTrack.Property.gift_show : ADEventTrack.Property.first_pack_show); TrackKit.SendEvent(GameHelper.GetEventName(), needScroll ? ADEventTrack.Property.gift_show : ADEventTrack.Property.first_pack_show);
list = ConfigSystem.GetConfig<Paidgift>(); list = ConfigSystem.GetConfig<Paidgift>();
if (GameHelper.IsAdModelOfPay()) if (GameHelper.IsAdModelOfPay())
{ {
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.pack_reward), ui.btn_buypack as btn_watchAd, SetTextString1); AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_FIRST_GIFT, ui.btn_buypack as btn_watchAd, SetTextString1);
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.remove_ad), ui.btn_buyremovead as btn_watchAd, SetTextString1); AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_REMOVE_ADS, ui.btn_buyremovead as btn_watchAd, SetTextString1);
} }
ui.btn_go_ad.SetClick(() => ui.btn_go_ad.SetClick(() =>
{ {
ui.type.selectedIndex = 1; ui.type.selectedIndex = 1;
}); });
ui.btn_go_lucky.SetClick(() => ui.btn_go_lucky.SetClick(() =>
{ {
ui.type.selectedIndex = 0; ui.type.selectedIndex = 0;
}); });
InitView(); InitView();
// var fileName = GameHelper.GetBackgroundName(1); // var fileName = GameHelper.GetBackgroundName(1);
// Debug.Log($"fileName======{fileName}"); // Debug.Log($"fileName======{fileName}");
// TextureHelper.SetImgLoader(ui.no_ad_pic.picture, fileName, null, "Background/"); // TextureHelper.SetImgLoader(ui.no_ad_pic.picture, fileName, null, "Background/");
// //
// var fileName1 = GameHelper.GetBackgroundName(2); // var fileName1 = GameHelper.GetBackgroundName(2);
// Debug.Log($"fileName1======{fileName1}"); // Debug.Log($"fileName1======{fileName1}");
// //
// TextureHelper.SetImgLoader(ui.lucky_pic.picture, fileName1, null, "Background/"); // TextureHelper.SetImgLoader(ui.lucky_pic.picture, fileName1, null, "Background/");
// var fileName = GameHelper.GetBackgroundName(1); // var fileName = GameHelper.GetBackgroundName(1);
// var task = new List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)>(); // 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)); // task.Add((ui.lucky_pic.picture, fileName, null, "Background/", FolderNames.BackgroundName));
// var fileName1 = GameHelper.GetBackgroundName(2); // var fileName1 = GameHelper.GetBackgroundName(2);
// task.Add((ui.no_ad_pic.picture, fileName1, null, "Background/", FolderNames.BackgroundName)); // task.Add((ui.no_ad_pic.picture, fileName1, null, "Background/", FolderNames.BackgroundName));
// TextureHelper.SetImgLoaders(task); // TextureHelper.SetImgLoaders(task);
} }
protected override void OnOpen(object args) protected override void OnOpen(object args)
{ {
} }
protected override void OnHide() protected override void OnHide()
{ {
} }
protected override void OnDisplay(object args) protected override void OnDisplay(object args)
{ {
} }
#endregion #endregion
#region #region
protected override void AddListener() protected override void AddListener()
{ {
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success); GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
} }
protected override void RemoveListener() protected override void RemoveListener()
{ {
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success); GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
} }
#endregion #endregion
void pay_success(object str) void pay_success(object str)
{ {
string type = (string)str; string type = (string)str;
Debug.Log($"pay_success type================{type}"); Debug.Log($"pay_success type================{type}");
if (type == PurchasingManager.GetPaySku(PayType.remove_ad)) if (type == IAPPayManager.PRODUCT_REMOVE_ADS)
{ {
var gold = list[1].coins_quantity; var gold = list[1].coins_quantity;
var start = GameHelper.GetUICenterPosition(ui.text_goldnum2); var start = GameHelper.GetUICenterPosition(ui.text_goldnum2);
var end = GameHelper.GetUICenterPosition(ui.gold.GetChild("icon")); var end = GameHelper.GetUICenterPosition(ui.gold.GetChild("icon"));
var rewardData = new RewardData(); var rewardData = new RewardData();
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask) var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
{ {
startPosition = start, startPosition = start,
endPosition = end, endPosition = end,
}; };
rewardData.AddReward(rewardSingleData); rewardData.AddReward(rewardSingleData);
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange; rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
rewardData.AddCompleted((isScu) => rewardData.AddCompleted((isScu) =>
{ {
DOVirtual.DelayedCall(0.5f, () => DOVirtual.DelayedCall(0.5f, () =>
{ {
var startNum = DataMgr.Coin.Value - gold; var startNum = DataMgr.Coin.Value - gold;
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f, DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f,
value => { ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); }); value => { ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); });
}); });
}); });
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData); GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AdcomingUI_Close); UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AdcomingUI_Close);
SaveData.GetSaveObject().is_get_removead = true; SaveData.GetSaveObject().is_get_removead = true;
SaveData.SaveDataFunc(); SaveData.SaveDataFunc();
InitView(); InitView();
} }
else if (type == PurchasingManager.GetPaySku(PayType.pack_reward)) else if (type == IAPPayManager.PRODUCT_FIRST_GIFT)
{ {
var start = GameHelper.GetUICenterPosition(ui.text_goldnum); var start = GameHelper.GetUICenterPosition(ui.text_goldnum);
var end = GameHelper.GetUICenterPosition(ui.gold.GetChild("icon")); var end = GameHelper.GetUICenterPosition(ui.gold.GetChild("icon"));
var gold = list[0].coins_quantity; var gold = list[0].coins_quantity;
var rewardData = new RewardData(); var rewardData = new RewardData();
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask) var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
{ {
startPosition = start, startPosition = start,
endPosition = end, endPosition = end,
}; };
rewardData.AddReward(rewardSingleData); rewardData.AddReward(rewardSingleData);
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange; rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
rewardData.AddCompleted((isScu) => rewardData.AddCompleted((isScu) =>
{ {
DOVirtual.DelayedCall(0.5f, () => DOVirtual.DelayedCall(0.5f, () =>
{ {
var startNum = DataMgr.Coin.Value - gold; var startNum = DataMgr.Coin.Value - gold;
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f, DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f,
value => { ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); }); value => { ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); });
}); });
}); });
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData); GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
SaveData.GetSaveObject().is_get_packreward = true; SaveData.GetSaveObject().is_get_packreward = true;
SaveData.SaveDataFunc(); SaveData.SaveDataFunc();
InitView(); InitView();
} }
} }
//初始化页面逻辑 //初始化页面逻辑
private int gold_num = 300; private int gold_num = 300;
private int back_num = 1; private int back_num = 1;
private int out_num = 1; private int out_num = 1;
private int refresh_num = 1; private int refresh_num = 1;
private void InitView() private void InitView()
{ {
gold_num = list[0].coins_quantity; gold_num = list[0].coins_quantity;
back_num = list[0].props_quantity[1]; back_num = list[0].props_quantity[1];
out_num = list[0].props_quantity[0]; out_num = list[0].props_quantity[0];
refresh_num = list[0].props_quantity[2]; refresh_num = list[0].props_quantity[2];
ui.text_time.SetVar("time", ConfigSystem.GetCommonConf().RemoveADsPackDuration.ToString()).FlushVars(); ui.text_time.SetVar("time", ConfigSystem.GetCommonConf().RemoveADsPackDuration.ToString()).FlushVars();
ui.btn_close.SetClick(CtrlCloseUI); ui.btn_close.SetClick(CtrlCloseUI);
ui.btn_luck_close.SetClick(CtrlCloseUI); ui.btn_luck_close.SetClick(CtrlCloseUI);
ui.text_goldnum.text = "x" + GameHelper.Get101Str(gold_num); ui.text_goldnum.text = "x" + GameHelper.Get101Str(gold_num);
ui.text_backnum1.text = "x" + back_num; ui.text_backnum1.text = "x" + back_num;
ui.text_outnum.text = "x" + out_num; ui.text_outnum.text = "x" + out_num;
ui.text_refreshnum.text = "x" + refresh_num; ui.text_refreshnum.text = "x" + refresh_num;
var buy_text = ui.btn_buypack.GetChild("title") as GTextField; var buy_text = ui.btn_buypack.GetChild("title") as GTextField;
buy_text.SetVar("price", list[0].Paid_price.ToString()).FlushVars(); buy_text.SetVar("price", list[0].Paid_price.ToString()).FlushVars();
ui.text_goldnum2.text = "x" + GameHelper.Get101Str(list[1].coins_quantity); ui.text_goldnum2.text = "x" + GameHelper.Get101Str(list[1].coins_quantity);
var buy_text1 = ui.btn_buyremovead.GetChild("title") as GTextField; var buy_text1 = ui.btn_buyremovead.GetChild("title") as GTextField;
buy_text1.SetVar("price", list[1].Paid_price.ToString()).FlushVars(); buy_text1.SetVar("price", list[1].Paid_price.ToString()).FlushVars();
if (!GameHelper.IsAdModelOfPay()) if (!GameHelper.IsAdModelOfPay())
{ {
ui.pay_type.selectedIndex = 1; ui.pay_type.selectedIndex = 1;
decimal price_pack = (decimal)list[0].Paid_price2; decimal price_pack = (decimal)list[0].Paid_price2;
ui.btn_max_pack.title = GameHelper.Get102Str(price_pack); ui.btn_max_pack.title = GameHelper.Get102Str(price_pack);
bool is_get = SaveData.GetSaveObject().is_get_packreward; bool is_get = SaveData.GetSaveObject().is_get_packreward;
Debug.Log($"is_get================{is_get}"); Debug.Log($"is_get================{is_get}");
if (is_get) if (is_get)
{ {
ui.btn_max_pack.enabled = false; ui.btn_max_pack.enabled = false;
ui.btn_max_pack.SetClick(() => { }); ui.btn_max_pack.SetClick(() => { });
} }
else else
{ {
ui.btn_max_pack.SetClick(() => ui.btn_max_pack.SetClick(() =>
{ {
ApplePayClass maxPayData = new ApplePayClass ApplePayClass maxPayData = new ApplePayClass
{ {
amount = (int)Math.Round(price_pack * 100), amount = (int)Math.Round(price_pack * 100),
sku = PurchasingManager.GetPaySku(PayType.pack_reward), sku = IAPPayManager.PRODUCT_FIRST_GIFT,
currency = "USD" currency = "USD"
}; };
MaxPayManager.Instance.Buy(maxPayData); MaxPayManager.Instance.Buy(maxPayData);
}); });
} }
decimal price_remove = (decimal)list[1].Paid_price2; decimal price_remove = (decimal)list[1].Paid_price2;
ui.btn_max_remove.title = GameHelper.Get102Str(price_remove); ui.btn_max_remove.title = GameHelper.Get102Str(price_remove);
bool is_get1 = SaveData.GetSaveObject().is_get_removead; bool is_get1 = SaveData.GetSaveObject().is_get_removead;
Debug.Log($"is_get1================{is_get1}"); Debug.Log($"is_get1================{is_get1}");
if (is_get1) if (is_get1)
{ {
HallManager.Instance.UpdateSecondEvent += RemoveAdCountDown; HallManager.Instance.UpdateSecondEvent += RemoveAdCountDown;
ui.btn_max_remove.enabled = false; ui.btn_max_remove.enabled = false;
ui.btn_max_remove.SetClick(() => { }); ui.btn_max_remove.SetClick(() => { });
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime()); int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
if (cd > 24 * 3600) if (cd > 24 * 3600)
{ {
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D"); ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
} }
else else
{ {
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Hour); ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
} }
} }
else else
{ {
ui.btn_max_remove.SetClick(() => ui.btn_max_remove.SetClick(() =>
{ {
ApplePayClass maxPayData = new ApplePayClass ApplePayClass maxPayData = new ApplePayClass
{ {
amount = (int)Math.Round(price_remove * 100), amount = (int)Math.Round(price_remove * 100),
sku = PurchasingManager.GetPaySku(PayType.remove_ad), sku = IAPPayManager.PRODUCT_REMOVE_ADS,
currency = "USD" currency = "USD"
}; };
MaxPayManager.Instance.Buy(maxPayData); MaxPayManager.Instance.Buy(maxPayData);
}); });
} }
} }
else else
{ {
ui.pay_type.selectedIndex = 0; ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.Start(); AdExchangeManager.Instance.Start();
SetTextString1(); SetTextString1();
decimal price_remove = (decimal)list[1].Paid_price2; decimal price_remove = (decimal)list[1].Paid_price2;
bool is_get1 = SaveData.GetSaveObject().is_get_removead; bool is_get1 = SaveData.GetSaveObject().is_get_removead;
if (is_get1) if (is_get1)
{ {
HallManager.Instance.UpdateSecondEvent += RemoveAdCountDown; HallManager.Instance.UpdateSecondEvent += RemoveAdCountDown;
ui.btn_buyremovead.enabled = false; ui.btn_buyremovead.enabled = false;
ui.btn_buyremovead.SetClick(() => { }); ui.btn_buyremovead.SetClick(() => { });
var lastTimes = SaveData.GetSaveObject()._watch_ad_cd; var lastTimes = SaveData.GetSaveObject()._watch_ad_cd;
if (GameHelper.GetNowTime() < lastTimes) if (GameHelper.GetNowTime() < lastTimes)
{ {
} }
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime()); int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
if (cd > 24 * 3600) if (cd > 24 * 3600)
{ {
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D"); ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
} }
else else
{ {
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Hour); ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
} }
} }
} }
} }
private void RemoveAdCountDown() private void RemoveAdCountDown()
{ {
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime()); int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
if (cd > 0) if (cd > 0)
{ {
if (cd > 24 * 3600) if (cd > 24 * 3600)
{ {
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D"); ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D"); ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
} }
else else
{ {
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Hour); ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Hour); ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
} }
} }
else else
{ {
SaveData.GetSaveObject().is_get_removead = false; SaveData.GetSaveObject().is_get_removead = false;
SaveData.GetSaveObject().remove_ad_time = 0; SaveData.GetSaveObject().remove_ad_time = 0;
InitView(); InitView();
} }
} }
public void SetTextString1() public void SetTextString1()
{ {
var remove_need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.remove_ad)); var remove_need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_REMOVE_ADS);
var pack_need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.pack_reward)); var pack_need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_FIRST_GIFT);
var myAd = AdExchangeManager.Instance.GetLookRewardADNum(); var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.ads.SetVar("num", myAd.ToString()).FlushVars(); ui.ads.SetVar("num", myAd.ToString()).FlushVars();
ui.tips1.SetVar("num", pack_need.ToString()).FlushVars(); ui.tips1.SetVar("num", pack_need.ToString()).FlushVars();
ui.tips2.SetVar("num", remove_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.com_gold.y += Screen.safeArea.y;
} }
ui.gift_switch.selectedIndex = 1; ui.gift_switch.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;
total_item = 8; total_item = 8;
selectIndex = DataMgr.PlayerAvatarId.Value; selectIndex = DataMgr.PlayerAvatarId.Value;
@@ -143,6 +143,8 @@ namespace RedHotRoast
// ui.btn_credits.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 2); }); // ui.btn_credits.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 2); });
ui.btn_restore.SetClick(() => ui.btn_restore.SetClick(() =>
{ {
//恢复购买按钮
IAPPayManager.Instance.OnRestoreButtonClicked();
// ApplePayManager.Instance.AppleRestore((success, message) => // ApplePayManager.Instance.AppleRestore((success, message) =>
// { // {
// if (success) // if (success)
File diff suppressed because it is too large Load Diff
+146 -146
View File
@@ -1,146 +1,146 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using FGUI.ZM_Common_01; using FGUI.ZM_Common_01;
using SGModule.NetKit; using SGModule.NetKit;
namespace RedHotRoast namespace RedHotRoast
{ {
public class PassunlockUI : BaseUI public class PassunlockUI : BaseUI
{ {
private PassunlockUICtrl ctrl; private PassunlockUICtrl ctrl;
private PassunlockModel model; private PassunlockModel model;
private FGUI.ZM_Pack_16.com_passunlock ui; private FGUI.ZM_Pack_16.com_passunlock ui;
public btn_watchAd btn_WatchAd; public btn_watchAd btn_WatchAd;
public PassunlockUI(PassunlockUICtrl ctrl) : base(ctrl) public PassunlockUI(PassunlockUICtrl ctrl) : base(ctrl)
{ {
uiName = UIConst.PassunlockUI; uiName = UIConst.PassunlockUI;
this.ctrl = ctrl; this.ctrl = ctrl;
} }
protected override void SetUIInfo(UIInfo uiInfo) protected override void SetUIInfo(UIInfo uiInfo)
{ {
uiInfo.packageName = "ZM_Pack_16"; uiInfo.packageName = "ZM_Pack_16";
uiInfo.assetName = "com_passunlock"; uiInfo.assetName = "com_passunlock";
uiInfo.layerType = UILayerType.Popup; uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false; uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false; uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true; uiInfo.isNeedUIMask = true;
} }
#region #region
protected override void OnInit() protected override void OnInit()
{ {
//model = ModuleManager.Instance.GetModel(ModelConst.PassunlockModel) as PassunlockModel; //model = ModuleManager.Instance.GetModel(ModelConst.PassunlockModel) as PassunlockModel;
} }
protected override void OnClose() protected override void OnClose()
{ {
AdExchangeManager.Instance.Destroy(); AdExchangeManager.Instance.Destroy();
GameHelper.CallShowTurn(); GameHelper.CallShowTurn();
} }
protected override void OnBind() protected override void OnBind()
{ {
ui = baseUI as FGUI.ZM_Pack_16.com_passunlock; ui = baseUI as FGUI.ZM_Pack_16.com_passunlock;
} }
protected override void OnOpenBefore(object args) protected override void OnOpenBefore(object args)
{ {
if (GameHelper.IsAdModelOfPay()) { if (GameHelper.IsAdModelOfPay()) {
ui.pay_type.selectedIndex = 0; ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.battle_pass), ui.btn_buypass as btn_watchAd,SetTextString); AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_PASS_BONUS, ui.btn_buypass as btn_watchAd,SetTextString);
AdExchangeManager.Instance.Start(); AdExchangeManager.Instance.Start();
SetTextString(); SetTextString();
} else { } else {
ui.pay_type.selectedIndex = 1; ui.pay_type.selectedIndex = 1;
decimal price = (decimal)GameHelper.GetCommonModel().Passportgift2; decimal price = (decimal)GameHelper.GetCommonModel().Passportgift2;
ui.btn_max_pay.title = GameHelper.Get102Str(price); ui.btn_max_pay.title = GameHelper.Get102Str(price);
ui.btn_max_pay.SetClick(() => { ui.btn_max_pay.SetClick(() => {
ApplePayClass maxPayData = new ApplePayClass ApplePayClass maxPayData = new ApplePayClass
{ {
amount = (int)Math.Round(price * 100), amount = (int)Math.Round(price * 100),
sku = PurchasingManager.GetPaySku(PayType.battle_pass), sku = IAPPayManager.PRODUCT_PASS_BONUS,
currency = "USD" currency = "USD"
}; };
MaxPayManager.Instance.Buy(maxPayData); MaxPayManager.Instance.Buy(maxPayData);
}); });
} }
ui.gift_switch.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0; ui.gift_switch.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;
InitView(); InitView();
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.master_pass_show); TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.master_pass_show);
var fileName = GameHelper.GetBackgroundName(3); var fileName = GameHelper.GetBackgroundName(3);
TextureHelper.SetImgLoader(ui.loader.picture, fileName, null, "Background/", FolderNames.BackgroundName); TextureHelper.SetImgLoader(ui.loader.picture, fileName, null, "Background/", FolderNames.BackgroundName);
} }
protected override void OnOpen(object args) protected override void OnOpen(object args)
{ {
} }
protected override void OnHide() protected override void OnHide()
{ {
} }
protected override void OnDisplay(object args) protected override void OnDisplay(object args)
{ {
} }
#endregion #endregion
#region #region
protected override void AddListener() protected override void AddListener()
{ {
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success); GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
} }
protected override void RemoveListener() protected override void RemoveListener()
{ {
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success); GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
} }
#endregion #endregion
void pay_success(object str) void pay_success(object str)
{ {
string type = (string)str; string type = (string)str;
string purch_number = ""; string purch_number = "";
if (type == PurchasingManager.GetPaySku(PayType.battle_pass)) if (type == IAPPayManager.PRODUCT_PASS_BONUS)
{ {
CtrlCloseUI(); CtrlCloseUI();
} }
// if (purch_number != "") // if (purch_number != "")
// { // {
// GameHelper.SendRevenueToAF(purch_number); // GameHelper.SendRevenueToAF(purch_number);
// } // }
} }
//初始化页面逻辑 //初始化页面逻辑
private void InitView() private void InitView()
{ {
ui.btn_close.SetClick(CtrlCloseUI); ui.btn_close.SetClick(CtrlCloseUI);
int gold = 0; int gold = 0;
List<Passportrewards> Passportrewards_list = ConfigSystem.GetConfig<Passportrewards>(); List<Passportrewards> Passportrewards_list = ConfigSystem.GetConfig<Passportrewards>();
for (int i = 0; i < Passportrewards_list.Count; i++) for (int i = 0; i < Passportrewards_list.Count; i++)
{ {
if (Passportrewards_list[i].Paid_rewards_type == 0) gold += Passportrewards_list[i].Paid_rewards_num; if (Passportrewards_list[i].Paid_rewards_type == 0) gold += Passportrewards_list[i].Paid_rewards_num;
} }
ui.text_allgold.text = GameHelper.Get101Str(gold); ui.text_allgold.text = GameHelper.Get101Str(gold);
// ui.btn_buypass.GetChild("title").text = "$" + ConfigSystem.GetConfig<CommonModel>().Passportgift; // ui.btn_buypass.GetChild("title").text = "$" + ConfigSystem.GetConfig<CommonModel>().Passportgift;
} }
public void SetTextString() public void SetTextString()
{ {
var need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.battle_pass)); var need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_PASS_BONUS);
var myAd = AdExchangeManager.Instance.GetLookRewardADNum(); var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.tips.SetVar("num", need.ToString()).FlushVars(); ui.tips.SetVar("num", need.ToString()).FlushVars();
ui.ads.SetVar("num", myAd.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(openUIMsg, OpenUI);
uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI); 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() protected override void RemoveListener()
{ {
uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI); uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI); 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; // 第三方支付 bool is_maxPay = false; // 第三方支付
string type = (string)str; string type = (string)str;
string purch_number = ""; 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; List<Paidcoins> list = ConfigSystem.GetConfig<Paidcoins>();
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符 // GameHelper.AddGoldNumber(list[suffix_num].Actual_coins);
int suffix_num = int.Parse(suffix); int gold_num = list[suffix_num].Actual_coins;
GetPayReward(gold_num);
purch_number = ConfigSystem.GetConfig<Paidcoins>()[suffix_num].Payment_amount2.ToString(); SaveData.GetSaveObject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
SaveData.SaveDataFunc();
if (!UIManager.Instance.IsExistUI(UIConst.BuygoldUI)) 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; SaveData.GetSaveObject().is_get_battlepass = true;
int gold = 0; int gold = 0;
@@ -158,7 +152,7 @@ namespace RedHotRoast
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh); 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.GetSaveObject().have_slot = true;
SaveData.SaveDataFunc(); SaveData.SaveDataFunc();
@@ -167,7 +161,7 @@ namespace RedHotRoast
purch_number = GameHelper.GetCommonModel().addspace2.ToString(); 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().remove_ad_time = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().RemoveADsPackDuration * 3600;
SaveData.GetSaveObject().is_get_removead = true; SaveData.GetSaveObject().is_get_removead = true;
@@ -179,7 +173,7 @@ namespace RedHotRoast
GameHelper.ShowTips("purchase_succ", true); GameHelper.ShowTips("purchase_succ", true);
purch_number = ConfigSystem.GetConfig<Paidgift>()[1].Paid_price2.ToString(); 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>(); List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
int gold_num = list[0].coins_quantity; int gold_num = list[0].coins_quantity;
@@ -199,40 +193,38 @@ namespace RedHotRoast
GameHelper.ShowTips("purchase_succ", true); GameHelper.ShowTips("purchase_succ", true);
purch_number = ConfigSystem.GetConfig<Paidgift>()[0].Paid_price2.ToString(); purch_number = ConfigSystem.GetConfig<Paidgift>()[0].Paid_price2.ToString();
} }
else if (type == PurchasingManager.GetPaySku(PayType.fail_pack)) // else if (type == PurchasingManager.GetPaySku(PayType.fail_pack))
{ // {
List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>(); // List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
purch_number = ConfigSystem.GetConfig<Paidgift>()[2].Paid_price2.ToString(); // purch_number = ConfigSystem.GetConfig<Paidgift>()[2].Paid_price2.ToString();
//ui?.setBtnAds(); // //ui?.setBtnAds();
GameDispatcher.Instance.Dispatch(GameMsg.resurgence); // GameDispatcher.Instance.Dispatch(GameMsg.resurgence);
//
// DataMgr.Coin.Value += ConfigSystem.GetConfig<PaidgiftModel>().DataList[1].coins_quantity; // // DataMgr.Coin.Value += ConfigSystem.GetConfig<PaidgiftModel>().DataList[1].coins_quantity;
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh); // // GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
int back_num = list[2].props_quantity[1]; // int back_num = list[2].props_quantity[1];
int out_num = list[2].props_quantity[0]; // int out_num = list[2].props_quantity[0];
int refresh_num = list[2].props_quantity[2]; // int refresh_num = list[2].props_quantity[2];
//GameHelper.addGoldNumber(gold_num); // //GameHelper.addGoldNumber(gold_num);
int gold_num = list[2].coins_quantity; // int gold_num = list[2].coins_quantity;
if (!UIManager.Instance.IsExistUI(UIConst.ResurgenceUI)) DataMgr.Coin.Value += gold_num; // if (!UIManager.Instance.IsExistUI(UIConst.ResurgenceUI)) DataMgr.Coin.Value += gold_num;
GameHelper.AddItemNumber(0, out_num); // GameHelper.AddItemNumber(0, out_num);
GameHelper.AddItemNumber(1, back_num); // GameHelper.AddItemNumber(1, back_num);
GameHelper.AddItemNumber(2, refresh_num); // GameHelper.AddItemNumber(2, refresh_num);
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh); // GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
SaveData.SaveDataFunc(); // SaveData.SaveDataFunc();
//
} // }
else if (type == PurchasingManager.GetPaySku(PayType.three_days_gift)) // else if (type == PurchasingManager.GetPaySku(PayType.three_days_gift))
{ // {
SaveData.GetSaveObject().is_get_ThreeDaysGift = true; // SaveData.GetSaveObject().is_get_ThreeDaysGift = true;
SaveData.SaveDataFunc(); // SaveData.SaveDataFunc();
purch_number = ConfigSystem.GetConfig<Multigift>()[0].Paid_price2.ToString(); // purch_number = ConfigSystem.GetConfig<Multigift>()[0].Paid_price2.ToString();
} // }
else if (type.StartsWith("vip_club")) else if (PurchasingManager.VipProductMap.TryGetValue(type, out var vipIdx))
{ {
is_maxPay = true; is_maxPay = true;
int startIndex = "vip_club".Length; int suffixNum = int.Parse(vipIdx);
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffixNum = int.Parse(suffix);
if (!MaxPayManager.isIOSPay) if (!MaxPayManager.isIOSPay)
{ {
@@ -287,16 +279,36 @@ namespace RedHotRoast
// 付费上报BI // 付费上报BI
BIManager.Instance.TrackPurchase(purch_number.As<double>(), "USD", payType.ToString(), type, "paid"); BIManager.Instance.TrackPurchase(purch_number.As<double>(), "USD", payType.ToString(), type, "paid");
Debug.Log("付费收益上报AF----------- " + revenue); // Debug.Log("付费收益上报AF----------- " + revenue);
adCallbackInfo.Clear(); // adCallbackInfo.Clear();
adCallbackInfo.Add("appsflyer_id", AppsFlyer.getAppsFlyerId()); // adCallbackInfo.Add("appsflyer_id", AppsFlyer.getAppsFlyerId());
adCallbackInfo.Add("customer_user_id", GameHelper.GetLoginModel().Uid.ToString()); // adCallbackInfo.Add("customer_user_id", GameHelper.GetLoginModel().Uid.ToString());
adCallbackInfo.Add("af_currency", "USD"); // adCallbackInfo.Add("af_currency", "USD");
adCallbackInfo.Add("af_revenue", revenue.ToString(CultureInfo.InvariantCulture)); // adCallbackInfo.Add("af_revenue", revenue.ToString(CultureInfo.InvariantCulture));
AppsFlyer.sendEvent("af_purchase", adCallbackInfo); // AppsFlyer.sendEvent("af_purchase", adCallbackInfo);
TrackKit.SendEvent(AfPurchaseTrack.Event, AfPurchaseTrack.Property.af_revenue, (int)(purch_number.As<decimal>() * 10000)); 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) if (Screen.safeArea.y != 0)
{ {
ui.btn_gold.y += 68; ui.btn_gold.y += 58;
ui.btn_close.y += 68; ui.btn_close.y += 58;
ui.sc_list.y += 68; ui.sc_list.y += 38;
} }
var eventName = GameHelper.IsAdModelOfPay() ? ADEventTrack.Event : ADEventTrack.MaxPayEvent; var eventName = GameHelper.IsAdModelOfPay() ? ADEventTrack.Event : ADEventTrack.MaxPayEvent;
@@ -1,423 +1,423 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using DG.Tweening; using DG.Tweening;
using FairyGUI; using FairyGUI;
using FGUI.LG_secretAlbums; using FGUI.LG_secretAlbums;
using SGModule.Common.Helper; using SGModule.Common.Helper;
using SGModule.NetKit; using SGModule.NetKit;
using UnityEngine; using UnityEngine;
namespace RedHotRoast namespace RedHotRoast
{ {
public class SecretAlbumsNextUI : BaseUI public class SecretAlbumsNextUI : BaseUI
{ {
private SecretAlbumsNextUICtrl ctrl; private SecretAlbumsNextUICtrl ctrl;
private SecretAlbumsNextModel model; private SecretAlbumsNextModel model;
private FGUI.LG_secretAlbums.com_scAlbumPreview ui; private FGUI.LG_secretAlbums.com_scAlbumPreview ui;
public SecretAlbumsNextUI(SecretAlbumsNextUICtrl ctrl) : base(ctrl) public SecretAlbumsNextUI(SecretAlbumsNextUICtrl ctrl) : base(ctrl)
{ {
uiName = UIConst.SecretAlbumsNextUI; uiName = UIConst.SecretAlbumsNextUI;
this.ctrl = ctrl; this.ctrl = ctrl;
} }
protected override void SetUIInfo(UIInfo uiInfo) protected override void SetUIInfo(UIInfo uiInfo)
{ {
uiInfo.packageName = "LG_secretAlbums"; uiInfo.packageName = "LG_secretAlbums";
uiInfo.assetName = "com_scAlbumPreview"; uiInfo.assetName = "com_scAlbumPreview";
uiInfo.layerType = UILayerType.Popup; uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false; uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false; uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true; uiInfo.isNeedUIMask = true;
} }
#region #region
protected override void OnInit() protected override void OnInit()
{ {
//model = ModuleManager.Instance.GetModel(ModelConst.SecretAlbumsModel) as SecretAlbumsModel; //model = ModuleManager.Instance.GetModel(ModelConst.SecretAlbumsModel) as SecretAlbumsModel;
} }
protected override void OnClose() protected override void OnClose()
{ {
HallManager.Instance.UpdateSecondEvent -= UpWatchAdsBtn; HallManager.Instance.UpdateSecondEvent -= UpWatchAdsBtn;
// 清理 Loader 的材质和贴图 // 清理 Loader 的材质和贴图
foreach (var loader in loader_list) foreach (var loader in loader_list)
{ {
if (loader == null || loader.isDisposed) continue; if (loader == null || loader.isDisposed) continue;
// 释放材质到材质池 // 释放材质到材质池
if (loader.material != null) if (loader.material != null)
{ {
TextureHelper.CancelImageBlur(loader); // 自动返回材质池 TextureHelper.CancelImageBlur(loader); // 自动返回材质池
loader.material = null; loader.material = null;
} }
// 清理 NTexture // 清理 NTexture
if (loader.texture != null) if (loader.texture != null)
{ {
if (loader.texture.destroyMethod == DestroyMethod.Destroy) if (loader.texture.destroyMethod == DestroyMethod.Destroy)
loader.texture.Dispose(); // 销毁 NTexture 对象 loader.texture.Dispose(); // 销毁 NTexture 对象
loader.texture = null; loader.texture = null;
} }
} }
loader_list.Clear(); loader_list.Clear();
// 强制卸载未使用的资源 // 强制卸载未使用的资源
Resources.UnloadUnusedAssets(); Resources.UnloadUnusedAssets();
} }
protected override void OnBind() protected override void OnBind()
{ {
ui = baseUI as FGUI.LG_secretAlbums.com_scAlbumPreview; ui = baseUI as FGUI.LG_secretAlbums.com_scAlbumPreview;
} }
private AlbumPreviewData _albumPreviewData; private AlbumPreviewData _albumPreviewData;
protected override void OnOpenBefore(object args) protected override void OnOpenBefore(object args)
{ {
if (args == null) return; if (args == null) return;
_albumPreviewData = (AlbumPreviewData)args; _albumPreviewData = (AlbumPreviewData)args;
InitView(); InitView();
var event_names = ADEventTrack.Property.secret_albums_show + (_albumPreviewData.Index + 1); var event_names = ADEventTrack.Property.secret_albums_show + (_albumPreviewData.Index + 1);
var event_type = _albumPreviewData.PayType == (int)UnlockPayType.Ad ? ADEventTrack.Event : ADEventTrack.MaxPayEvent; var event_type = _albumPreviewData.PayType == (int)UnlockPayType.Ad ? ADEventTrack.Event : ADEventTrack.MaxPayEvent;
TrackKit.SendEvent(event_type, event_names); TrackKit.SendEvent(event_type, event_names);
} }
protected override void OnOpen(object args) protected override void OnOpen(object args)
{ {
} }
protected override void OnHide() protected override void OnHide()
{ {
} }
protected override void OnDisplay(object args) protected override void OnDisplay(object args)
{ {
} }
#endregion #endregion
#region #region
protected override void AddListener() 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); GameDispatcher.Instance.AddListener(GameMsg.BuyVip, InitView);
} }
protected override void RemoveListener() 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); GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, InitView);
} }
#endregion #endregion
void pay_success(object str) void pay_success(object str)
{ {
string type = (string)str; string type = (string)str;
string purch_number = ""; string purch_number = "";
if (type.StartsWith("secret_albnums")) if (type.StartsWith("secret_albnums"))
{ {
int startIndex = "secret_albnums".Length; int startIndex = "secret_albnums".Length;
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符 string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffix_num = int.Parse(suffix); int suffix_num = int.Parse(suffix);
Log.Info("Secret_pay_success", $"index================:{suffix_num}"); Log.Info("Secret_pay_success", $"index================:{suffix_num}");
// 判断是否已存在,避免重复添加 // 判断是否已存在,避免重复添加
if (!DataMgr.SecretUnlockList.Value.Contains(suffix_num)) if (!DataMgr.SecretUnlockList.Value.Contains(suffix_num))
{ {
DataMgr.SecretUnlockList.Value.Add(suffix_num); DataMgr.SecretUnlockList.Value.Add(suffix_num);
DataMgr.SecretUnlockList.Save(); DataMgr.SecretUnlockList.Save();
GameDispatcher.Instance.Dispatch(GameMsg.UnlockSecretSuccess); GameDispatcher.Instance.Dispatch(GameMsg.UnlockSecretSuccess);
} }
GameHelper.ShowTips("purchase_succ", true); GameHelper.ShowTips("purchase_succ", true);
InitView(); InitView();
} }
} }
private List<string> _secretData; private List<string> _secretData;
private bool is_unlock = false; //当前专辑是否解锁 private bool is_unlock = false; //当前专辑是否解锁
private List<GLoader> loader_list = new List<GLoader>(); private List<GLoader> loader_list = new List<GLoader>();
//初始化页面逻辑 //初始化页面逻辑
private void InitView(object a = null) private void InitView(object a = null)
{ {
// 先清理上一次的 loader 和任务 // 先清理上一次的 loader 和任务
foreach (var l in loader_list) foreach (var l in loader_list)
{ {
if (l != null && !l.isDisposed) if (l != null && !l.isDisposed)
{ {
TextureHelper.CancelImageBlur(l); // 放回材质池 TextureHelper.CancelImageBlur(l); // 放回材质池
if (l.texture != null) if (l.texture != null)
{ {
l.texture.Dispose(); l.texture.Dispose();
l.texture = null; l.texture = null;
} }
if (l.material != null) l.material = null; if (l.material != null) l.material = null;
} }
} }
loader_list.Clear(); loader_list.Clear();
_tasks.Clear(); _tasks.Clear();
//专辑解锁状态 //专辑解锁状态
is_unlock = DataMgr.SecretUnlockList.Value.Contains(_albumPreviewData.Index); is_unlock = DataMgr.SecretUnlockList.Value.Contains(_albumPreviewData.Index);
UpWatchAdsBtn(); UpWatchAdsBtn();
HallManager.Instance.UpdateSecondEvent += UpWatchAdsBtn; HallManager.Instance.UpdateSecondEvent += UpWatchAdsBtn;
ui.btn_close.SetClick(CtrlCloseUI); ui.btn_close.SetClick(CtrlCloseUI);
ui.old_price.text = GameHelper.getPrice((decimal)_albumPreviewData.Price); ui.old_price.text = GameHelper.getPrice((decimal)_albumPreviewData.Price);
ui.btn_pay.title = GameHelper.getPrice((decimal)_albumPreviewData.DiscountPrice); ui.btn_pay.title = GameHelper.getPrice((decimal)_albumPreviewData.DiscountPrice);
_secretData = SplitStringToList(_albumPreviewData.Name2); _secretData = SplitStringToList(_albumPreviewData.Name2);
ui.list.itemRenderer = ItemRender; ui.list.itemRenderer = ItemRender;
ui.list.numItems = _secretData.Count; ui.list.numItems = _secretData.Count;
ui.pay_type.selectedIndex = !is_unlock ? _albumPreviewData.PayType : (int)UnlockPayType.None; ui.pay_type.selectedIndex = !is_unlock ? _albumPreviewData.PayType : (int)UnlockPayType.None;
if (is_unlock) if (is_unlock)
{ {
ui.pay_type.selectedIndex = (int)UnlockPayType.None; ui.pay_type.selectedIndex = (int)UnlockPayType.None;
} }
else else
{ {
if (_albumPreviewData.SubscribeUnlock == 1) if (_albumPreviewData.SubscribeUnlock == 1)
{ {
ui.vip.selectedIndex = 1; ui.vip.selectedIndex = 1;
if (GameHelper.GetVipLevel() > 0) if (GameHelper.GetVipLevel() > 0)
{ {
ui.has_vip.selectedIndex = 1; ui.has_vip.selectedIndex = 1;
ui.btn_vip.x = 540; ui.btn_vip.x = 540;
// ui.btn_vip.y -= 10; // ui.btn_vip.y -= 10;
} }
else else
{ {
ui.has_vip.selectedIndex = 0; ui.has_vip.selectedIndex = 0;
} }
} }
else else
{ {
ui.vip.selectedIndex = 0; ui.vip.selectedIndex = 0;
} }
ui.pay_type.selectedIndex = _albumPreviewData.PayType; ui.pay_type.selectedIndex = _albumPreviewData.PayType;
} }
var _type = "secret_albnums" + _albumPreviewData.Index; var _type = "secret_albnums" + _albumPreviewData.Index;
ui.btn_pay.SetClick(() => ui.btn_pay.SetClick(() =>
{ {
ApplePayClass maxPayData = new ApplePayClass ApplePayClass maxPayData = new ApplePayClass
{ {
amount = (int)Math.Round(_albumPreviewData.DiscountPrice * 100), amount = (int)Math.Round(_albumPreviewData.DiscountPrice * 100),
sku = _type, sku = _type,
currency = "USD" currency = "USD"
}; };
MaxPayManager.Instance.Buy(maxPayData); MaxPayManager.Instance.Buy(maxPayData);
}); });
ui.btn_gold.title = _albumPreviewData.GoldCoins.ToString(); ui.btn_gold.title = _albumPreviewData.GoldCoins.ToString();
ui.btn_gold.SetClick(() => ui.btn_gold.SetClick(() =>
{ {
if (GameHelper.Get101() >= _albumPreviewData.GoldCoins) if (GameHelper.Get101() >= _albumPreviewData.GoldCoins)
{ {
GameHelper.AddGold(-_albumPreviewData.GoldCoins); GameHelper.AddGold(-_albumPreviewData.GoldCoins);
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _type); GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, _type);
string eventName = ADEventTrack.Property.secret_albums_success_ + (_albumPreviewData.Index + 1); string eventName = ADEventTrack.Property.secret_albums_success_ + (_albumPreviewData.Index + 1);
TrackKit.SendEvent(ADEventTrack.SecretAlbums, eventName); TrackKit.SendEvent(ADEventTrack.SecretAlbums, eventName);
GameDispatcher.Instance.Dispatch(GameMsg.Update101); GameDispatcher.Instance.Dispatch(GameMsg.Update101);
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.unlock_secretAlbums_resources); TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.unlock_secretAlbums_resources);
} }
else else
{ {
GameHelper.ShowTips("no_enough_gold", true); GameHelper.ShowTips("no_enough_gold", true);
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open); uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
} }
}); });
var AdCount = DataMgr.SecretUnlockADs.Value.GetValueOrDefault(_albumPreviewData.Index, 0); var AdCount = DataMgr.SecretUnlockADs.Value.GetValueOrDefault(_albumPreviewData.Index, 0);
ui.btn_watch.ads.SetVar("ads", AdCount + "/" + _albumPreviewData.AD).FlushVars(); ui.btn_watch.ads.SetVar("ads", AdCount + "/" + _albumPreviewData.AD).FlushVars();
ui.btn_watch.SetClick(() => ui.btn_watch.SetClick(() =>
{ {
if (AdCount >= _albumPreviewData.AD) if (AdCount >= _albumPreviewData.AD)
{ {
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _type); GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, _type);
} }
else else
{ {
GameHelper.ShowVideoAd("UnlockSecretAlbums", (isSuccess) => GameHelper.ShowVideoAd("UnlockSecretAlbums", (isSuccess) =>
{ {
if (isSuccess) if (isSuccess)
{ {
var adTimes = Convert.ToInt32(GameHelper.GetNowTime()); var adTimes = Convert.ToInt32(GameHelper.GetNowTime());
DataMgr.SecretUnlockCd.Value[_albumPreviewData.Index] = adTimes + _albumPreviewData.CD; DataMgr.SecretUnlockCd.Value[_albumPreviewData.Index] = adTimes + _albumPreviewData.CD;
DataMgr.SecretUnlockCd.Save(); DataMgr.SecretUnlockCd.Save();
var currentAdCount = DataMgr.SecretUnlockADs.Value.GetValueOrDefault(_albumPreviewData.Index, 0); var currentAdCount = DataMgr.SecretUnlockADs.Value.GetValueOrDefault(_albumPreviewData.Index, 0);
DataMgr.SecretUnlockADs.Value[_albumPreviewData.Index] = currentAdCount + 1; DataMgr.SecretUnlockADs.Value[_albumPreviewData.Index] = currentAdCount + 1;
DataMgr.SecretUnlockADs.Save(); DataMgr.SecretUnlockADs.Save();
string eventName = ADEventTrack.Property.secret_albums_success_ + (_albumPreviewData.Index + 1); string eventName = ADEventTrack.Property.secret_albums_success_ + (_albumPreviewData.Index + 1);
TrackKit.SendEvent(ADEventTrack.Event, eventName); TrackKit.SendEvent(ADEventTrack.Event, eventName);
InitView(); InitView();
} }
}); });
} }
}); });
ui.btn_vip.SetClick(() => ui.btn_vip.SetClick(() =>
{ {
TrackKit.SendEvent(ADEventTrack.SecretAlbums, ADEventTrack.Property.secret_albums_click_ + (_albumPreviewData.Index + 1)); TrackKit.SendEvent(ADEventTrack.SecretAlbums, ADEventTrack.Property.secret_albums_click_ + (_albumPreviewData.Index + 1));
if (GameHelper.GetVipLevel() > 0) if (GameHelper.GetVipLevel() > 0)
{ {
GameHelper.isVipUnlock = true; GameHelper.isVipUnlock = true;
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _type); GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, _type);
string eventName = ADEventTrack.Property.vip_secret_albums_unclock_ + (_albumPreviewData.Index + 1); string eventName = ADEventTrack.Property.vip_secret_albums_unclock_ + (_albumPreviewData.Index + 1);
TrackKit.SendEvent(ADEventTrack.VipSecretAlbums, eventName); TrackKit.SendEvent(ADEventTrack.VipSecretAlbums, eventName);
} }
else else
{ {
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open, 2); uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open, 2);
TrackKit.SendEvent(ADEventTrack.VipSecretAlbums, ADEventTrack.Property.vip_secret_albums_unclock); 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 List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)> _tasks = new();
private void ItemRender(int index, GObject obj) private void ItemRender(int index, GObject obj)
{ {
var item = (item_scAlbumPreview)obj; var item = (item_scAlbumPreview)obj;
var picture = (GLoader)item.com_pic_in.GetChild("picture"); var picture = (GLoader)item.com_pic_in.GetChild("picture");
if (!loader_list.Contains(picture)) if (!loader_list.Contains(picture))
loader_list.Add(picture); loader_list.Add(picture);
var state = GetSafe(_albumPreviewData.State, index); var state = GetSafe(_albumPreviewData.State, index);
item.state.selectedIndex = is_unlock ? 0 : state; item.state.selectedIndex = is_unlock ? 0 : state;
var task = (picture, _secretData[index], (Action<NTexture>)(s => var task = (picture, _secretData[index], (Action<NTexture>)(s =>
{ {
if (picture != null && !picture.isDisposed) if (picture != null && !picture.isDisposed)
{ {
if (!is_unlock && state == 1) if (!is_unlock && state == 1)
TextureHelper.SetImageBlur(picture); TextureHelper.SetImageBlur(picture);
else else
TextureHelper.CancelImageBlur(picture); TextureHelper.CancelImageBlur(picture);
} }
}), $"SecretAlbums/{_albumPreviewData.Name}/", FolderNames.SecretName); }), $"SecretAlbums/{_albumPreviewData.Name}/", FolderNames.SecretName);
_tasks.Add(task); _tasks.Add(task);
item.btn_detail.SetClick(() => item.btn_detail.SetClick(() =>
{ {
if (is_unlock) if (is_unlock)
{ {
var data = new DetailData var data = new DetailData
{ {
Name = _secretData[index], Name = _secretData[index],
Name1 = $"SecretAlbums/{_albumPreviewData.Name}/" Name1 = $"SecretAlbums/{_albumPreviewData.Name}/"
}; };
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretDetailUI_Open, data); UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretDetailUI_Open, data);
} }
else else
{ {
GameHelper.ShowTips("not_unlocked", true); GameHelper.ShowTips("not_unlocked", true);
} }
}); });
if (index == _secretData.Count - 1) if (index == _secretData.Count - 1)
{ {
TextureHelper.SetImgLoaders(_tasks); TextureHelper.SetImgLoaders(_tasks);
} }
} }
private void UpWatchAdsBtn() private void UpWatchAdsBtn()
{ {
DataMgr.SecretUnlockCd.Value.TryGetValue(_albumPreviewData.Index, out var lastTimes); DataMgr.SecretUnlockCd.Value.TryGetValue(_albumPreviewData.Index, out var lastTimes);
if (DataMgr.SecretUnlockADs.Value.TryGetValue(_albumPreviewData.Index, out var unlockAdValue) && if (DataMgr.SecretUnlockADs.Value.TryGetValue(_albumPreviewData.Index, out var unlockAdValue) &&
unlockAdValue >= _albumPreviewData.AD) unlockAdValue >= _albumPreviewData.AD)
{ {
ui.btn_watch.can_buy.selectedIndex = 1; ui.btn_watch.can_buy.selectedIndex = 1;
} }
else else
{ {
ui.btn_watch.can_buy.selectedIndex = 0; ui.btn_watch.can_buy.selectedIndex = 0;
if (GameHelper.GetNowTime() < lastTimes) if (GameHelper.GetNowTime() < lastTimes)
{ {
ui.btn_watch.enabled = false; ui.btn_watch.enabled = false;
ui.btn_watch.CD.selectedIndex = 1; ui.btn_watch.CD.selectedIndex = 1;
ui.btn_watch.watch_cd.text = ui.btn_watch.watch_cd.text =
CommonHelper.TimeFormat(lastTimes - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour); CommonHelper.TimeFormat(lastTimes - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
} }
else else
{ {
ui.btn_watch.enabled = true; ui.btn_watch.enabled = true;
ui.btn_watch.CD.selectedIndex = 0; ui.btn_watch.CD.selectedIndex = 0;
} }
} }
} }
// 拆分字符串为列表 // 拆分字符串为列表
public static List<string> SplitStringToList(string input) public static List<string> SplitStringToList(string input)
{ {
if (string.IsNullOrWhiteSpace(input)) if (string.IsNullOrWhiteSpace(input))
return new List<string>(); return new List<string>();
// 支持英文逗号, 中文逗号,空格 // 支持英文逗号, 中文逗号,空格
char[] separators = new char[] { ',', '', ' ' }; char[] separators = new char[] { ',', '', ' ' };
return input return input
.Split(separators, StringSplitOptions.RemoveEmptyEntries) .Split(separators, StringSplitOptions.RemoveEmptyEntries)
.Select(s => s.Trim()) // 去掉前后空白 .Select(s => s.Trim()) // 去掉前后空白
.ToList(); .ToList();
} }
/// <summary> /// <summary>
/// 安全获取列表或数组中的元素,如果越界则返回最后一个元素;如果为空则返回默认值。 /// 安全获取列表或数组中的元素,如果越界则返回最后一个元素;如果为空则返回默认值。
/// </summary> /// </summary>
public static T GetSafe<T>(IList<T> list, int index, T defaultValue = default) public static T GetSafe<T>(IList<T> list, int index, T defaultValue = default)
{ {
if (list == null || list.Count == 0) if (list == null || list.Count == 0)
return defaultValue; return defaultValue;
if (index < 0) if (index < 0)
return list[0]; return list[0];
if (index >= list.Count) if (index >= list.Count)
return list[list.Count - 1]; return list[list.Count - 1];
return list[index]; return list[index];
} }
} }
public class DetailData public class DetailData
{ {
public string Name; public string Name;
public string Name1; 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 FGUI.ZM_Common_01;
using UnityEngine; using UnityEngine;
using FairyGUI; using FairyGUI;
namespace RedHotRoast namespace RedHotRoast
{ {
public class SubUnlockUI : BaseUI public class SubUnlockUI : BaseUI
{ {
private SubUnlockUICtrl ctrl; private SubUnlockUICtrl ctrl;
private SubUnlockModel model; private SubUnlockModel model;
private FGUI.LG_Unlock.com_SubUnlock ui; private FGUI.LG_Unlock.com_SubUnlock ui;
public SubUnlockUI(SubUnlockUICtrl ctrl) : base(ctrl) public SubUnlockUI(SubUnlockUICtrl ctrl) : base(ctrl)
{ {
uiName = UIConst.SubUnlockUI; uiName = UIConst.SubUnlockUI;
this.ctrl = ctrl; this.ctrl = ctrl;
} }
protected override void SetUIInfo(UIInfo uiInfo) protected override void SetUIInfo(UIInfo uiInfo)
{ {
uiInfo.packageName = "LG_Unlock"; uiInfo.packageName = "LG_Unlock";
uiInfo.assetName = "com_SubUnlock"; uiInfo.assetName = "com_SubUnlock";
uiInfo.layerType = UILayerType.Popup; uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false; uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false; uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true; uiInfo.isNeedUIMask = true;
} }
#region #region
protected override void OnInit() protected override void OnInit()
{ {
//model = ModuleManager.Instance.GetModel(ModelConst.SubUnlockModel) as SubUnlockModel; //model = ModuleManager.Instance.GetModel(ModelConst.SubUnlockModel) as SubUnlockModel;
} }
protected override void OnClose() protected override void OnClose()
{ {
} }
protected override void OnBind() protected override void OnBind()
{ {
ui = baseUI as FGUI.LG_Unlock.com_SubUnlock; ui = baseUI as FGUI.LG_Unlock.com_SubUnlock;
} }
protected override void OnOpenBefore(object args) protected override void OnOpenBefore(object args)
{ {
InitView(); InitView();
} }
protected override void OnOpen(object args) protected override void OnOpen(object args)
{ {
} }
protected override void OnHide() protected override void OnHide()
{ {
} }
protected override void OnDisplay(object args) protected override void OnDisplay(object args)
{ {
} }
#endregion #endregion
#region #region
protected override void AddListener() protected override void AddListener()
{ {
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, refrsh); GameDispatcher.Instance.AddListener(GameMsg.BuyVip, refrsh);
} }
protected override void RemoveListener() protected override void RemoveListener()
{ {
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, refrsh); GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, refrsh);
} }
#endregion #endregion
private void refrsh(object a = null) private void refrsh(object a = null)
{ {
GameHelper.ShowTips("unlock_vip", true); GameHelper.ShowTips("unlock_vip", true);
CtrlCloseUI(); CtrlCloseUI();
} }
//初始化页面逻辑 //初始化页面逻辑
private void InitView() private void InitView()
{ {
ui.btn_close.SetClick(() => ui.btn_close.SetClick(() =>
{ {
CtrlCloseUI(); CtrlCloseUI();
}); });
var vip_list = ConfigSystem.GetConfig<VipClub>(); var vip_list = ConfigSystem.GetConfig<VipClub>();
ui.text_unlockLive.SetVar("num", GameHelper.GetCommonModel().UnlockLive[1].ToString()).FlushVars(); ui.text_unlockLive.SetVar("num", GameHelper.GetCommonModel().UnlockLive[1].ToString()).FlushVars();
ui.text_unlockAlbum.SetVar("num", GameHelper.GetCommonModel().UnlockSecret[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_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_vip1.text_price.text = GameHelper.getPrice((decimal)vip_list[1].DiscountPrice);
ui.btn_vip2.text_price.text = GameHelper.getPrice((decimal)vip_list[2].DiscountPrice); ui.btn_vip2.text_price.text = GameHelper.getPrice((decimal)vip_list[2].DiscountPrice);
if (GameHelper.GetVipLevel() - 1 >= 0) if (GameHelper.GetVipLevel() - 1 >= 0)
{ {
ui.btn_vip0.enabled = false; ui.btn_vip0.enabled = false;
} }
ui.btn_vip0.SetClick(() => ui.btn_vip0.SetClick(() =>
{ {
string _type = "vip_club" + 0; string _type = "vip_club" + 0;
ApplePayClass maxPayData = new ApplePayClass ApplePayClass maxPayData = new ApplePayClass
{ {
amount = (int)System.Math.Round(vip_list[0].DiscountPrice * 100), amount = (int)System.Math.Round(vip_list[0].DiscountPrice * 100),
sku = PurchasingManager.GetPaySku(PayType.weekly_subscription), sku = IAPPayManager.PRODUCT_VIP_WEEK,
currency = "USD", currency = "USD",
shopName = _type shopName = _type
}; };
MaxPayManager.Instance.Buy(maxPayData); MaxPayManager.Instance.Buy(maxPayData);
}); });
if (GameHelper.GetVipLevel() - 1 >= 1) if (GameHelper.GetVipLevel() - 1 >= 1)
{ {
ui.btn_vip1.enabled = false; ui.btn_vip1.enabled = false;
} }
ui.btn_vip1.SetClick(() => ui.btn_vip1.SetClick(() =>
{ {
string _type = "vip_club" + 1; string _type = "vip_club" + 1;
ApplePayClass maxPayData = new ApplePayClass ApplePayClass maxPayData = new ApplePayClass
{ {
amount = (int)System.Math.Round(vip_list[1].DiscountPrice * 100), amount = (int)System.Math.Round(vip_list[1].DiscountPrice * 100),
sku = PurchasingManager.GetPaySku(PayType.monthly_subscription), sku = IAPPayManager.PRODUCT_VIP_MONTH,
currency = "USD", currency = "USD",
shopName = _type shopName = _type
}; };
MaxPayManager.Instance.Buy(maxPayData); MaxPayManager.Instance.Buy(maxPayData);
}); });
if (GameHelper.GetVipLevel() - 1 >= 2) if (GameHelper.GetVipLevel() - 1 >= 2)
{ {
ui.btn_vip2.enabled = false; ui.btn_vip2.enabled = false;
} }
ui.btn_vip2.SetClick(() => ui.btn_vip2.SetClick(() =>
{ {
string _type = "vip_club" + 2; string _type = "vip_club" + 2;
ApplePayClass maxPayData = new ApplePayClass ApplePayClass maxPayData = new ApplePayClass
{ {
amount = (int)System.Math.Round(vip_list[2].DiscountPrice * 100), amount = (int)System.Math.Round(vip_list[2].DiscountPrice * 100),
sku = PurchasingManager.GetPaySku(PayType.yearly_subscription), sku = IAPPayManager.PRODUCT_VIP_YEAR,
currency = "USD", currency = "USD",
shopName = _type shopName = _type
}; };
MaxPayManager.Instance.Buy(maxPayData); MaxPayManager.Instance.Buy(maxPayData);
}); });
} }
} }
} }
@@ -1,430 +1,430 @@
using System.Collections.Generic; using System.Collections.Generic;
using FairyGUI; using FairyGUI;
using FGUI.threeDaysGift; using FGUI.threeDaysGift;
using Spine.Unity; using Spine.Unity;
using DG.Tweening; using DG.Tweening;
using System; using System;
using SGModule.NetKit; using SGModule.NetKit;
namespace RedHotRoast namespace RedHotRoast
{ {
public class ThreeDaysGiftUI : BaseUI public class ThreeDaysGiftUI : BaseUI
{ {
private ThreeDaysGiftUICtrl ctrl; private ThreeDaysGiftUICtrl ctrl;
private ThreeDaysGiftModel model; private ThreeDaysGiftModel model;
private FGUI.threeDaysGift.com_three_days ui; private FGUI.threeDaysGift.com_three_days ui;
public ThreeDaysGiftUI(ThreeDaysGiftUICtrl ctrl) : base(ctrl) public ThreeDaysGiftUI(ThreeDaysGiftUICtrl ctrl) : base(ctrl)
{ {
uiName = UIConst.ThreeDaysGiftUI; uiName = UIConst.ThreeDaysGiftUI;
this.ctrl = ctrl; this.ctrl = ctrl;
} }
protected override void SetUIInfo(UIInfo uiInfo) protected override void SetUIInfo(UIInfo uiInfo)
{ {
uiInfo.packageName = "threeDaysGift"; uiInfo.packageName = "threeDaysGift";
uiInfo.assetName = "com_three_days"; uiInfo.assetName = "com_three_days";
uiInfo.layerType = UILayerType.Popup; uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false; uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false; uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true; uiInfo.isNeedUIMask = true;
} }
#region #region
protected override void OnInit() protected override void OnInit()
{ {
} }
protected override void OnClose() protected override void OnClose()
{ {
HallManager.Instance.UpdateSecondEvent -= InitView; HallManager.Instance.UpdateSecondEvent -= InitView;
GameHelper.showGameUI = true; GameHelper.showGameUI = true;
GameDispatcher.Instance.Dispatch(GameMsg.pack_close); GameDispatcher.Instance.Dispatch(GameMsg.pack_close);
GameHelper.CallShowTurn(); GameHelper.CallShowTurn();
} }
protected override void OnBind() protected override void OnBind()
{ {
ui = baseUI as FGUI.threeDaysGift.com_three_days; ui = baseUI as FGUI.threeDaysGift.com_three_days;
} }
private Action closeCallback; private Action closeCallback;
protected override void OnOpenBefore(object args) protected override void OnOpenBefore(object args)
{ {
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.three_days_gift_show); TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.three_days_gift_show);
list = ConfigSystem.GetConfig<Multigift>(); list = ConfigSystem.GetConfig<Multigift>();
ui.btn_close.SetClick(() => ui.btn_close.SetClick(() =>
{ {
GameDispatcher.Instance.Dispatch(GameMsg.ThreeDaysGiftUIClose); GameDispatcher.Instance.Dispatch(GameMsg.ThreeDaysGiftUIClose);
CtrlCloseUI(); CtrlCloseUI();
}); });
ui.groups.visible = false; ui.groups.visible = false;
var ske_bg = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_bg, Fx_Type.fx_three_gift, ref closeCallback); 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.SetAnimation(0, "3_days", false);
ske_bg.state.Complete += (a) => ske_bg.state.Complete += (a) =>
{ {
ske_bg.state.SetAnimation(0, "3_days_dj", false); ske_bg.state.SetAnimation(0, "3_days_dj", false);
}; };
DOVirtual.DelayedCall(0.5f, () => DOVirtual.DelayedCall(0.5f, () =>
{ {
ui.groups.visible = true; ui.groups.visible = true;
}); });
InitView(); InitView();
HallManager.Instance.UpdateSecondEvent += InitView; HallManager.Instance.UpdateSecondEvent += InitView;
// //
} }
protected override void OnOpen(object args) protected override void OnOpen(object args)
{ {
} }
protected override void OnHide() protected override void OnHide()
{ {
} }
protected override void OnDisplay(object args) protected override void OnDisplay(object args)
{ {
} }
#endregion #endregion
#region #region
protected override void AddListener() 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.rewardMul_close, rewardMul_close); // GameDispatcher.Instance.AddListener(GameMsg.rewardMul_close, rewardMul_close);
} }
protected override void RemoveListener() 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.rewardMul_close, rewardMul_close); // GameDispatcher.Instance.RemoveListener(GameMsg.rewardMul_close, rewardMul_close);
} }
#endregion #endregion
void pay_success(object str) void pay_success(object str)
{ {
string type = (string)str; // string type = (string)str;
if (type == PurchasingManager.GetPaySku(PayType.three_days_gift)) // if (type == PurchasingManager.GetPaySku(PayType.three_days_gift))
{ // {
//
// var start = Vector2.zero; // // var start = Vector2.zero;
// if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day1) { // // if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day1) {
// start = GameHelper.GetUICenterPosition(ui.day1.item1.lab_num); // // start = GameHelper.GetUICenterPosition(ui.day1.item1.lab_num);
// } else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day2) { // // } else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day2) {
// start = GameHelper.GetUICenterPosition(ui.day2.item1.lab_num); // // start = GameHelper.GetUICenterPosition(ui.day2.item1.lab_num);
// } else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day3) { // // } else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day3) {
// start = GameHelper.GetUICenterPosition(ui.day3.item1.lab_num); // // start = GameHelper.GetUICenterPosition(ui.day3.item1.lab_num);
// } // // }
// // //
// var rewardData = new RewardData(); // // var rewardData = new RewardData();
// var end = GameHelper.GetUICenterPosition(ui.node_end); // // var end = GameHelper.GetUICenterPosition(ui.node_end);
// // //
// var rewardSingleData = new RewardSingleData(101, list[1].coins_quantity, RewardOrigin.AdTask) // // var rewardSingleData = new RewardSingleData(101, list[1].coins_quantity, RewardOrigin.AdTask)
// { // // {
// startPosition = start, // // startPosition = start,
// endPosition = end // // endPosition = end
// }; // // };
// // //
// rewardData.AddReward(rewardSingleData); // // rewardData.AddReward(rewardSingleData);
// rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange; // // rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
// rewardData.AddCompleted(success => // // rewardData.AddCompleted(success =>
// { // // {
// // if (success) // // // if (success)
// // { // // // {
// // RefreshGold(awardNum); // // // RefreshGold(awardNum);
// // } // // // }
// }); // // });
// // //
// GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData); // // GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
// // DataMgr.Coin.Value -= list[1].coins_quantity; // // // DataMgr.Coin.Value -= list[1].coins_quantity;
// // //
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AdcomingUI_Close); // // UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AdcomingUI_Close);
// SaveData.GetSaveObject().is_get_removead = true; // // SaveData.GetSaveObject().is_get_removead = true;
// InitView(); // // InitView();
//
ui.pay_type.selectedIndex = 2; // ui.pay_type.selectedIndex = 2;
} // }
// GameDispatcher.Instance.Dispatch(GameMsg.noads_refresh); // // GameDispatcher.Instance.Dispatch(GameMsg.noads_refresh);
//
} }
void rewardMul_close(object str) void rewardMul_close(object str)
{ {
if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day1) if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day1)
{ {
TrackKit.SendEvent(ThreeDaysGiftEventTrack.Event, ThreeDaysGiftEventTrack.Property.three_day1_success); TrackKit.SendEvent(ThreeDaysGiftEventTrack.Event, ThreeDaysGiftEventTrack.Property.three_day1_success);
} }
else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day2) else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day2)
{ {
TrackKit.SendEvent(ThreeDaysGiftEventTrack.Event, ThreeDaysGiftEventTrack.Property.three_day2_success); TrackKit.SendEvent(ThreeDaysGiftEventTrack.Event, ThreeDaysGiftEventTrack.Property.three_day2_success);
} }
else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day3) else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day3)
{ {
TrackKit.SendEvent(ThreeDaysGiftEventTrack.Event, ThreeDaysGiftEventTrack.Property.three_day3_success); TrackKit.SendEvent(ThreeDaysGiftEventTrack.Event, ThreeDaysGiftEventTrack.Property.three_day3_success);
} }
SaveData.GetSaveObject().three_gift_got_index++; SaveData.GetSaveObject().three_gift_got_index++;
SaveData.GetSaveObject().last_got_three_gift_time = GameHelper.GetNowTime(); SaveData.GetSaveObject().last_got_three_gift_time = GameHelper.GetNowTime();
} }
private List<Multigift> list; private List<Multigift> list;
// int adNums = AdExchangeManager.Instance.GetLookRewardADNum(); // int adNums = AdExchangeManager.Instance.GetLookRewardADNum();
// adNums++; // adNums++;
// AdExchangeManager.Instance.SetLookRewardADNum(adNums); // AdExchangeManager.Instance.SetLookRewardADNum(adNums);
private void InitView() private void InitView()
{ {
ui.text_have.text = Language.GetContentParams("owner_ad", AdExchangeManager.Instance.GetLookRewardADNum()); ui.text_have.text = Language.GetContentParams("owner_ad", AdExchangeManager.Instance.GetLookRewardADNum());
ui.need_text.text = Language.GetContentParams("need_ad", list[0].Paid_price); ui.need_text.text = Language.GetContentParams("need_ad", list[0].Paid_price);
initItem(0); initItem(0);
initItem(1); initItem(1);
initItem(2); initItem(2);
FGUI.threeDaysGift.btn_watchAd btn_buypack = (ui.btn_buypack as FGUI.threeDaysGift.btn_watchAd); FGUI.threeDaysGift.btn_watchAd btn_buypack = (ui.btn_buypack as FGUI.threeDaysGift.btn_watchAd);
GObject pack_title = ui.btn_buypack.GetChild("btn_text"); GObject pack_title = ui.btn_buypack.GetChild("btn_text");
if (SaveData.GetSaveObject().is_get_ThreeDaysGift) if (SaveData.GetSaveObject().is_get_ThreeDaysGift)
{ {
ui.pay_type.selectedIndex = 2; ui.pay_type.selectedIndex = 2;
var isToday = GameHelper.InToday(SaveData.GetSaveObject().last_got_three_gift_time, 0, true); var isToday = GameHelper.InToday(SaveData.GetSaveObject().last_got_three_gift_time, 0, true);
int three_gift_got_index = SaveData.GetSaveObject().three_gift_got_index; int three_gift_got_index = SaveData.GetSaveObject().three_gift_got_index;
if (isToday || (three_gift_got_index > (int)rewardState.day3)) if (isToday || (three_gift_got_index > (int)rewardState.day3))
{ {
ui.btn_get.grayed = true; ui.btn_get.grayed = true;
ui.btn_get.SetClick(() => ui.btn_get.SetClick(() =>
{ {
if (three_gift_got_index < (int)rewardState.day3) if (three_gift_got_index < (int)rewardState.day3)
{ {
GameHelper.ShowTips("pick_tomorrow",true); GameHelper.ShowTips("pick_tomorrow",true);
} }
}); });
} }
else else
{ {
ui.btn_get.SetClick(() => ui.btn_get.SetClick(() =>
{ {
getReward(); getReward();
ui.btn_get.SetClick(() => { }); ui.btn_get.SetClick(() => { });
}); });
} }
} }
else else
{ {
if (!GameHelper.IsAdModelOfPay()) if (!GameHelper.IsAdModelOfPay())
{ {
ui.pay_type.selectedIndex = 1; ui.pay_type.selectedIndex = 1;
decimal price_pack = (decimal)list[0].Paid_price2; decimal price_pack = (decimal)list[0].Paid_price2;
ui.btn_max_pack.title = GameHelper.Get102Str(price_pack); ui.btn_max_pack.title = GameHelper.Get102Str(price_pack);
bool is_get = SaveData.GetSaveObject().is_get_ThreeDaysGift; bool is_get = SaveData.GetSaveObject().is_get_ThreeDaysGift;
if (is_get) if (is_get)
{ {
ui.btn_max_pack.enabled = false; ui.btn_max_pack.enabled = false;
ui.btn_max_pack.SetClick(() => { }); ui.btn_max_pack.SetClick(() => { });
} }
else else
{ {
ui.btn_max_pack.SetClick(() => ui.btn_max_pack.SetClick(() =>
{ {
ApplePayClass maxPayData = new ApplePayClass // ApplePayClass maxPayData = new ApplePayClass
{ // {
amount = (int)Math.Round(price_pack * 100), // amount = (int)Math.Round(price_pack * 100),
sku =PurchasingManager.GetPaySku(PayType.three_days_gift), // sku =PurchasingManager.GetPaySku(PayType.three_days_gift),
currency = "USD" // currency = "USD"
}; // };
MaxPayManager.Instance.Buy(maxPayData); // MaxPayManager.Instance.Buy(maxPayData);
}); });
} }
} }
else else
{ {
ui.pay_type.selectedIndex = 0; ui.pay_type.selectedIndex = 0;
bool is_get = SaveData.GetSaveObject().is_get_ThreeDaysGift; bool is_get = SaveData.GetSaveObject().is_get_ThreeDaysGift;
if (is_get) if (is_get)
{ {
btn_buypack.buy_state.selectedIndex = 0; btn_buypack.buy_state.selectedIndex = 0;
btn_buypack.can_buy.selectedIndex = 1; btn_buypack.can_buy.selectedIndex = 1;
ui.btn_buypack.grayed = true; ui.btn_buypack.grayed = true;
pack_title.text = Language.GetContent("claimed"); pack_title.text = Language.GetContent("claimed");
ui.btn_buypack.SetClick(() => ui.btn_buypack.SetClick(() =>
{ {
}); });
} }
else if (AdExchangeManager.Instance.GetLookRewardADNum() >= list[0].Paid_price) else if (AdExchangeManager.Instance.GetLookRewardADNum() >= list[0].Paid_price)
{ {
btn_buypack.buy_state.selectedIndex = 1; btn_buypack.buy_state.selectedIndex = 1;
btn_buypack.can_buy.selectedIndex = 0; btn_buypack.can_buy.selectedIndex = 0;
btn_buypack.SetClick(() => btn_buypack.SetClick(() =>
{ {
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.three_days_gift_buy_success); TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.three_days_gift_buy_success);
// SaveData.GetSaveObject().look_ad_numbers // SaveData.GetSaveObject().look_ad_numbers
int adNums = AdExchangeManager.Instance.GetLookRewardADNum(); int adNums = AdExchangeManager.Instance.GetLookRewardADNum();
adNums -= (int)list[0].Paid_price; adNums -= (int)list[0].Paid_price;
AdExchangeManager.Instance.SetLookRewardADNum(adNums); AdExchangeManager.Instance.SetLookRewardADNum(adNums);
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, PurchasingManager.GetPaySku(PayType.three_days_gift)); // GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, PurchasingManager.GetPaySku(PayType.three_days_gift));
// getReward(); // getReward();
ui.btn_buypack.SetClick(() => { }); ui.btn_buypack.SetClick(() => { });
}); });
} }
else if (SaveData.GetSaveObject()._watch_ad_cd > GameHelper.GetNowTime()) else if (SaveData.GetSaveObject()._watch_ad_cd > GameHelper.GetNowTime())
{ {
btn_buypack.buy_state.selectedIndex = 0; btn_buypack.buy_state.selectedIndex = 0;
btn_buypack.can_buy.selectedIndex = 1; btn_buypack.can_buy.selectedIndex = 1;
pack_title.text = CommonHelper.TimeFormat(SaveData.GetSaveObject()._watch_ad_cd - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour); pack_title.text = CommonHelper.TimeFormat(SaveData.GetSaveObject()._watch_ad_cd - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
btn_buypack.SetClick(() => { }); btn_buypack.SetClick(() => { });
} }
else else
{ {
btn_buypack.buy_state.selectedIndex = 0; btn_buypack.buy_state.selectedIndex = 0;
btn_buypack.can_buy.selectedIndex = 0; btn_buypack.can_buy.selectedIndex = 0;
pack_title.text = Language.GetContent("watch_ad"); pack_title.text = Language.GetContent("watch_ad");
btn_buypack.SetClick(() => btn_buypack.SetClick(() =>
{ {
GameHelper.ShowVideoAd("ThreeDaysGift", (issuccess) => GameHelper.ShowVideoAd("ThreeDaysGift", (issuccess) =>
{ {
if (issuccess) if (issuccess)
{ {
SaveData.GetSaveObject()._watch_ad_cd = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().exchangeCD; SaveData.GetSaveObject()._watch_ad_cd = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().exchangeCD;
InitView(); InitView();
} }
}); });
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.three_days_gift_click); TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.three_days_gift_click);
}); });
} }
} }
} }
} }
private void initItem(int index) private void initItem(int index)
{ {
com_item day = null; com_item day = null;
if (index == 0) if (index == 0)
{ {
day = ui.day1; day = ui.day1;
} }
else if (index == 1) else if (index == 1)
{ {
day = ui.day2; day = ui.day2;
} }
else if (index == 2) else if (index == 2)
{ {
day = ui.day3; day = ui.day3;
} }
if (SaveData.GetSaveObject().three_gift_got_index - 1 > index) if (SaveData.GetSaveObject().three_gift_got_index - 1 > index)
{ {
day.img_select.visible = true; day.img_select.visible = true;
if (SaveData.GetSaveObject().three_gift_got_index - 1 > 2) if (SaveData.GetSaveObject().three_gift_got_index - 1 > 2)
{ {
day.img_select2.visible = true; day.img_select2.visible = true;
} }
} }
if (index == 2) if (index == 2)
{ {
day.state.selectedIndex = 3; day.state.selectedIndex = 3;
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
item_reward item = day.GetChild("item" + (i + 2)) as item_reward; item_reward item = day.GetChild("item" + (i + 2)) as item_reward;
item.visible = false; item.visible = false;
} }
} }
else else
{ {
day.state.selectedIndex = list[index].props_quantity.Length; day.state.selectedIndex = list[index].props_quantity.Length;
} }
setItemUrl(day.item1.loader_, GiftType.coin); setItemUrl(day.item1.loader_, GiftType.coin);
day.item1.lab_num.text = "x" + list[index].coins_quantity; day.item1.lab_num.text = "x" + list[index].coins_quantity;
for (int i = 0; i < list[index].props_quantity.Length; i++) for (int i = 0; i < list[index].props_quantity.Length; i++)
{ {
item_reward item = (day.GetChild("item" + (i + 2)) as item_reward); item_reward item = (day.GetChild("item" + (i + 2)) as item_reward);
setItemUrl(item.loader_, (GiftType)list[index].props_type[i]); setItemUrl(item.loader_, (GiftType)list[index].props_type[i]);
item.visible = true; item.visible = true;
item.lab_num.text = "x" + list[index].props_quantity[i]; item.lab_num.text = "x" + list[index].props_quantity[i];
} }
} }
private void setItemUrl(GLoader loader, GiftType urltype) private void setItemUrl(GLoader loader, GiftType urltype)
{ {
if (urltype == GiftType.coin) loader.url = "ui://threeDaysGift/3DAYS_prs_001"; 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.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.refresh) loader.url = "ui://threeDaysGift/3DAYS_prs_002";
else if (urltype == GiftType.undo) loader.url = "ui://threeDaysGift/3DAYS_prs_004"; else if (urltype == GiftType.undo) loader.url = "ui://threeDaysGift/3DAYS_prs_004";
} }
private void getReward() private void getReward()
{ {
int index = SaveData.GetSaveObject().three_gift_got_index; int index = SaveData.GetSaveObject().three_gift_got_index;
com_item item = null; com_item item = null;
if (index == (int)rewardState.day1) if (index == (int)rewardState.day1)
{ {
item = ui.day1; item = ui.day1;
} }
else if (index == (int)rewardState.day2) else if (index == (int)rewardState.day2)
{ {
item = ui.day2; item = ui.day2;
} }
else if (index == (int)rewardState.day3) else if (index == (int)rewardState.day3)
{ {
item = ui.day3; item = ui.day3;
} }
item.img_select.visible = true; item.img_select.visible = true;
List<int> types = new List<int>(); List<int> types = new List<int>();
List<int> rewards = new List<int>(); List<int> rewards = new List<int>();
types.Add((int)GiftType.coin); types.Add((int)GiftType.coin);
rewards.Add(list[index - 1].coins_quantity); rewards.Add(list[index - 1].coins_quantity);
for (int i = 0; i < list[index - 1].props_quantity.Length; i++) for (int i = 0; i < list[index - 1].props_quantity.Length; i++)
{ {
types.Add(list[index - 1].props_type[i]); // GiftType 类型 types.Add(list[index - 1].props_type[i]); // GiftType 类型
rewards.Add(list[index - 1].props_quantity[i]); rewards.Add(list[index - 1].props_quantity[i]);
} }
GiftData data = new GiftData(); GiftData data = new GiftData();
data.type = types; data.type = types;
data.reward = rewards; data.reward = rewards;
uiCtrlDispatcher.Dispatch(UICtrlMsg.RewardMulNewUI_Open, data); uiCtrlDispatcher.Dispatch(UICtrlMsg.RewardMulNewUI_Open, data);
} }
} }
} }
enum rewardState enum rewardState
{ {
day1 = 1, day1 = 1,
day2, day2,
day3 day3
} }
public class GiftData public class GiftData
{ {
public List<int> type; public List<int> type;
public List<int> reward; public List<int> reward;
public string uiName; public string uiName;
} }
public enum GiftType : int public enum GiftType : int
{ {
coin = 101, coin = 101,
move_out = 0, move_out = 0,
undo = 1, undo = 1,
refresh = 2, refresh = 2,
} }
@@ -182,13 +182,13 @@ namespace RedHotRoast
protected override void AddListener() 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); GameDispatcher.Instance.AddListener(GameMsg.BuyVip, InitView);
} }
protected override void RemoveListener() 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); GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, InitView);
} }
@@ -221,6 +221,8 @@ namespace RedHotRoast
ui.btn_restore.visible = !GameHelper.IsGiftSwitch(); ui.btn_restore.visible = !GameHelper.IsGiftSwitch();
ui.btn_restore.SetClick(() => ui.btn_restore.SetClick(() =>
{ {
IAPPayManager.Instance.OnRestoreButtonClicked();
// ApplePayManager.Instance.AppleRestore((success, message) => // ApplePayManager.Instance.AppleRestore((success, message) =>
// { // {
// Debug.Log($"[barry] restore success message: {message}---- {JsonConvert.SerializeObject(message)}"); // Debug.Log($"[barry] restore success message: {message}---- {JsonConvert.SerializeObject(message)}");
@@ -258,7 +260,7 @@ namespace RedHotRoast
ApplePayClass maxPayData = new ApplePayClass ApplePayClass maxPayData = new ApplePayClass
{ {
amount = (int)System.Math.Round(vip_list[_level].DiscountPrice * 100), amount = (int)System.Math.Round(vip_list[_level].DiscountPrice * 100),
sku = PurchasingManager.GetPaySku(GetTypeByIndex(_level)), sku = GetTypeByIndex(_level),
currency = "USD", currency = "USD",
shopName = _type shopName = _type
}; };
@@ -278,14 +280,14 @@ namespace RedHotRoast
ui.vip_icon_loader.url = $"ui://LG_Common/vip_{lv}"; ui.vip_icon_loader.url = $"ui://LG_Common/vip_{lv}";
} }
private PayType GetTypeByIndex(int index) private string GetTypeByIndex(int index)
{ {
return index switch return index switch
{ {
0 => PayType.weekly_subscription, 0 => IAPPayManager.PRODUCT_VIP_WEEK,
1 => PayType.monthly_subscription, 1 => IAPPayManager.PRODUCT_VIP_MONTH,
2 => PayType.yearly_subscription, 2 => IAPPayManager.PRODUCT_VIP_YEAR,
_ => PayType.weekly_subscription _ => IAPPayManager.PRODUCT_VIP_WEEK
}; };
} }
+176 -119
View File
@@ -1,30 +1,29 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
// using SGModule.ApplePay;
using SGModule.NetKit; using SGModule.NetKit;
using UnityEngine; using UnityEngine;
using RedHotRoast; using RedHotRoast;
// using UnityEngine.Purchasing;
using Newtonsoft.Json; using Newtonsoft.Json;
using SGModule.Net;
using UnityEngine.Events;
public enum PayType // public enum PayType
{ // {
buy_one, // buy_one,
buy_one_off, // buy_one_off,
buy_gold_1, // buy_gold_1,
buy_gold_2, // buy_gold_2,
buy_gold_3, // buy_gold_3,
buy_gold_4, // buy_gold_4,
buy_gold_5, // buy_gold_5,
remove_ad, // remove_ad,
battle_pass, // battle_pass,
pack_reward, // pack_reward,
fail_pack, // fail_pack,
three_days_gift, // three_days_gift,
weekly_subscription, // weekly_subscription,
monthly_subscription, // monthly_subscription,
yearly_subscription, // yearly_subscription,
} // }
public class PurchasingManager public class PurchasingManager
{ {
@@ -32,42 +31,42 @@ public class PurchasingManager
private static readonly List<ApplePay> PayConfig = ConfigSystem.GetConfig<ApplePay>(); private static readonly List<ApplePay> PayConfig = ConfigSystem.GetConfig<ApplePay>();
private static readonly List<ApplePay2> PayConfig2 = ConfigSystem.GetConfig<ApplePay2>(); private static readonly List<ApplePay2> PayConfig2 = ConfigSystem.GetConfig<ApplePay2>();
public static string GetPaySku(PayType key) // public static string GetPaySku(PayType key)
{ // {
string keys = ""; // string keys = "";
//
if (PayConfig != null) // if (PayConfig != null)
{ // {
foreach (var data in PayConfig) // foreach (var data in PayConfig)
{ // {
if (data.payKey != key.ToString()) continue; // if (data.payKey != key.ToString()) continue;
keys = data.sku; // keys = data.sku;
break; // break;
} // }
} // }
//
return keys; // return keys;
} // }
//
public static int GetVipLvFormConfig(string sku) // public static int GetVipLvFormConfig(string sku)
{ // {
var lv = 1; // var lv = 1;
//
if (GetPaySku(PayType.weekly_subscription) == sku) // if (GetPaySku(PayType.weekly_subscription) == sku)
{ // {
lv = 1; // lv = 1;
} // }
else if (GetPaySku(PayType.monthly_subscription) == sku) // else if (GetPaySku(PayType.monthly_subscription) == sku)
{ // {
lv = 2; // lv = 2;
} // }
else if (GetPaySku(PayType.yearly_subscription) == sku) // else if (GetPaySku(PayType.yearly_subscription) == sku)
{ // {
lv = 3; // lv = 3;
} // }
//
return lv; // return lv;
} // }
public static void Purchase(ApplePayData payData) public static void Purchase(ApplePayData payData)
@@ -75,13 +74,28 @@ public class PurchasingManager
//本地测试 //本地测试
// TestIOSPay(payData); // TestIOSPay(payData);
// return; // return;
Debug.Log($"[Apple Pay] unity Purchase--0-----: {payData.sku}"); Debug.Log($"[Apple Pay] unity Purchase--0-----: {payData.sku}");
// ApplePayManager.Instance.Purchase(payData.sku, ApplePaySuccessCallback(payData), message => // ApplePayManager.Instance.Purchase(payData.sku, ApplePaySuccessCallback(payData), message =>
// { // {
// Debug.Log("purchase fail------- reason: " + message); // Debug.Log("purchase fail------- reason: " + message);
// }); // });
if (payData.sku.Contains("sub"))
{
IAPPayManager.Instance.SubscribeProduct(payData.sku, "",() =>
{
});
}
else
{
IAPPayManager.Instance.BuyProduct(payData.sku, "",() =>
{
});
}
} }
// public static Action<ApplePayBackType, AppleResponseData> ApplePaySuccessCallback(ApplePayData payData) // public static Action<ApplePayBackType, AppleResponseData> ApplePaySuccessCallback(ApplePayData payData)
@@ -112,7 +126,7 @@ public class PurchasingManager
// var sku = SetSku(payData); // var sku = SetSku(payData);
// //
// Debug.Log($"[Apple Pay] Check sku===2===== {sku}"); // Debug.Log($"[Apple Pay] Check sku===2===== {sku}");
// GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, sku); // GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, sku);
// Debug.Log($"[Apple Pay] Check sku===3===== {sku}"); // Debug.Log($"[Apple Pay] Check sku===3===== {sku}");
// //
// SendEventClickByName(sku, "open"); // SendEventClickByName(sku, "open");
@@ -148,31 +162,69 @@ public class PurchasingManager
// ApplePayManager.Instance.ApplePayTest(types, payData.sku, tranId, ApplePaySuccessCallback(payData)); // ApplePayManager.Instance.ApplePayTest(types, payData.sku, tranId, ApplePaySuccessCallback(payData));
// } // }
private static string SetSku(ApplePayData data) // private static string SetSku(ApplePayData data)
// {
// string sku = "";
// if (data.type != null && data.type == GetPaySku(PayType.remove_ad))
// {
// sku = data.type;
// }
// else if (data.sku.Contains("shop"))
// {
// sku = data.shopName;
// }
// else if (data.sku.Contains("sub"))
// {
// sku = data.shopName;
// }
// else
// {
// sku = data.sku;
// }
//
// return sku;
// }
// 商店商品映射表
public static readonly Dictionary<string, string> ShopProductMap = new Dictionary<string, string>
{ {
string sku = ""; { IAPPayManager.PRODUCT_SHOP_1, "0" },
if (data.type != null && data.type == GetPaySku(PayType.remove_ad)) { IAPPayManager.PRODUCT_SHOP_2, "1" },
{ { IAPPayManager.PRODUCT_SHOP_3, "2" },
sku = data.type; { IAPPayManager.PRODUCT_SHOP_4, "3" },
} { IAPPayManager.PRODUCT_SHOP_5, "4" }
else if (data.sku.Contains("shop")) };
{
sku = data.shopName; // 订阅商品映射表
} public static readonly Dictionary<string, string> VipProductMap = new Dictionary<string, string>
else if (data.sku.Contains("sub")) {
{ { IAPPayManager.PRODUCT_VIP_WEEK, "0" },
sku = data.shopName; { IAPPayManager.PRODUCT_VIP_MONTH, "1" },
} { IAPPayManager.PRODUCT_VIP_YEAR, "2" },
else };
{
sku = data.sku;
}
return sku; /// <summary>
/// 更新map中的value,与配置表的id对应
/// _shopProductMap
/// </summary>
public static void SetShopMapValue()
{
var list = ConfigSystem.GetConfig<Paidcoins>();
if (list is not { Count: > 0 }) return;
foreach (var paidcoin in list)
{
if (string.IsNullOrEmpty(paidcoin.SKU))
continue;
if (ShopProductMap.ContainsKey(paidcoin.SKU))
{
ShopProductMap[paidcoin.SKU] = (paidcoin.id - 1).ToString();
}
}
} }
public static void SendEventClickByName(string name, string type)
private static void SendEventClickByName(string name, string type)
{ {
if (name == null) if (name == null)
{ {
@@ -183,64 +235,60 @@ public class PurchasingManager
string successTrackKey = null; string successTrackKey = null;
string openTrackKey = null; string openTrackKey = null;
if (name == GetPaySku(PayType.pack_reward)) if (name == IAPPayManager.PRODUCT_FIRST_GIFT)
{ {
clickTrackKey = ADEventTrack.Property.lucky_gift_click; clickTrackKey = ADEventTrack.Property.lucky_gift_click;
successTrackKey = ADEventTrack.Property.lucky_gift_receive; successTrackKey = ADEventTrack.Property.lucky_gift_receive;
openTrackKey = ADEventTrack.Property.first_pack_show; openTrackKey = ADEventTrack.Property.first_pack_show;
} }
else if (name == GetPaySku(PayType.remove_ad)) else if (name == IAPPayManager.PRODUCT_REMOVE_ADS)
{ {
clickTrackKey = ADEventTrack.Property.remove_ad_click; clickTrackKey = ADEventTrack.Property.remove_ad_click;
successTrackKey = ADEventTrack.Property.remove_ad_receive; successTrackKey = ADEventTrack.Property.remove_ad_receive;
openTrackKey = ADEventTrack.Property.gift_show; openTrackKey = ADEventTrack.Property.gift_show;
} }
else if (name == GetPaySku(PayType.battle_pass)) else if (name == IAPPayManager.PRODUCT_PASS_BONUS)
{ {
clickTrackKey = ADEventTrack.Property.master_pass_click; clickTrackKey = ADEventTrack.Property.master_pass_click;
successTrackKey = ADEventTrack.Property.master_pass_receive; successTrackKey = ADEventTrack.Property.master_pass_receive;
openTrackKey = ADEventTrack.Property.master_pass_show; openTrackKey = ADEventTrack.Property.master_pass_show;
} }
else if (name == GetPaySku(PayType.buy_one)) else if (name == IAPPayManager.PRODUCT_SPACE_BONUS)
{ {
clickTrackKey = ADEventTrack.Property.buy_one_click; clickTrackKey = ADEventTrack.Property.buy_one_click;
successTrackKey = ADEventTrack.Property.buy_one_success; successTrackKey = ADEventTrack.Property.buy_one_success;
openTrackKey = ADEventTrack.Property.buy_one_show; openTrackKey = ADEventTrack.Property.buy_one_show;
} }
else if (name == GetPaySku(PayType.buy_one_off)) // else if (name == GetPaySku(PayType.buy_one_off))
{ // {
// clickTrackKey = ADEventTrack.Property.BuyOneOffClick; // // clickTrackKey = ADEventTrack.Property.BuyOneOffClick;
// successTrackKey = ADEventTrack.Property.BuyOneOffSuccess; // // successTrackKey = ADEventTrack.Property.BuyOneOffSuccess;
// openTrackKey = ADEventTrack.Property.BuyOneOffShow; // // openTrackKey = ADEventTrack.Property.BuyOneOffShow;
} // }
else if (name == GetPaySku(PayType.fail_pack)) // else if (name == GetPaySku(PayType.fail_pack))
{ // {
clickTrackKey = ADEventTrack.Property.fail_click; // clickTrackKey = ADEventTrack.Property.fail_click;
successTrackKey = ADEventTrack.Property.fail_buy_success; // successTrackKey = ADEventTrack.Property.fail_buy_success;
openTrackKey = ADEventTrack.Property.fail_show; // openTrackKey = ADEventTrack.Property.fail_show;
} // }
else if (name == GetPaySku(PayType.three_days_gift)) // else if (name == GetPaySku(PayType.three_days_gift))
{ // {
clickTrackKey = ADEventTrack.Property.three_days_gift_click; // clickTrackKey = ADEventTrack.Property.three_days_gift_click;
successTrackKey = ADEventTrack.Property.three_days_gift_buy_success; // successTrackKey = ADEventTrack.Property.three_days_gift_buy_success;
openTrackKey = ADEventTrack.Property.three_days_gift_show; // openTrackKey = ADEventTrack.Property.three_days_gift_show;
} // }
if (name.StartsWith("buy_gold")) else if (ShopProductMap.TryGetValue(name, out var idx))
{ {
int startIndex = "buy_gold".Length; clickTrackKey = ADEventTrack.Property.gold_click_ + idx;
string suffix = name[startIndex..]; // 截取 "gold" 后的所有字符 successTrackKey = ADEventTrack.Property.shop_receive_ + idx;
clickTrackKey = ADEventTrack.Property.gold_click_ + suffix;
successTrackKey = ADEventTrack.Property.shop_receive_ + suffix;
openTrackKey = ADEventTrack.Property.shop_show; openTrackKey = ADEventTrack.Property.shop_show;
} }
if (name.StartsWith("vip_club")) else if (VipProductMap.TryGetValue(name, out var vipIdx))
{ {
int startIndex = "vip_club".Length; clickTrackKey = ADEventTrack.Property.vip_click_ + vipIdx;
string suffix = name[startIndex..]; // 截取 "gold" 后的所有字符 successTrackKey = ADEventTrack.Property.vip_success_ + vipIdx;
clickTrackKey = ADEventTrack.Property.vip_click_ + suffix;
successTrackKey = ADEventTrack.Property.vip_success_ + suffix;
openTrackKey = ADEventTrack.Property.buy_one_show; openTrackKey = ADEventTrack.Property.buy_one_show;
} }
@@ -254,13 +302,20 @@ public class PurchasingManager
} }
else if (type == "open" && openTrackKey != null) else if (type == "open" && openTrackKey != null)
{ {
// TrackKit.SendEvent(ADEventTrack.IOS_Pay_Event, openTrackKey); TrackKit.SendEvent(ADEventTrack.IOS_Pay_Event, openTrackKey);
} }
} }
/// <summary>
/// ios支付创建订单接口,改一下用来上传数据给后台统计支付数据
/// </summary>
/// <param name="data"></param>
/// <param name="onCompleted"></param>
public static void ApplePayCreate<T>(ApplePayData data, UnityAction<ResponseData<T>> onCompleted = null)
{
NetKit.Instance.Post<T>("shop/applePayCreate", data,
response => { onCompleted?.Invoke(response); });
}
} }
public class ApplePayData public class ApplePayData
{ {
@@ -276,6 +331,8 @@ public class ApplePayData
public string shopName; public string shopName;
[JsonProperty("type")] [JsonProperty("type")]
public string type; public string type;
[JsonProperty("isCompleted")]
public bool isCompleted;
} }
@@ -125,7 +125,7 @@ namespace RedHotRoast {
b = GetCommonConf().IsOrganic == 1; b = GetCommonConf().IsOrganic == 1;
} }
Debug.Log($"下载---------开关:{b}"); // Debug.Log($"下载---------开关:{b}");
return b; return b;
} }
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -1009,11 +1009,11 @@ PlayerSettings:
apiCompatibilityLevel: 6 apiCompatibilityLevel: 6
activeInputHandler: 0 activeInputHandler: 0
windowsGamepadBackendHint: 0 windowsGamepadBackendHint: 0
cloudProjectId: cloudProjectId: 3fce7f77-ba31-4650-89e2-ae642f62eb2c
framebufferDepthMemorylessMode: 0 framebufferDepthMemorylessMode: 0
qualitySettingsNames: [] qualitySettingsNames: []
projectName: projectName: Red-Hot Roast
organizationId: organizationId: ipfang
cloudEnabled: 0 cloudEnabled: 0
legacyClampBlendShapeWeights: 0 legacyClampBlendShapeWeights: 0
hmiLoadingImage: {fileID: 0} hmiLoadingImage: {fileID: 0}
+1
View File
@@ -1,4 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AJsonPropertyAttribute_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F97354_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F761cf2a144514d2291a678c334d49e9baa000_003Fd2_003F103dd213_003FJsonPropertyAttribute_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AResources_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F97354_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F37cc348edc804f4cb176b63962c716e7177200_003Fea_003Ffcad8965_003FResources_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AResources_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F97354_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F37cc348edc804f4cb176b63962c716e7177200_003Fea_003Ffcad8965_003FResources_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASettingsUI_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F97354_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F6e53694256e748aaa40387bd9aae590a19400_003F8f_003F4404ef43_003FSettingsUI_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASettingsUI_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003F97354_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F6e53694256e748aaa40387bd9aae590a19400_003F8f_003F4404ef43_003FSettingsUI_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASetupCoroutine_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2026_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Feaa93d1ff51f46939e13cc06b5754f3d177000_003F3a_003F4f590d28_003FSetupCoroutine_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASetupCoroutine_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2026_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Feaa93d1ff51f46939e13cc06b5754f3d177000_003F3a_003F4f590d28_003FSetupCoroutine_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>