fix:1、添加支付,使用sdk的支付方案
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,68 +1,68 @@
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public static partial class GameMsg
|
||||
{
|
||||
public static readonly uint OpenGame = ++Cursor_BASE;
|
||||
public static readonly uint Update111Completed = ++Cursor_BASE;
|
||||
public static readonly uint BackMainScene = ++Cursor_BASE;
|
||||
public static readonly uint Update101Completed = ++Cursor_BASE;
|
||||
public static readonly uint Update102 = ++Cursor_BASE;
|
||||
|
||||
public static uint Slot_refresh = ++Cursor_BASE;
|
||||
public static uint Remake_state = ++Cursor_BASE;
|
||||
public static readonly uint MakeupSuccess = ++Cursor_BASE;
|
||||
public static readonly uint Update102Completed = ++Cursor_BASE;
|
||||
public static uint PaySuccess = ++Cursor_BASE;
|
||||
|
||||
public static uint Ad_success = ++Cursor_BASE;
|
||||
public static uint UpdateHotFixMax = ++Cursor_BASE;
|
||||
public static uint UpdateHotFixProgress = ++Cursor_BASE;
|
||||
public static readonly uint RefreshMakeupData = ++Cursor_BASE;
|
||||
public static uint Gold_refresh = ++Cursor_BASE;
|
||||
public static uint Sheep_item_refresh = ++Cursor_BASE;
|
||||
public static uint card_click = ++Cursor_BASE;
|
||||
public static uint UpdateCurrency102 = ++Cursor_BASE;
|
||||
|
||||
public static uint RefreshADTask = ++Cursor_BASE;
|
||||
public static readonly uint GetReward = ++Cursor_BASE;
|
||||
public static readonly uint ProcessReward = ++Cursor_BASE;
|
||||
|
||||
public static readonly uint Update101 = ++Cursor_BASE;
|
||||
public static readonly uint MakeUpConfirmUIClosed = ++Cursor_BASE;
|
||||
|
||||
public static readonly uint Update111 = ++Cursor_BASE;
|
||||
public static uint reset_game = ++Cursor_BASE;
|
||||
public static uint GetTaskReward = ++Cursor_BASE;
|
||||
public static uint pack_close = ++Cursor_BASE;
|
||||
public static uint RefreshRedDot = ++Cursor_BASE;
|
||||
public static uint resetH5progress = ++Cursor_BASE;
|
||||
public static uint RefreshGame = ++Cursor_BASE;
|
||||
public static uint RewardUIClosed = ++Cursor_BASE;
|
||||
public static uint H5ViewClickBtn = ++Cursor_BASE;
|
||||
public static uint apple_pay_success = ++Cursor_BASE;
|
||||
public static uint ExitGame = ++Cursor_BASE;
|
||||
|
||||
public static uint UpdateNoads = ++Cursor_BASE;
|
||||
public static uint Network_reconnection = ++Cursor_BASE;
|
||||
public static uint resurgence = ++Cursor_BASE;
|
||||
public static uint resurgence_close = ++Cursor_BASE;
|
||||
public static uint RefreshSaveingPot = ++Cursor_BASE;
|
||||
public static uint hideBroadCast = ++Cursor_BASE;
|
||||
public static uint showBroadCast = ++Cursor_BASE;
|
||||
public static uint updateRecordList = ++Cursor_BASE;
|
||||
public static uint ThreeDaysGiftUIClose = ++Cursor_BASE;
|
||||
public static uint rewardMul_close = ++Cursor_BASE;
|
||||
public static uint RefreshConfig = ++Cursor_BASE;
|
||||
public static uint UnlockLevelsuccess = ++Cursor_BASE;
|
||||
public static uint creatCARD = ++Cursor_BASE;
|
||||
public static uint LiveChange = ++Cursor_BASE;
|
||||
public static uint liveDetailClose = ++Cursor_BASE;
|
||||
public static uint UnlockSecretSuccess = ++Cursor_BASE;
|
||||
public static uint UnlockAlbums = ++Cursor_BASE;
|
||||
public static uint BuyVip = ++Cursor_BASE;
|
||||
public static uint CheckEnd = ++Cursor_BASE;
|
||||
public static uint AddChatNum = ++Cursor_BASE;
|
||||
public static uint Setbg = ++Cursor_BASE;
|
||||
public static uint liveVideoLoaded = ++Cursor_BASE;
|
||||
}
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public static partial class GameMsg
|
||||
{
|
||||
public static readonly uint OpenGame = ++Cursor_BASE;
|
||||
public static readonly uint Update111Completed = ++Cursor_BASE;
|
||||
public static readonly uint BackMainScene = ++Cursor_BASE;
|
||||
public static readonly uint Update101Completed = ++Cursor_BASE;
|
||||
public static readonly uint Update102 = ++Cursor_BASE;
|
||||
|
||||
public static uint Slot_refresh = ++Cursor_BASE;
|
||||
public static uint Remake_state = ++Cursor_BASE;
|
||||
public static readonly uint MakeupSuccess = ++Cursor_BASE;
|
||||
public static readonly uint Update102Completed = ++Cursor_BASE;
|
||||
public static uint PaySuccess = ++Cursor_BASE;
|
||||
|
||||
public static uint Ad_success = ++Cursor_BASE;
|
||||
public static uint UpdateHotFixMax = ++Cursor_BASE;
|
||||
public static uint UpdateHotFixProgress = ++Cursor_BASE;
|
||||
public static readonly uint RefreshMakeupData = ++Cursor_BASE;
|
||||
public static uint Gold_refresh = ++Cursor_BASE;
|
||||
public static uint Sheep_item_refresh = ++Cursor_BASE;
|
||||
public static uint card_click = ++Cursor_BASE;
|
||||
public static uint UpdateCurrency102 = ++Cursor_BASE;
|
||||
|
||||
public static uint RefreshADTask = ++Cursor_BASE;
|
||||
public static readonly uint GetReward = ++Cursor_BASE;
|
||||
public static readonly uint ProcessReward = ++Cursor_BASE;
|
||||
|
||||
public static readonly uint Update101 = ++Cursor_BASE;
|
||||
public static readonly uint MakeUpConfirmUIClosed = ++Cursor_BASE;
|
||||
|
||||
public static readonly uint Update111 = ++Cursor_BASE;
|
||||
public static uint reset_game = ++Cursor_BASE;
|
||||
public static uint GetTaskReward = ++Cursor_BASE;
|
||||
public static uint pack_close = ++Cursor_BASE;
|
||||
public static uint RefreshRedDot = ++Cursor_BASE;
|
||||
public static uint resetH5progress = ++Cursor_BASE;
|
||||
public static uint RefreshGame = ++Cursor_BASE;
|
||||
public static uint RewardUIClosed = ++Cursor_BASE;
|
||||
public static uint H5ViewClickBtn = ++Cursor_BASE;
|
||||
public static uint IAP_PAY_SUCCESS = ++Cursor_BASE;
|
||||
public static uint ExitGame = ++Cursor_BASE;
|
||||
|
||||
public static uint UpdateNoads = ++Cursor_BASE;
|
||||
public static uint Network_reconnection = ++Cursor_BASE;
|
||||
public static uint resurgence = ++Cursor_BASE;
|
||||
public static uint resurgence_close = ++Cursor_BASE;
|
||||
public static uint RefreshSaveingPot = ++Cursor_BASE;
|
||||
public static uint hideBroadCast = ++Cursor_BASE;
|
||||
public static uint showBroadCast = ++Cursor_BASE;
|
||||
public static uint updateRecordList = ++Cursor_BASE;
|
||||
public static uint ThreeDaysGiftUIClose = ++Cursor_BASE;
|
||||
public static uint rewardMul_close = ++Cursor_BASE;
|
||||
public static uint RefreshConfig = ++Cursor_BASE;
|
||||
public static uint UnlockLevelsuccess = ++Cursor_BASE;
|
||||
public static uint creatCARD = ++Cursor_BASE;
|
||||
public static uint LiveChange = ++Cursor_BASE;
|
||||
public static uint liveDetailClose = ++Cursor_BASE;
|
||||
public static uint UnlockSecretSuccess = ++Cursor_BASE;
|
||||
public static uint UnlockAlbums = ++Cursor_BASE;
|
||||
public static uint BuyVip = ++Cursor_BASE;
|
||||
public static uint CheckEnd = ++Cursor_BASE;
|
||||
public static uint AddChatNum = ++Cursor_BASE;
|
||||
public static uint Setbg = ++Cursor_BASE;
|
||||
public static uint liveVideoLoaded = ++Cursor_BASE;
|
||||
}
|
||||
}
|
||||
@@ -1404,7 +1404,7 @@ namespace RedHotRoast
|
||||
/// <returns>true:广告兑换 -- false:三方支付</returns>
|
||||
public static bool IsAdModelOfPay()
|
||||
{
|
||||
return true;//zhushi
|
||||
// return true;//zhushi
|
||||
var isAd = GetLoginModel().Enwp != 1;
|
||||
return isAd;
|
||||
}
|
||||
@@ -1750,7 +1750,20 @@ namespace RedHotRoast
|
||||
}
|
||||
|
||||
#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_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,10 @@ namespace RedHotRoast
|
||||
shopName = "",
|
||||
type = ""
|
||||
};
|
||||
List<ApplePay2> listA = ConfigSystem.GetConfig<ApplePay2>();
|
||||
// List<ApplePay2> listA = ConfigSystem.GetConfig<ApplePay2>();
|
||||
|
||||
//更新map中的value,与配置表的id对应
|
||||
PurchasingManager.SetShopMapValue();
|
||||
|
||||
// // 方式一:LINQ Select
|
||||
// List<ProductConfig> listB = listA
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 470 KiB After Width: | Height: | Size: 502 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1893,6 +1893,50 @@ SpriteRenderer:
|
||||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 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
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2342,3 +2386,4 @@ SceneRoots:
|
||||
- {fileID: 392099410}
|
||||
- {fileID: 29401442}
|
||||
- {fileID: 292594112}
|
||||
- {fileID: 1659410219}
|
||||
|
||||
+437
-439
@@ -1,439 +1,437 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using RedHotRoast;
|
||||
using DG.Tweening;
|
||||
using FGUI.ZM_Common_01;
|
||||
using UnityEngine;
|
||||
using Newtonsoft.Json;
|
||||
using SGModule.Common.Helper;
|
||||
using SGModule.NetKit;
|
||||
using System.Linq;
|
||||
|
||||
public class AdExchangeManager
|
||||
{
|
||||
public static readonly AdExchangeManager Instance = new AdExchangeManager();
|
||||
|
||||
AdExchangeManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// 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_2 = "com.rainforestworld.shop.3.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 remove_ad = "com.rainforestworld.remove.2.99";
|
||||
// public const string battle_pass = "com.rainforestworld.pass.9.99";
|
||||
// public const string pack_reward = "com.rainforestworld.reward.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 secret_albnums = "com.rainforestworld.secret_albnums.3.99";
|
||||
|
||||
|
||||
// private static readonly Dictionary<string, EventTrackMapping> _trackMappings = new()
|
||||
// {
|
||||
// [pack_reward] = new EventTrackMapping
|
||||
// {
|
||||
// EventKey = ADEventTrack.Event,
|
||||
// ClickProperty = _ => ADEventTrack.Property.lucky_gift_click,
|
||||
// SuccessProperty = _ => ADEventTrack.Property.lucky_gift_receive
|
||||
// },
|
||||
// [remove_ad] = new EventTrackMapping
|
||||
// {
|
||||
// EventKey = ADEventTrack.Event,
|
||||
// ClickProperty = _ => ADEventTrack.Property.remove_ad_click,
|
||||
// SuccessProperty = _ => ADEventTrack.Property.remove_ad_receive
|
||||
// },
|
||||
// [battle_pass] = new EventTrackMapping
|
||||
// {
|
||||
// EventKey = ADEventTrack.Event,
|
||||
// ClickProperty = _ => ADEventTrack.Property.master_pass_click,
|
||||
// SuccessProperty = _ => ADEventTrack.Property.master_pass_receive
|
||||
// },
|
||||
// [buy_one] = new EventTrackMapping
|
||||
// {
|
||||
// EventKey = ADEventTrack.Event,
|
||||
// ClickProperty = _ => ADEventTrack.Property.buy_one_click,
|
||||
// SuccessProperty = _ => ADEventTrack.Property.buy_one_success
|
||||
// },
|
||||
// ["buy_gold"] = new EventTrackMapping
|
||||
// {
|
||||
// EventKey = ADEventTrack.Event,
|
||||
// ClickProperty = suffix => ADEventTrack.Property.gold_click_ + suffix,
|
||||
// SuccessProperty = suffix => ADEventTrack.Property.shop_receive_ + suffix
|
||||
// }
|
||||
// };
|
||||
|
||||
public void Exchange(AdExchangeData _data)
|
||||
{
|
||||
if (Time.time - SaveData.rm_time < 5)
|
||||
{
|
||||
GameHelper.ShowTips("click_too_frequent", true);
|
||||
return;
|
||||
}
|
||||
SaveData.rm_time = Time.time;
|
||||
|
||||
int myAdNum = GetLookRewardADNum();
|
||||
if (myAdNum >= _data.ad_count)
|
||||
{
|
||||
SetLookRewardADNum(myAdNum - _data.ad_count);
|
||||
|
||||
SendEventClickByName(_data.type, "success");
|
||||
|
||||
DOVirtual.DelayedCall(0.1f, () =>
|
||||
{
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _data.type);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("no_ad_count", true);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowVideoAd(string adName, Action _action)
|
||||
{
|
||||
GameHelper.ShowVideoAd(adName, isSuccess =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
_action?.Invoke();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// private btn_watchAd btn_WatchAd = null;
|
||||
private Dictionary<string, btn_watchAd> btn_WatchAd = new Dictionary<string, btn_watchAd>();
|
||||
private Dictionary<string, Action> ActionSetText = new Dictionary<string, Action>(); //广告数量的显示
|
||||
|
||||
public void SetWatchAd(string key, btn_watchAd _btn, Action action)
|
||||
{
|
||||
if (!btn_WatchAd.ContainsKey(key))
|
||||
{
|
||||
btn_WatchAd.Add(key, _btn);
|
||||
}
|
||||
else
|
||||
{
|
||||
btn_WatchAd[key] = _btn;
|
||||
}
|
||||
|
||||
if (!ActionSetText.ContainsKey(key))
|
||||
{
|
||||
ActionSetText.Add(key, action);
|
||||
}
|
||||
else
|
||||
{
|
||||
ActionSetText[key] = action;
|
||||
}
|
||||
}
|
||||
private void removeWatchAd()
|
||||
{
|
||||
btn_WatchAd.Clear();
|
||||
}
|
||||
private int ad_cool_down = ConfigSystem.GetCommonConf().exchangeCD;
|
||||
|
||||
private void updateWatchCD()
|
||||
{
|
||||
var lastTimes = SaveData.GetSaveObject()._watch_ad_cd;
|
||||
foreach (var item in btn_WatchAd)
|
||||
{
|
||||
bool is_get = item.Key == PurchasingManager.GetPaySku(PayType.pack_reward) && SaveData.GetSaveObject().is_get_packreward;
|
||||
bool is_get1 = item.Key == PurchasingManager.GetPaySku(PayType.remove_ad) && SaveData.GetSaveObject().is_get_removead;
|
||||
if (is_get || is_get1)
|
||||
{
|
||||
item.Value.enabled = false;
|
||||
}
|
||||
else if (GameHelper.GetNowTime() < lastTimes && !checkIsCanReceive(item.Key))
|
||||
{
|
||||
item.Value.enabled = false;
|
||||
item.Value.can_buy.selectedIndex = btn_watchAd.Can_buy_cd;
|
||||
item.Value.btn_text.text = CommonHelper.TimeFormat(lastTimes - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
|
||||
}
|
||||
else
|
||||
{
|
||||
// stopAction();
|
||||
item.Value.enabled = true;
|
||||
item.Value.can_buy.selectedIndex = btn_watchAd.Can_buy_can;
|
||||
checkBtnState(item.Value, item.Key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private CommonModel config = ConfigSystem.GetCommonConf();
|
||||
private List<Paidgift> packdata = ConfigSystem.GetConfig<Paidgift>();
|
||||
private List<Multigift> threeDayData = ConfigSystem.GetConfig<Multigift>();
|
||||
public int GetCeilingNeedAds(string name)
|
||||
{
|
||||
|
||||
int needAds = -1;
|
||||
if (name == PurchasingManager.GetPaySku(PayType.buy_one))
|
||||
{
|
||||
double addspace = config.addspace;
|
||||
needAds = (int)Math.Ceiling(addspace);
|
||||
}
|
||||
// else if (name == PurchasingManager.GetPaySku(PayType.buy_one_off))
|
||||
// {
|
||||
// double addspace1 = config.AddDiscount;
|
||||
// needAds = (int)Math.Ceiling(addspace1);
|
||||
// }
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.battle_pass))
|
||||
{
|
||||
double Passportgift = config.Passportgift;
|
||||
needAds = (int)Math.Ceiling(Passportgift);
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.pack_reward))
|
||||
{
|
||||
double Paid_price = packdata[0].Paid_price;
|
||||
needAds = (int)Math.Ceiling(Paid_price);
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.remove_ad))
|
||||
{
|
||||
double move_price = packdata[1].Paid_price;
|
||||
needAds = (int)Math.Ceiling(move_price);
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
{
|
||||
double move_price = threeDayData[2].Paid_price;
|
||||
needAds = (int)Math.Ceiling(move_price);
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.buy_gold_1))
|
||||
{
|
||||
needAds = (int)Math.Ceiling(getCoinNeedAds(name));
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.buy_gold_2))
|
||||
{
|
||||
needAds = (int)Math.Ceiling(getCoinNeedAds(name));
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.buy_gold_3))
|
||||
{
|
||||
needAds = (int)Math.Ceiling(getCoinNeedAds(name));
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.buy_gold_4))
|
||||
{
|
||||
needAds = (int)Math.Ceiling(getCoinNeedAds(name));
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.buy_gold_5))
|
||||
{
|
||||
needAds = (int)Math.Ceiling(getCoinNeedAds(name));
|
||||
}
|
||||
|
||||
return needAds;
|
||||
|
||||
}
|
||||
private List<Paidcoins> coinList = ConfigSystem.GetConfig<Paidcoins>();
|
||||
private double getCoinNeedAds(string sku)
|
||||
{
|
||||
Paidcoins result = coinList.FirstOrDefault(c => c.SKU == sku);
|
||||
if (result != null)
|
||||
{
|
||||
return result.Payment_amount;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private bool checkIsCanReceive(string name)
|
||||
{
|
||||
int myAd = GetLookRewardADNum();
|
||||
return myAd >= GetCeilingNeedAds(name);
|
||||
}
|
||||
private void checkBtnState(btn_watchAd item, string key)
|
||||
{
|
||||
// stopAction();
|
||||
// foreach (var item in btn_WatchAd)
|
||||
// {
|
||||
item.SetClick(() => { });
|
||||
|
||||
if (checkIsCanReceive(key))
|
||||
{
|
||||
item.buy_state.selectedIndex = btn_watchAd.Buy_state_buy;
|
||||
|
||||
item.SetClick(() =>
|
||||
{
|
||||
item.enabled = false;
|
||||
AdExchangeData adExchangeData = new AdExchangeData()
|
||||
{
|
||||
type = key,
|
||||
ad_count = GetCeilingNeedAds(key)
|
||||
};
|
||||
Exchange(adExchangeData);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
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_get1 = key == PurchasingManager.GetPaySku(PayType.remove_ad) && SaveData.GetSaveObject().is_get_removead;
|
||||
|
||||
if (is_get || is_get1)
|
||||
{
|
||||
item.enabled = false;
|
||||
item.SetClick(() => { });
|
||||
}
|
||||
else
|
||||
{
|
||||
item.SetClick(() =>
|
||||
{
|
||||
SendEventClickByName(key, "click");
|
||||
ShowVideoAd("buy_add_one", () =>
|
||||
{
|
||||
RunAllAction();
|
||||
item.enabled = false;
|
||||
TimerHelper.mEasy.AddTimer(0.1f, () =>
|
||||
{
|
||||
var ad_times = Convert.ToInt32(GameHelper.GetNowTime());
|
||||
SaveData.GetSaveObject()._watch_ad_cd = ad_times + ad_cool_down;
|
||||
startAction();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private void RunAllAction()
|
||||
{
|
||||
foreach (var item in ActionSetText)
|
||||
{
|
||||
item.Value?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void startAction()
|
||||
{
|
||||
stopAction();
|
||||
HallManager.Instance.UpdateSecondEvent += updateWatchCD;
|
||||
}
|
||||
|
||||
private void stopAction()
|
||||
{
|
||||
HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
|
||||
}
|
||||
|
||||
public int GetLookRewardADNum()
|
||||
{
|
||||
return DataMgr.AdWatchCount.Value;
|
||||
}
|
||||
|
||||
public void SetLookRewardADNum(int nums)
|
||||
{
|
||||
DataMgr.AdWatchCount.Value = nums;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
startAction();
|
||||
updateWatchCD();
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
stopAction();
|
||||
removeWatchAd();
|
||||
ActionSetText.Clear();
|
||||
}
|
||||
|
||||
public void SendEventClickByName(string name, string type)
|
||||
{
|
||||
string eventClickName = "";
|
||||
string eventSuccName = "";
|
||||
if (name == PurchasingManager.GetPaySku(PayType.pack_reward))
|
||||
{
|
||||
eventClickName = ADEventTrack.Property.lucky_gift_click;
|
||||
eventSuccName = ADEventTrack.Property.lucky_gift_receive;
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.remove_ad))
|
||||
{
|
||||
eventClickName = ADEventTrack.Property.remove_ad_click;
|
||||
eventSuccName = ADEventTrack.Property.remove_ad_receive;
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.battle_pass))
|
||||
{
|
||||
eventClickName = ADEventTrack.Property.master_pass_click;
|
||||
eventSuccName = ADEventTrack.Property.master_pass_receive;
|
||||
}
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.buy_one))
|
||||
{
|
||||
eventClickName = ADEventTrack.Property.buy_one_click;
|
||||
eventSuccName = ADEventTrack.Property.buy_one_success;
|
||||
}
|
||||
// else if (name == PurchasingManager.GetPaySku(PayType.buy_one_off))
|
||||
// {
|
||||
// eventClickName = ADEventTrack.Property.BuyOneOffClick;
|
||||
// eventSuccName = ADEventTrack.Property.BuyOneOffSuccess;
|
||||
// }
|
||||
else if (name == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
{
|
||||
eventClickName = ADEventTrack.Property.three_days_gift_click;
|
||||
eventSuccName = ADEventTrack.Property.three_days_gift_buy_success;
|
||||
}
|
||||
else if (name.StartsWith("buy_gold"))
|
||||
{
|
||||
int startIndex = "buy_gold".Length;
|
||||
string suffix = name[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
eventClickName = ADEventTrack.Property.gold_click_ + suffix;
|
||||
eventSuccName = ADEventTrack.Property.shop_receive_ + suffix;
|
||||
}
|
||||
|
||||
if (type == "success" && eventSuccName != "")
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.Event, eventSuccName);
|
||||
}
|
||||
else if (type == "click" && eventClickName != "")
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.Event, eventClickName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class EventTrackMapping
|
||||
{
|
||||
public string EventKey
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Func<string, string> ClickProperty
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Func<string, string> SuccessProperty
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
public class AdExchangeData
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public string type;
|
||||
[JsonProperty("ad_count")]
|
||||
public int ad_count;
|
||||
[JsonProperty("shopName")]
|
||||
public string shopName;
|
||||
|
||||
}
|
||||
public class orderState
|
||||
{
|
||||
[JsonProperty("order_id")]
|
||||
public string order_id;
|
||||
[JsonProperty("status")]
|
||||
public int status;
|
||||
|
||||
}
|
||||
public class orderData
|
||||
{
|
||||
[JsonProperty("order_id")]
|
||||
public string order_id;
|
||||
[JsonProperty("pay_url")]
|
||||
public string pay_url;
|
||||
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using RedHotRoast;
|
||||
using DG.Tweening;
|
||||
using FGUI.ZM_Common_01;
|
||||
using UnityEngine;
|
||||
using Newtonsoft.Json;
|
||||
using SGModule.Common.Helper;
|
||||
using SGModule.NetKit;
|
||||
using System.Linq;
|
||||
|
||||
public class AdExchangeManager
|
||||
{
|
||||
public static readonly AdExchangeManager Instance = new AdExchangeManager();
|
||||
|
||||
AdExchangeManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// 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_2 = "com.rainforestworld.shop.3.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 remove_ad = "com.rainforestworld.remove.2.99";
|
||||
// public const string battle_pass = "com.rainforestworld.pass.9.99";
|
||||
// public const string pack_reward = "com.rainforestworld.reward.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 secret_albnums = "com.rainforestworld.secret_albnums.3.99";
|
||||
|
||||
|
||||
// private static readonly Dictionary<string, EventTrackMapping> _trackMappings = new()
|
||||
// {
|
||||
// [pack_reward] = new EventTrackMapping
|
||||
// {
|
||||
// EventKey = ADEventTrack.Event,
|
||||
// ClickProperty = _ => ADEventTrack.Property.lucky_gift_click,
|
||||
// SuccessProperty = _ => ADEventTrack.Property.lucky_gift_receive
|
||||
// },
|
||||
// [remove_ad] = new EventTrackMapping
|
||||
// {
|
||||
// EventKey = ADEventTrack.Event,
|
||||
// ClickProperty = _ => ADEventTrack.Property.remove_ad_click,
|
||||
// SuccessProperty = _ => ADEventTrack.Property.remove_ad_receive
|
||||
// },
|
||||
// [battle_pass] = new EventTrackMapping
|
||||
// {
|
||||
// EventKey = ADEventTrack.Event,
|
||||
// ClickProperty = _ => ADEventTrack.Property.master_pass_click,
|
||||
// SuccessProperty = _ => ADEventTrack.Property.master_pass_receive
|
||||
// },
|
||||
// [buy_one] = new EventTrackMapping
|
||||
// {
|
||||
// EventKey = ADEventTrack.Event,
|
||||
// ClickProperty = _ => ADEventTrack.Property.buy_one_click,
|
||||
// SuccessProperty = _ => ADEventTrack.Property.buy_one_success
|
||||
// },
|
||||
// ["buy_gold"] = new EventTrackMapping
|
||||
// {
|
||||
// EventKey = ADEventTrack.Event,
|
||||
// ClickProperty = suffix => ADEventTrack.Property.gold_click_ + suffix,
|
||||
// SuccessProperty = suffix => ADEventTrack.Property.shop_receive_ + suffix
|
||||
// }
|
||||
// };
|
||||
|
||||
public void Exchange(AdExchangeData _data)
|
||||
{
|
||||
if (Time.time - SaveData.rm_time < 5)
|
||||
{
|
||||
GameHelper.ShowTips("click_too_frequent", true);
|
||||
return;
|
||||
}
|
||||
SaveData.rm_time = Time.time;
|
||||
|
||||
int myAdNum = GetLookRewardADNum();
|
||||
if (myAdNum >= _data.ad_count)
|
||||
{
|
||||
SetLookRewardADNum(myAdNum - _data.ad_count);
|
||||
|
||||
SendEventClickByName(_data.type, "success");
|
||||
|
||||
DOVirtual.DelayedCall(0.1f, () =>
|
||||
{
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, _data.type);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("no_ad_count", true);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowVideoAd(string adName, Action _action)
|
||||
{
|
||||
GameHelper.ShowVideoAd(adName, isSuccess =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
_action?.Invoke();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// private btn_watchAd btn_WatchAd = null;
|
||||
private Dictionary<string, btn_watchAd> btn_WatchAd = new Dictionary<string, btn_watchAd>();
|
||||
private Dictionary<string, Action> ActionSetText = new Dictionary<string, Action>(); //广告数量的显示
|
||||
|
||||
public void SetWatchAd(string key, btn_watchAd _btn, Action action)
|
||||
{
|
||||
if (!btn_WatchAd.ContainsKey(key))
|
||||
{
|
||||
btn_WatchAd.Add(key, _btn);
|
||||
}
|
||||
else
|
||||
{
|
||||
btn_WatchAd[key] = _btn;
|
||||
}
|
||||
|
||||
if (!ActionSetText.ContainsKey(key))
|
||||
{
|
||||
ActionSetText.Add(key, action);
|
||||
}
|
||||
else
|
||||
{
|
||||
ActionSetText[key] = action;
|
||||
}
|
||||
}
|
||||
private void removeWatchAd()
|
||||
{
|
||||
btn_WatchAd.Clear();
|
||||
}
|
||||
private int ad_cool_down = ConfigSystem.GetCommonConf().exchangeCD;
|
||||
|
||||
private void updateWatchCD()
|
||||
{
|
||||
var lastTimes = SaveData.GetSaveObject()._watch_ad_cd;
|
||||
foreach (var item in btn_WatchAd)
|
||||
{
|
||||
bool is_get = item.Key == IAPPayManager.PRODUCT_FIRST_GIFT && SaveData.GetSaveObject().is_get_packreward;
|
||||
bool is_get1 = item.Key == IAPPayManager.PRODUCT_REMOVE_ADS && SaveData.GetSaveObject().is_get_removead;
|
||||
if (is_get || is_get1)
|
||||
{
|
||||
item.Value.enabled = false;
|
||||
}
|
||||
else if (GameHelper.GetNowTime() < lastTimes && !checkIsCanReceive(item.Key))
|
||||
{
|
||||
item.Value.enabled = false;
|
||||
item.Value.can_buy.selectedIndex = btn_watchAd.Can_buy_cd;
|
||||
item.Value.btn_text.text = CommonHelper.TimeFormat(lastTimes - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
|
||||
}
|
||||
else
|
||||
{
|
||||
// stopAction();
|
||||
item.Value.enabled = true;
|
||||
item.Value.can_buy.selectedIndex = btn_watchAd.Can_buy_can;
|
||||
checkBtnState(item.Value, item.Key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private CommonModel config = ConfigSystem.GetCommonConf();
|
||||
private List<Paidgift> packdata = ConfigSystem.GetConfig<Paidgift>();
|
||||
private List<Multigift> threeDayData = ConfigSystem.GetConfig<Multigift>();
|
||||
public int GetCeilingNeedAds(string name)
|
||||
{
|
||||
|
||||
int needAds = -1;
|
||||
if (name == IAPPayManager.PRODUCT_SPACE_BONUS)
|
||||
{
|
||||
double addspace = config.addspace;
|
||||
needAds = (int)Math.Ceiling(addspace);
|
||||
}
|
||||
// else if (name == PurchasingManager.GetPaySku(PayType.buy_one_off))
|
||||
// {
|
||||
// double addspace1 = config.AddDiscount;
|
||||
// needAds = (int)Math.Ceiling(addspace1);
|
||||
// }
|
||||
else if (name == IAPPayManager.PRODUCT_PASS_BONUS)
|
||||
{
|
||||
double Passportgift = config.Passportgift;
|
||||
needAds = (int)Math.Ceiling(Passportgift);
|
||||
}
|
||||
else if (name == IAPPayManager.PRODUCT_FIRST_GIFT)
|
||||
{
|
||||
double Paid_price = packdata[0].Paid_price;
|
||||
needAds = (int)Math.Ceiling(Paid_price);
|
||||
}
|
||||
else if (name == IAPPayManager.PRODUCT_REMOVE_ADS)
|
||||
{
|
||||
double move_price = packdata[1].Paid_price;
|
||||
needAds = (int)Math.Ceiling(move_price);
|
||||
}
|
||||
// else if (name == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
// {
|
||||
// double move_price = threeDayData[2].Paid_price;
|
||||
// needAds = (int)Math.Ceiling(move_price);
|
||||
// }
|
||||
else if (name == IAPPayManager.PRODUCT_SHOP_1)
|
||||
{
|
||||
needAds = (int)Math.Ceiling(getCoinNeedAds(name));
|
||||
}
|
||||
else if (name == IAPPayManager.PRODUCT_SHOP_2)
|
||||
{
|
||||
needAds = (int)Math.Ceiling(getCoinNeedAds(name));
|
||||
}
|
||||
else if (name == IAPPayManager.PRODUCT_SHOP_3)
|
||||
{
|
||||
needAds = (int)Math.Ceiling(getCoinNeedAds(name));
|
||||
}
|
||||
else if (name == IAPPayManager.PRODUCT_SHOP_4)
|
||||
{
|
||||
needAds = (int)Math.Ceiling(getCoinNeedAds(name));
|
||||
}
|
||||
else if (name == IAPPayManager.PRODUCT_SHOP_5)
|
||||
{
|
||||
needAds = (int)Math.Ceiling(getCoinNeedAds(name));
|
||||
}
|
||||
|
||||
return needAds;
|
||||
|
||||
}
|
||||
private List<Paidcoins> coinList = ConfigSystem.GetConfig<Paidcoins>();
|
||||
private double getCoinNeedAds(string sku)
|
||||
{
|
||||
Paidcoins result = coinList.FirstOrDefault(c => c.SKU == sku);
|
||||
if (result != null)
|
||||
{
|
||||
return result.Payment_amount;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private bool checkIsCanReceive(string name)
|
||||
{
|
||||
int myAd = GetLookRewardADNum();
|
||||
return myAd >= GetCeilingNeedAds(name);
|
||||
}
|
||||
private void checkBtnState(btn_watchAd item, string key)
|
||||
{
|
||||
// stopAction();
|
||||
// foreach (var item in btn_WatchAd)
|
||||
// {
|
||||
item.SetClick(() => { });
|
||||
|
||||
if (checkIsCanReceive(key))
|
||||
{
|
||||
item.buy_state.selectedIndex = btn_watchAd.Buy_state_buy;
|
||||
|
||||
item.SetClick(() =>
|
||||
{
|
||||
item.enabled = false;
|
||||
AdExchangeData adExchangeData = new AdExchangeData()
|
||||
{
|
||||
type = key,
|
||||
ad_count = GetCeilingNeedAds(key)
|
||||
};
|
||||
Exchange(adExchangeData);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
item.buy_state.selectedIndex = btn_watchAd.Buy_state_ad;
|
||||
bool is_get = key == IAPPayManager.PRODUCT_FIRST_GIFT && SaveData.GetSaveObject().is_get_packreward;
|
||||
bool is_get1 = key == IAPPayManager.PRODUCT_REMOVE_ADS && SaveData.GetSaveObject().is_get_removead;
|
||||
|
||||
if (is_get || is_get1)
|
||||
{
|
||||
item.enabled = false;
|
||||
item.SetClick(() => { });
|
||||
}
|
||||
else
|
||||
{
|
||||
item.SetClick(() =>
|
||||
{
|
||||
SendEventClickByName(key, "click");
|
||||
ShowVideoAd("buy_add_one", () =>
|
||||
{
|
||||
RunAllAction();
|
||||
item.enabled = false;
|
||||
TimerHelper.mEasy.AddTimer(0.1f, () =>
|
||||
{
|
||||
var ad_times = Convert.ToInt32(GameHelper.GetNowTime());
|
||||
SaveData.GetSaveObject()._watch_ad_cd = ad_times + ad_cool_down;
|
||||
startAction();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
private void RunAllAction()
|
||||
{
|
||||
foreach (var item in ActionSetText)
|
||||
{
|
||||
item.Value?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void startAction()
|
||||
{
|
||||
stopAction();
|
||||
HallManager.Instance.UpdateSecondEvent += updateWatchCD;
|
||||
}
|
||||
|
||||
private void stopAction()
|
||||
{
|
||||
HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
|
||||
}
|
||||
|
||||
public int GetLookRewardADNum()
|
||||
{
|
||||
return DataMgr.AdWatchCount.Value;
|
||||
}
|
||||
|
||||
public void SetLookRewardADNum(int nums)
|
||||
{
|
||||
DataMgr.AdWatchCount.Value = nums;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
startAction();
|
||||
updateWatchCD();
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
stopAction();
|
||||
removeWatchAd();
|
||||
ActionSetText.Clear();
|
||||
}
|
||||
|
||||
public void SendEventClickByName(string name, string type)
|
||||
{
|
||||
string eventClickName = "";
|
||||
string eventSuccName = "";
|
||||
if (name == IAPPayManager.PRODUCT_FIRST_GIFT)
|
||||
{
|
||||
eventClickName = ADEventTrack.Property.lucky_gift_click;
|
||||
eventSuccName = ADEventTrack.Property.lucky_gift_receive;
|
||||
}
|
||||
else if (name == IAPPayManager.PRODUCT_REMOVE_ADS)
|
||||
{
|
||||
eventClickName = ADEventTrack.Property.remove_ad_click;
|
||||
eventSuccName = ADEventTrack.Property.remove_ad_receive;
|
||||
}
|
||||
else if (name == IAPPayManager.PRODUCT_PASS_BONUS)
|
||||
{
|
||||
eventClickName = ADEventTrack.Property.master_pass_click;
|
||||
eventSuccName = ADEventTrack.Property.master_pass_receive;
|
||||
}
|
||||
else if (name == IAPPayManager.PRODUCT_SPACE_BONUS)
|
||||
{
|
||||
eventClickName = ADEventTrack.Property.buy_one_click;
|
||||
eventSuccName = ADEventTrack.Property.buy_one_success;
|
||||
}
|
||||
// else if (name == PurchasingManager.GetPaySku(PayType.buy_one_off))
|
||||
// {
|
||||
// eventClickName = ADEventTrack.Property.BuyOneOffClick;
|
||||
// eventSuccName = ADEventTrack.Property.BuyOneOffSuccess;
|
||||
// }
|
||||
// else if (name == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
// {
|
||||
// eventClickName = ADEventTrack.Property.three_days_gift_click;
|
||||
// eventSuccName = ADEventTrack.Property.three_days_gift_buy_success;
|
||||
// }
|
||||
else if (PurchasingManager.ShopProductMap.TryGetValue(name, out var idx))
|
||||
{
|
||||
eventClickName = ADEventTrack.Property.gold_click_ + idx;
|
||||
eventSuccName = ADEventTrack.Property.shop_receive_ + idx;
|
||||
}
|
||||
|
||||
if (type == "success" && eventSuccName != "")
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.Event, eventSuccName);
|
||||
}
|
||||
else if (type == "click" && eventClickName != "")
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.Event, eventClickName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class EventTrackMapping
|
||||
{
|
||||
public string EventKey
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Func<string, string> ClickProperty
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Func<string, string> SuccessProperty
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
public class AdExchangeData
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public string type;
|
||||
[JsonProperty("ad_count")]
|
||||
public int ad_count;
|
||||
[JsonProperty("shopName")]
|
||||
public string shopName;
|
||||
|
||||
}
|
||||
public class orderState
|
||||
{
|
||||
[JsonProperty("order_id")]
|
||||
public string order_id;
|
||||
[JsonProperty("status")]
|
||||
public int status;
|
||||
|
||||
}
|
||||
public class orderData
|
||||
{
|
||||
[JsonProperty("order_id")]
|
||||
public string order_id;
|
||||
[JsonProperty("pay_url")]
|
||||
public string pay_url;
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4b5c2a375fb4610a0417b408c252104
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -97,15 +97,17 @@ public class MaxPayManager
|
||||
// Debug.Log("barry ios pay");
|
||||
// 调用官方支付逻辑
|
||||
isIOSPay = true;
|
||||
// var appleData = new ApplePayData
|
||||
// {
|
||||
// sku = _data.sku,
|
||||
// amount = _data.amount,
|
||||
// currency = _data.currency,
|
||||
// shopName = _data.shopName,
|
||||
// type = _data.type
|
||||
// };
|
||||
// PurchasingManager.Purchase(appleData);
|
||||
#if UNITY_IOS
|
||||
var appleData = new ApplePayData
|
||||
{
|
||||
sku = _data.sku,
|
||||
amount = _data.amount,
|
||||
currency = _data.currency,
|
||||
shopName = _data.shopName,
|
||||
type = _data.type
|
||||
};
|
||||
PurchasingManager.Purchase(appleData);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -128,52 +130,47 @@ public class MaxPayManager
|
||||
ApplePayClass paydata = data_;
|
||||
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);
|
||||
}
|
||||
else if (data_.sku == PurchasingManager.GetPaySku(PayType.buy_one_off))
|
||||
{
|
||||
// TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.BuyOneOffClick);
|
||||
}
|
||||
else if (data_.sku != null && data_.sku == PurchasingManager.GetPaySku(PayType.remove_ad))
|
||||
// else if (data_.sku == PurchasingManager.GetPaySku(PayType.buy_one_off))
|
||||
// {
|
||||
// // TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.BuyOneOffClick);
|
||||
// }
|
||||
else if (data_.sku != null && data_.sku == IAPPayManager.PRODUCT_REMOVE_ADS)
|
||||
{
|
||||
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);
|
||||
}
|
||||
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;
|
||||
string suffix = paydata.shopName[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
string eventClickName = $"gold_click_{suffix}";
|
||||
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.gold_click_ + suffix);
|
||||
|
||||
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.gold_click_ + idx);
|
||||
}
|
||||
else if (data_.sku.StartsWith("secret_albnums"))
|
||||
{
|
||||
string suffix = data_.sku["secret_albnums".Length..];
|
||||
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_ + suffix);
|
||||
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.vip_click_ + vipIdx);
|
||||
}
|
||||
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);
|
||||
}
|
||||
else if (data_.sku == PurchasingManager.GetPaySku(PayType.fail_pack))
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.fail_click);
|
||||
}
|
||||
else if (data_.sku == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.three_days_gift_click);
|
||||
}
|
||||
// else if (data_.sku == PurchasingManager.GetPaySku(PayType.fail_pack))
|
||||
// {
|
||||
// TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.fail_click);
|
||||
// }
|
||||
// else if (data_.sku == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
// {
|
||||
// TrackKit.SendEvent(ADEventTrack.MaxPayEvent, ADEventTrack.Property.three_days_gift_click);
|
||||
// }
|
||||
|
||||
PayerData requestData = new PayerData()
|
||||
{
|
||||
@@ -348,7 +345,7 @@ public class MaxPayManager
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -356,35 +353,33 @@ public class MaxPayManager
|
||||
// {
|
||||
// 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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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 suffix = paydata.shopName[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
string eventSuccessName = ADEventTrack.Property.shop_receive_ + suffix;
|
||||
string eventSuccessName = ADEventTrack.Property.shop_receive_ + idx;
|
||||
|
||||
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);
|
||||
}
|
||||
else if (paydata.sku == PurchasingManager.GetPaySku(PayType.fail_pack))
|
||||
{
|
||||
isOpen = HandleSku(paydata.sku, UIConst.PackrewardUI, ADEventTrack.Property.fail_buy_success);
|
||||
}
|
||||
else if (paydata.sku == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
{
|
||||
isOpen = HandleSku(paydata.sku, UIConst.ThreeDaysGiftUI, ADEventTrack.Property.three_days_gift_buy_success);
|
||||
}
|
||||
// else if (paydata.sku == PurchasingManager.GetPaySku(PayType.fail_pack))
|
||||
// {
|
||||
// isOpen = HandleSku(paydata.sku, UIConst.PackrewardUI, ADEventTrack.Property.fail_buy_success);
|
||||
// }
|
||||
// else if (paydata.sku == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
// {
|
||||
// isOpen = HandleSku(paydata.sku, UIConst.ThreeDaysGiftUI, ADEventTrack.Property.three_days_gift_buy_success);
|
||||
// }
|
||||
else if (paydata.sku.StartsWith("secret_albnums"))
|
||||
{
|
||||
int startIndex = "secret_albnums".Length;
|
||||
@@ -393,11 +388,9 @@ public class MaxPayManager
|
||||
|
||||
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 suffix = paydata.shopName[startIndex..]; // 截取 "vip_club" 后的所有字符
|
||||
string eventSuccessName = ADEventTrack.Property.vip_success_ + suffix;
|
||||
string eventSuccessName = ADEventTrack.Property.vip_success_ + vipIdx;
|
||||
isOpen = HandleSku(paydata.sku, UIConst.VipClubViewUI, eventSuccessName);
|
||||
}
|
||||
else
|
||||
@@ -408,16 +401,16 @@ public class MaxPayManager
|
||||
}
|
||||
|
||||
string sku = "";
|
||||
if (paydata.sku.Contains("shop") || paydata.sku.Contains("sub"))
|
||||
{
|
||||
sku = paydata.shopName;
|
||||
}
|
||||
else
|
||||
{
|
||||
sku = paydata.sku;
|
||||
}
|
||||
// if (paydata.sku.Contains("shop") || paydata.sku.Contains("sub"))
|
||||
// {
|
||||
// sku = paydata.shopName;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
sku = paydata.sku;
|
||||
// }
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, sku);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, sku);
|
||||
|
||||
DOVirtual.DelayedCall(1, () =>
|
||||
{
|
||||
@@ -466,7 +459,7 @@ public class MaxPayManager
|
||||
{
|
||||
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
|
||||
{
|
||||
[JsonProperty("order_id")]
|
||||
public string order_id;
|
||||
}
|
||||
|
||||
public class ApplePayClass
|
||||
{
|
||||
[JsonProperty("innerOrderId")]
|
||||
public string innerOrderId;
|
||||
[JsonProperty("transactionId")]
|
||||
public string transactionId;
|
||||
[JsonProperty("amount")]
|
||||
public int amount;
|
||||
[JsonProperty("sku")]
|
||||
public string sku;
|
||||
[JsonProperty("currency")]
|
||||
public string currency = "USD";
|
||||
[JsonProperty("status")]
|
||||
public int status;
|
||||
[JsonProperty("shopName")]
|
||||
public string shopName;
|
||||
[JsonProperty("type")]
|
||||
public string type;
|
||||
}
|
||||
|
||||
@@ -594,9 +596,13 @@ public class ApplePayClass
|
||||
|
||||
public class PayerData
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
public string name;
|
||||
[JsonProperty("tel")]
|
||||
public string tel;
|
||||
[JsonProperty("email")]
|
||||
public string email;
|
||||
[JsonProperty("amount")]
|
||||
public int amount;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,158 +1,158 @@
|
||||
using System;
|
||||
using FGUI.ZM_Common_01;
|
||||
using SGModule.NetKit;
|
||||
using Spine.Unity;
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class AddViewUI : BaseUI
|
||||
{
|
||||
private AddViewUICtrl ctrl;
|
||||
private AddViewModel model;
|
||||
private FGUI.ZM_AddCell_12.com_addView ui;
|
||||
public int ad_cool_down = 120;
|
||||
public btn_watchAd btn_WatchAd;
|
||||
|
||||
public AddViewUI(AddViewUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.AddViewUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_AddCell_12";
|
||||
uiInfo.assetName = "com_addView";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.AddViewModel) as AddViewModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
GameHelper.showGameUI = true;
|
||||
// HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
|
||||
if (GameHelper.IsAdModelOfPay())
|
||||
{
|
||||
AdExchangeManager.Instance.Destroy();
|
||||
}
|
||||
if (need_call) GameHelper.CallShowTurn();
|
||||
}
|
||||
private bool need_call;
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.ZM_AddCell_12.com_addView;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.buy_one_show);
|
||||
if (args != null) need_call = (bool)args;
|
||||
// ad_cool_down = ConfigSystem.GetConfig<CommonModel>().exchangeCD;
|
||||
// btn_WatchAd = ui.btn_watch as btn_watchAd;
|
||||
if (GameHelper.IsAdModelOfPay())
|
||||
{
|
||||
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.buy_one), ui.btn_watch as btn_watchAd, SetTextString);
|
||||
ui.pay_type.selectedIndex = 0;
|
||||
|
||||
|
||||
AdExchangeManager.Instance.Start();
|
||||
SetTextString();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.pay_type.selectedIndex = 1;
|
||||
decimal price = (decimal)GameHelper.GetCommonModel().addspace2;
|
||||
ui.btn_max_pay.title = GameHelper.getPrice(price);
|
||||
ui.btn_max_pay.SetClick(() =>
|
||||
{
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)Math.Round(price * 100),
|
||||
sku =PurchasingManager.GetPaySku(PayType.buy_one),
|
||||
currency = "USD"
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
});
|
||||
}
|
||||
|
||||
InitView();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||||
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||||
|
||||
}
|
||||
#endregion
|
||||
void pay_success(object str)
|
||||
{
|
||||
string type = (string)str;
|
||||
|
||||
if (type == PurchasingManager.GetPaySku(PayType.buy_one))
|
||||
{
|
||||
CtrlCloseUI();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Action closeCallback = null;
|
||||
|
||||
//初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
|
||||
|
||||
// var add = FXManager.Instance.SetFx<SkeletonAnimation>(ui.anim_bg, Fx_Type.fx_add_box, ref closeCallback);
|
||||
// add.state.SetAnimation(0, "animation", true);
|
||||
//
|
||||
|
||||
ui.btn_close.SetClick(() =>
|
||||
{
|
||||
CtrlCloseUI();
|
||||
});
|
||||
|
||||
// HallManager.Instance.UpdateSecondEvent += updateWatchCD;
|
||||
// updateWatchCD();
|
||||
|
||||
// checkBtnState();
|
||||
|
||||
}
|
||||
|
||||
public void SetTextString()
|
||||
{
|
||||
var need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.buy_one));
|
||||
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
|
||||
|
||||
ui.text_watch_ad.SetVar("needNum", need.ToString()).FlushVars();
|
||||
ui.tips.SetVar("needAds", need.ToString()).FlushVars();
|
||||
ui.tips.SetVar("myAds", myAd.ToString()).FlushVars();
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using FGUI.ZM_Common_01;
|
||||
using SGModule.NetKit;
|
||||
using Spine.Unity;
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class AddViewUI : BaseUI
|
||||
{
|
||||
private AddViewUICtrl ctrl;
|
||||
private AddViewModel model;
|
||||
private FGUI.ZM_AddCell_12.com_addView ui;
|
||||
public int ad_cool_down = 120;
|
||||
public btn_watchAd btn_WatchAd;
|
||||
|
||||
public AddViewUI(AddViewUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.AddViewUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_AddCell_12";
|
||||
uiInfo.assetName = "com_addView";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.AddViewModel) as AddViewModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
GameHelper.showGameUI = true;
|
||||
// HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
|
||||
if (GameHelper.IsAdModelOfPay())
|
||||
{
|
||||
AdExchangeManager.Instance.Destroy();
|
||||
}
|
||||
if (need_call) GameHelper.CallShowTurn();
|
||||
}
|
||||
private bool need_call;
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.ZM_AddCell_12.com_addView;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.buy_one_show);
|
||||
if (args != null) need_call = (bool)args;
|
||||
// ad_cool_down = ConfigSystem.GetConfig<CommonModel>().exchangeCD;
|
||||
// btn_WatchAd = ui.btn_watch as btn_watchAd;
|
||||
if (GameHelper.IsAdModelOfPay())
|
||||
{
|
||||
AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_SPACE_BONUS, ui.btn_watch as btn_watchAd, SetTextString);
|
||||
ui.pay_type.selectedIndex = 0;
|
||||
|
||||
|
||||
AdExchangeManager.Instance.Start();
|
||||
SetTextString();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.pay_type.selectedIndex = 1;
|
||||
decimal price = (decimal)GameHelper.GetCommonModel().addspace2;
|
||||
ui.btn_max_pay.title = GameHelper.getPrice(price);
|
||||
ui.btn_max_pay.SetClick(() =>
|
||||
{
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)Math.Round(price * 100),
|
||||
sku =IAPPayManager.PRODUCT_SPACE_BONUS,
|
||||
currency = "USD"
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
});
|
||||
}
|
||||
|
||||
InitView();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
|
||||
}
|
||||
#endregion
|
||||
void pay_success(object str)
|
||||
{
|
||||
string type = (string)str;
|
||||
|
||||
if (type == IAPPayManager.PRODUCT_SPACE_BONUS)
|
||||
{
|
||||
CtrlCloseUI();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Action closeCallback = null;
|
||||
|
||||
//初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
|
||||
|
||||
// var add = FXManager.Instance.SetFx<SkeletonAnimation>(ui.anim_bg, Fx_Type.fx_add_box, ref closeCallback);
|
||||
// add.state.SetAnimation(0, "animation", true);
|
||||
//
|
||||
|
||||
ui.btn_close.SetClick(() =>
|
||||
{
|
||||
CtrlCloseUI();
|
||||
});
|
||||
|
||||
// HallManager.Instance.UpdateSecondEvent += updateWatchCD;
|
||||
// updateWatchCD();
|
||||
|
||||
// checkBtnState();
|
||||
|
||||
}
|
||||
|
||||
public void SetTextString()
|
||||
{
|
||||
var need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_SPACE_BONUS);
|
||||
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
|
||||
|
||||
ui.text_watch_ad.SetVar("needNum", need.ToString()).FlushVars();
|
||||
ui.tips.SetVar("needAds", need.ToString()).FlushVars();
|
||||
ui.tips.SetVar("myAds", myAd.ToString()).FlushVars();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,221 +1,221 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using FGUI.ZM_Common_01;
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class BroadcastUI : BaseUI
|
||||
{
|
||||
private BroadcastUICtrl ctrl;
|
||||
private BroadcastModel model;
|
||||
private com_broadcast1 ui;
|
||||
|
||||
public BroadcastUI(BroadcastUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.BroadcastUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_Common_01";
|
||||
uiInfo.assetName = "com_broadcast1";
|
||||
uiInfo.layerType = UILayerType.Highest;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = false;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as com_broadcast1;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
InitView();
|
||||
//ui.y = 241;
|
||||
|
||||
if (UIManager.Instance.IsExistUI(UIConst.RainPlayUI))
|
||||
{
|
||||
|
||||
Settop();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Setbuttom();
|
||||
}
|
||||
// ui.visible = false;
|
||||
// if (Screen.safeArea.y != 0)
|
||||
// {//刘海屏
|
||||
// ui.y += Screen.safeArea.y;
|
||||
// }
|
||||
text_ui = ui.broad_cast_text;
|
||||
|
||||
|
||||
text_ui.btn_broad.SetClick(OpenRecord);
|
||||
|
||||
if (ConfigSystem.GetConfig<SubscribePodcast>() == null) return;
|
||||
config_name_list = SubscribePodcastModel.config_name_list;
|
||||
config_vip_level_list = SubscribePodcastModel.config_vip_level_list;
|
||||
|
||||
GameDispatcher.Instance.AddListener(GameMsg.hideBroadCast, hideEvent);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.showBroadCast, showEvent);
|
||||
UICtrlDispatcher.Instance.AddListener(UICtrlMsg.MainUI_Open, Setbuttom);
|
||||
UICtrlDispatcher.Instance.AddListener(UICtrlMsg.RainPlayUI_Open, Settop);
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
private int time_count = 11;
|
||||
private com_broadcast_text1 text_ui;
|
||||
private List<string> config_name_list;
|
||||
private List<string> config_vip_level_list;
|
||||
private bool main_ui_show = true;
|
||||
//初始化页面逻辑
|
||||
|
||||
private Action closeCallback;
|
||||
private void InitView()
|
||||
{
|
||||
HallManager.Instance.UpdateSecondEvent += timeEvent;
|
||||
|
||||
|
||||
var sk = FXManager.Instance.SetFx<SkeletonAnimation>(ui.broad_cast_text.bg_panel, Fx_Type.fx_broad, ref closeCallback);
|
||||
sk.state.SetAnimation(0, "animation", true);
|
||||
ui.broad_cast_text.bg_panel.SetScale(1.45f, 1.1f);
|
||||
}
|
||||
|
||||
private void OpenRecord()
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.RecordViewUI_Open);
|
||||
}
|
||||
private void hideEvent(object sender = null)
|
||||
{
|
||||
Debug.Log("hide");
|
||||
main_ui_show = false;
|
||||
ui.visible = false;
|
||||
}
|
||||
private void showEvent(object sender = null)
|
||||
{
|
||||
Debug.Log("show");
|
||||
main_ui_show = true;
|
||||
ui.visible = true;
|
||||
}
|
||||
private void Settop(object sender = null)
|
||||
{
|
||||
ui.group_.y = 350;
|
||||
if (Screen.safeArea.y != 0)
|
||||
{//刘海屏
|
||||
ui.group_.y += 68;
|
||||
}
|
||||
}
|
||||
private void Setbuttom(object sender = null)
|
||||
{
|
||||
ui.group_.y = 170;
|
||||
if (Screen.safeArea.y != 0)
|
||||
{//刘海屏
|
||||
ui.group_.y += 68;
|
||||
}
|
||||
}
|
||||
# if GAME_RELEASE
|
||||
private const int MaxTime = 300;
|
||||
#else
|
||||
private const int MaxTime = 10;
|
||||
#endif
|
||||
void timeEvent()
|
||||
{
|
||||
time_count++;
|
||||
Debug.Log(time_count);
|
||||
Debug.Log(MaxTime);
|
||||
if (time_count > MaxTime)
|
||||
{
|
||||
time_count = 0;
|
||||
var name_index = Random.Range(0, config_name_list.Count);
|
||||
var money_index = Random.Range(0, config_vip_level_list.Count);
|
||||
Debug.Log(text_ui.cast_text.text);
|
||||
|
||||
string name = config_name_list[name_index];
|
||||
if (name.Length > 8)
|
||||
{
|
||||
name = name[..8] + "..";
|
||||
}
|
||||
string broad_text = String.Format(text_ui.hide_text.text, name,
|
||||
config_vip_level_list[money_index], DateTimeManager.Instance.GetCurrDateTime());
|
||||
text_ui.cast_text.text = broad_text;
|
||||
|
||||
var lv = GetVipLevelFromName(config_vip_level_list[money_index]);
|
||||
text_ui.broad_icon_loader.url = $"ui://LG_Common/vip_{lv}";
|
||||
|
||||
// Tweener tweener = DOTween.To(() => ui.broad.x,
|
||||
// x => ui.broad.x = x, 200, 0.5f);
|
||||
ui.t0.Play();
|
||||
|
||||
DOVirtual.DelayedCall(3.5f, () =>
|
||||
{
|
||||
// Tweener tweener = DOTween.To(() => ui.broad.x,
|
||||
// x => ui.broad.x = x, 1080, 0.5f);
|
||||
ui.t1.Play();
|
||||
});
|
||||
string str = name + "#" + config_vip_level_list[money_index] + "#" + DateTimeManager.Instance.GetCurrDateTime();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.updateRecordList, str);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private int GetVipLevelFromName(string name)
|
||||
{
|
||||
var vip_level = 1;
|
||||
switch (name)
|
||||
{
|
||||
case "Gold":
|
||||
vip_level = 1;
|
||||
break;
|
||||
case "Platinum":
|
||||
vip_level = 2;
|
||||
break;
|
||||
case "Diamond":
|
||||
vip_level = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
return vip_level;
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using FGUI.ZM_Common_01;
|
||||
using Spine.Unity;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class BroadcastUI : BaseUI
|
||||
{
|
||||
private BroadcastUICtrl ctrl;
|
||||
private BroadcastModel model;
|
||||
private com_broadcast1 ui;
|
||||
|
||||
public BroadcastUI(BroadcastUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.BroadcastUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_Common_01";
|
||||
uiInfo.assetName = "com_broadcast1";
|
||||
uiInfo.layerType = UILayerType.Highest;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = false;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as com_broadcast1;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
InitView();
|
||||
//ui.y = 241;
|
||||
|
||||
if (UIManager.Instance.IsExistUI(UIConst.RainPlayUI))
|
||||
{
|
||||
|
||||
Settop();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Setbuttom();
|
||||
}
|
||||
// ui.visible = false;
|
||||
// if (Screen.safeArea.y != 0)
|
||||
// {//刘海屏
|
||||
// ui.y += Screen.safeArea.y;
|
||||
// }
|
||||
text_ui = ui.broad_cast_text;
|
||||
|
||||
|
||||
text_ui.btn_broad.SetClick(OpenRecord);
|
||||
|
||||
if (ConfigSystem.GetConfig<SubscribePodcast>() == null) return;
|
||||
config_name_list = SubscribePodcastModel.config_name_list;
|
||||
config_vip_level_list = SubscribePodcastModel.config_vip_level_list;
|
||||
|
||||
GameDispatcher.Instance.AddListener(GameMsg.hideBroadCast, hideEvent);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.showBroadCast, showEvent);
|
||||
UICtrlDispatcher.Instance.AddListener(UICtrlMsg.MainUI_Open, Setbuttom);
|
||||
UICtrlDispatcher.Instance.AddListener(UICtrlMsg.RainPlayUI_Open, Settop);
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
private int time_count = 11;
|
||||
private com_broadcast_text1 text_ui;
|
||||
private List<string> config_name_list;
|
||||
private List<string> config_vip_level_list;
|
||||
private bool main_ui_show = true;
|
||||
//初始化页面逻辑
|
||||
|
||||
private Action closeCallback;
|
||||
private void InitView()
|
||||
{
|
||||
HallManager.Instance.UpdateSecondEvent += timeEvent;
|
||||
|
||||
|
||||
var sk = FXManager.Instance.SetFx<SkeletonAnimation>(ui.broad_cast_text.bg_panel, Fx_Type.fx_broad, ref closeCallback);
|
||||
sk.state.SetAnimation(0, "animation", true);
|
||||
ui.broad_cast_text.bg_panel.SetScale(1.45f, 1.1f);
|
||||
}
|
||||
|
||||
private void OpenRecord()
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.RecordViewUI_Open);
|
||||
}
|
||||
private void hideEvent(object sender = null)
|
||||
{
|
||||
Debug.Log("hide");
|
||||
main_ui_show = false;
|
||||
ui.visible = false;
|
||||
}
|
||||
private void showEvent(object sender = null)
|
||||
{
|
||||
Debug.Log("show");
|
||||
main_ui_show = true;
|
||||
ui.visible = true;
|
||||
}
|
||||
private void Settop(object sender = null)
|
||||
{
|
||||
ui.group_.y = 350;
|
||||
if (Screen.safeArea.y != 0)
|
||||
{//刘海屏
|
||||
ui.group_.y += 68;
|
||||
}
|
||||
}
|
||||
private void Setbuttom(object sender = null)
|
||||
{
|
||||
ui.group_.y = 170;
|
||||
if (Screen.safeArea.y != 0)
|
||||
{//刘海屏
|
||||
ui.group_.y += 68;
|
||||
}
|
||||
}
|
||||
# if GAME_RELEASE
|
||||
private const int MaxTime = 300;
|
||||
#else
|
||||
private const int MaxTime = 10;
|
||||
#endif
|
||||
void timeEvent()
|
||||
{
|
||||
time_count++;
|
||||
// Debug.Log(time_count);
|
||||
// Debug.Log(MaxTime);
|
||||
if (time_count > MaxTime)
|
||||
{
|
||||
time_count = 0;
|
||||
var name_index = Random.Range(0, config_name_list.Count);
|
||||
var money_index = Random.Range(0, config_vip_level_list.Count);
|
||||
Debug.Log(text_ui.cast_text.text);
|
||||
|
||||
string name = config_name_list[name_index];
|
||||
if (name.Length > 8)
|
||||
{
|
||||
name = name[..8] + "..";
|
||||
}
|
||||
string broad_text = String.Format(text_ui.hide_text.text, name,
|
||||
config_vip_level_list[money_index], DateTimeManager.Instance.GetCurrDateTime());
|
||||
text_ui.cast_text.text = broad_text;
|
||||
|
||||
var lv = GetVipLevelFromName(config_vip_level_list[money_index]);
|
||||
text_ui.broad_icon_loader.url = $"ui://LG_Common/vip_{lv}";
|
||||
|
||||
// Tweener tweener = DOTween.To(() => ui.broad.x,
|
||||
// x => ui.broad.x = x, 200, 0.5f);
|
||||
ui.t0.Play();
|
||||
|
||||
DOVirtual.DelayedCall(3.5f, () =>
|
||||
{
|
||||
// Tweener tweener = DOTween.To(() => ui.broad.x,
|
||||
// x => ui.broad.x = x, 1080, 0.5f);
|
||||
ui.t1.Play();
|
||||
});
|
||||
string str = name + "#" + config_vip_level_list[money_index] + "#" + DateTimeManager.Instance.GetCurrDateTime();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.updateRecordList, str);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private int GetVipLevelFromName(string name)
|
||||
{
|
||||
var vip_level = 1;
|
||||
switch (name)
|
||||
{
|
||||
case "Gold":
|
||||
vip_level = 1;
|
||||
break;
|
||||
case "Platinum":
|
||||
vip_level = 2;
|
||||
break;
|
||||
case "Diamond":
|
||||
vip_level = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
return vip_level;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,8 +511,9 @@ namespace RedHotRoast
|
||||
|
||||
ui.btn_live.SetClick(() =>
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretUnlockUI_Open);
|
||||
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LiveUI_Open);
|
||||
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LiveUI_Open);
|
||||
|
||||
});
|
||||
ui.btn_secret.title = "LV." + GameHelper.GetCommonModel().UnlockSecret[1];
|
||||
@@ -593,6 +594,8 @@ namespace RedHotRoast
|
||||
ui.btn_task.SetClick(() => { OnClickTask(false); });
|
||||
ui.btn_restore.SetClick(() =>
|
||||
{
|
||||
IAPPayManager.Instance.OnRestoreButtonClicked();
|
||||
|
||||
// ApplePayManager.Instance.AppleRestore((success, message) =>
|
||||
// {
|
||||
// Debug.Log($"[barry] restore success message: {message}---- {JsonConvert.SerializeObject(message)}");
|
||||
|
||||
@@ -1,362 +1,362 @@
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
using DG.Tweening;
|
||||
using FGUI.ZM_Common_01;
|
||||
using System;
|
||||
using SGModule.NetKit;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class LuckyPackUI : BaseUI
|
||||
{
|
||||
private LuckyPackUICtrl ctrl;
|
||||
private LuckyPackModel model;
|
||||
private FGUI.LG_LuckyGift.com_lucky ui;
|
||||
private List<Paidgift> list;
|
||||
|
||||
public LuckyPackUI(LuckyPackUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.LuckyPackUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "LG_LuckyGift";
|
||||
uiInfo.assetName = "com_lucky";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.PackrewardModel) as LuckyPackModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
AdExchangeManager.Instance.Destroy();
|
||||
GameHelper.showGameUI = true;
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.pack_close);
|
||||
int three_gift_got_index = SaveData.GetSaveObject().three_gift_got_index;
|
||||
// if (GameHelper.isAutoPop && (three_gift_got_index <= (int)rewardState.day3))
|
||||
// {
|
||||
// uiCtrlDispatcher.Dispatch(UICtrlMsg.ThreeDaysGiftUI_Open);
|
||||
// GameHelper.isAutoPop = false;
|
||||
// }
|
||||
GameHelper.CallShowTurn();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.LG_LuckyGift.com_lucky;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
|
||||
ui.gold.GetChild("text_gold").text = GameHelper.Get101Str(GameHelper.GetGoldNumber());
|
||||
var needScroll = false;
|
||||
if (args != null) needScroll = (bool)args;
|
||||
ui.type.selectedIndex = needScroll ? 1 : 0;
|
||||
ui.gift_switch.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;
|
||||
Debug.Log($"needScroll============={needScroll}= {ui.type.selectedIndex}");
|
||||
TrackKit.SendEvent(GameHelper.GetEventName(), needScroll ? ADEventTrack.Property.gift_show : ADEventTrack.Property.first_pack_show);
|
||||
|
||||
list = ConfigSystem.GetConfig<Paidgift>();
|
||||
|
||||
if (GameHelper.IsAdModelOfPay())
|
||||
{
|
||||
|
||||
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.pack_reward), ui.btn_buypack as btn_watchAd, SetTextString1);
|
||||
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.remove_ad), ui.btn_buyremovead as btn_watchAd, SetTextString1);
|
||||
}
|
||||
|
||||
ui.btn_go_ad.SetClick(() =>
|
||||
{
|
||||
ui.type.selectedIndex = 1;
|
||||
});
|
||||
ui.btn_go_lucky.SetClick(() =>
|
||||
{
|
||||
ui.type.selectedIndex = 0;
|
||||
});
|
||||
|
||||
InitView();
|
||||
// var fileName = GameHelper.GetBackgroundName(1);
|
||||
// Debug.Log($"fileName======{fileName}");
|
||||
// TextureHelper.SetImgLoader(ui.no_ad_pic.picture, fileName, null, "Background/");
|
||||
//
|
||||
// var fileName1 = GameHelper.GetBackgroundName(2);
|
||||
// Debug.Log($"fileName1======{fileName1}");
|
||||
//
|
||||
// TextureHelper.SetImgLoader(ui.lucky_pic.picture, fileName1, null, "Background/");
|
||||
|
||||
|
||||
|
||||
// var fileName = GameHelper.GetBackgroundName(1);
|
||||
// var task = new List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)>();
|
||||
// task.Add((ui.lucky_pic.picture, fileName, null, "Background/", FolderNames.BackgroundName));
|
||||
// var fileName1 = GameHelper.GetBackgroundName(2);
|
||||
// task.Add((ui.no_ad_pic.picture, fileName1, null, "Background/", FolderNames.BackgroundName));
|
||||
// TextureHelper.SetImgLoaders(task);
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||||
}
|
||||
#endregion
|
||||
void pay_success(object str)
|
||||
{
|
||||
string type = (string)str;
|
||||
Debug.Log($"pay_success type================{type}");
|
||||
if (type == PurchasingManager.GetPaySku(PayType.remove_ad))
|
||||
{
|
||||
var gold = list[1].coins_quantity;
|
||||
var start = GameHelper.GetUICenterPosition(ui.text_goldnum2);
|
||||
var end = GameHelper.GetUICenterPosition(ui.gold.GetChild("icon"));
|
||||
|
||||
var rewardData = new RewardData();
|
||||
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
|
||||
{
|
||||
startPosition = start,
|
||||
endPosition = end,
|
||||
};
|
||||
rewardData.AddReward(rewardSingleData);
|
||||
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
||||
rewardData.AddCompleted((isScu) =>
|
||||
{
|
||||
DOVirtual.DelayedCall(0.5f, () =>
|
||||
{
|
||||
var startNum = DataMgr.Coin.Value - gold;
|
||||
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f,
|
||||
value => { ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); });
|
||||
});
|
||||
});
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
||||
|
||||
|
||||
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AdcomingUI_Close);
|
||||
SaveData.GetSaveObject().is_get_removead = true;
|
||||
SaveData.SaveDataFunc();
|
||||
InitView();
|
||||
|
||||
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.pack_reward))
|
||||
{
|
||||
var start = GameHelper.GetUICenterPosition(ui.text_goldnum);
|
||||
var end = GameHelper.GetUICenterPosition(ui.gold.GetChild("icon"));
|
||||
var gold = list[0].coins_quantity;
|
||||
|
||||
var rewardData = new RewardData();
|
||||
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
|
||||
{
|
||||
startPosition = start,
|
||||
endPosition = end,
|
||||
};
|
||||
rewardData.AddReward(rewardSingleData);
|
||||
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
||||
rewardData.AddCompleted((isScu) =>
|
||||
{
|
||||
DOVirtual.DelayedCall(0.5f, () =>
|
||||
{
|
||||
var startNum = DataMgr.Coin.Value - gold;
|
||||
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f,
|
||||
value => { ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); });
|
||||
});
|
||||
});
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
||||
SaveData.GetSaveObject().is_get_packreward = true;
|
||||
|
||||
SaveData.SaveDataFunc();
|
||||
|
||||
InitView();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//初始化页面逻辑
|
||||
private int gold_num = 300;
|
||||
private int back_num = 1;
|
||||
private int out_num = 1;
|
||||
private int refresh_num = 1;
|
||||
private void InitView()
|
||||
{
|
||||
gold_num = list[0].coins_quantity;
|
||||
back_num = list[0].props_quantity[1];
|
||||
out_num = list[0].props_quantity[0];
|
||||
refresh_num = list[0].props_quantity[2];
|
||||
|
||||
ui.text_time.SetVar("time", ConfigSystem.GetCommonConf().RemoveADsPackDuration.ToString()).FlushVars();
|
||||
|
||||
ui.btn_close.SetClick(CtrlCloseUI);
|
||||
ui.btn_luck_close.SetClick(CtrlCloseUI);
|
||||
ui.text_goldnum.text = "x" + GameHelper.Get101Str(gold_num);
|
||||
ui.text_backnum1.text = "x" + back_num;
|
||||
ui.text_outnum.text = "x" + out_num;
|
||||
ui.text_refreshnum.text = "x" + refresh_num;
|
||||
var buy_text = ui.btn_buypack.GetChild("title") as GTextField;
|
||||
buy_text.SetVar("price", list[0].Paid_price.ToString()).FlushVars();
|
||||
|
||||
ui.text_goldnum2.text = "x" + GameHelper.Get101Str(list[1].coins_quantity);
|
||||
var buy_text1 = ui.btn_buyremovead.GetChild("title") as GTextField;
|
||||
buy_text1.SetVar("price", list[1].Paid_price.ToString()).FlushVars();
|
||||
|
||||
if (!GameHelper.IsAdModelOfPay())
|
||||
{
|
||||
ui.pay_type.selectedIndex = 1;
|
||||
decimal price_pack = (decimal)list[0].Paid_price2;
|
||||
ui.btn_max_pack.title = GameHelper.Get102Str(price_pack);
|
||||
bool is_get = SaveData.GetSaveObject().is_get_packreward;
|
||||
Debug.Log($"is_get================{is_get}");
|
||||
if (is_get)
|
||||
{
|
||||
ui.btn_max_pack.enabled = false;
|
||||
ui.btn_max_pack.SetClick(() => { });
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ui.btn_max_pack.SetClick(() =>
|
||||
{
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)Math.Round(price_pack * 100),
|
||||
sku = PurchasingManager.GetPaySku(PayType.pack_reward),
|
||||
currency = "USD"
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
});
|
||||
}
|
||||
decimal price_remove = (decimal)list[1].Paid_price2;
|
||||
ui.btn_max_remove.title = GameHelper.Get102Str(price_remove);
|
||||
bool is_get1 = SaveData.GetSaveObject().is_get_removead;
|
||||
Debug.Log($"is_get1================{is_get1}");
|
||||
if (is_get1)
|
||||
{
|
||||
HallManager.Instance.UpdateSecondEvent += RemoveAdCountDown;
|
||||
ui.btn_max_remove.enabled = false;
|
||||
ui.btn_max_remove.SetClick(() => { });
|
||||
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
|
||||
if (cd > 24 * 3600)
|
||||
{
|
||||
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_max_remove.SetClick(() =>
|
||||
{
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)Math.Round(price_remove * 100),
|
||||
sku = PurchasingManager.GetPaySku(PayType.remove_ad),
|
||||
currency = "USD"
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.pay_type.selectedIndex = 0;
|
||||
AdExchangeManager.Instance.Start();
|
||||
SetTextString1();
|
||||
|
||||
decimal price_remove = (decimal)list[1].Paid_price2;
|
||||
bool is_get1 = SaveData.GetSaveObject().is_get_removead;
|
||||
|
||||
if (is_get1)
|
||||
{
|
||||
HallManager.Instance.UpdateSecondEvent += RemoveAdCountDown;
|
||||
|
||||
ui.btn_buyremovead.enabled = false;
|
||||
ui.btn_buyremovead.SetClick(() => { });
|
||||
|
||||
var lastTimes = SaveData.GetSaveObject()._watch_ad_cd;
|
||||
if (GameHelper.GetNowTime() < lastTimes)
|
||||
{
|
||||
|
||||
}
|
||||
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
|
||||
if (cd > 24 * 3600)
|
||||
{
|
||||
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void RemoveAdCountDown()
|
||||
{
|
||||
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
|
||||
if (cd > 0)
|
||||
{
|
||||
if (cd > 24 * 3600)
|
||||
{
|
||||
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
|
||||
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
|
||||
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SaveData.GetSaveObject().is_get_removead = false;
|
||||
SaveData.GetSaveObject().remove_ad_time = 0;
|
||||
InitView();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTextString1()
|
||||
{
|
||||
var remove_need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.remove_ad));
|
||||
var pack_need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.pack_reward));
|
||||
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
|
||||
|
||||
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
|
||||
ui.tips1.SetVar("num", pack_need.ToString()).FlushVars();
|
||||
ui.tips2.SetVar("num", remove_need.ToString()).FlushVars();
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
using DG.Tweening;
|
||||
using FGUI.ZM_Common_01;
|
||||
using System;
|
||||
using SGModule.NetKit;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class LuckyPackUI : BaseUI
|
||||
{
|
||||
private LuckyPackUICtrl ctrl;
|
||||
private LuckyPackModel model;
|
||||
private FGUI.LG_LuckyGift.com_lucky ui;
|
||||
private List<Paidgift> list;
|
||||
|
||||
public LuckyPackUI(LuckyPackUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.LuckyPackUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "LG_LuckyGift";
|
||||
uiInfo.assetName = "com_lucky";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.PackrewardModel) as LuckyPackModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
AdExchangeManager.Instance.Destroy();
|
||||
GameHelper.showGameUI = true;
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.pack_close);
|
||||
int three_gift_got_index = SaveData.GetSaveObject().three_gift_got_index;
|
||||
// if (GameHelper.isAutoPop && (three_gift_got_index <= (int)rewardState.day3))
|
||||
// {
|
||||
// uiCtrlDispatcher.Dispatch(UICtrlMsg.ThreeDaysGiftUI_Open);
|
||||
// GameHelper.isAutoPop = false;
|
||||
// }
|
||||
GameHelper.CallShowTurn();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.LG_LuckyGift.com_lucky;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
|
||||
ui.gold.GetChild("text_gold").text = GameHelper.Get101Str(GameHelper.GetGoldNumber());
|
||||
var needScroll = false;
|
||||
if (args != null) needScroll = (bool)args;
|
||||
ui.type.selectedIndex = needScroll ? 1 : 0;
|
||||
ui.gift_switch.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;
|
||||
Debug.Log($"needScroll============={needScroll}= {ui.type.selectedIndex}");
|
||||
TrackKit.SendEvent(GameHelper.GetEventName(), needScroll ? ADEventTrack.Property.gift_show : ADEventTrack.Property.first_pack_show);
|
||||
|
||||
list = ConfigSystem.GetConfig<Paidgift>();
|
||||
|
||||
if (GameHelper.IsAdModelOfPay())
|
||||
{
|
||||
|
||||
AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_FIRST_GIFT, ui.btn_buypack as btn_watchAd, SetTextString1);
|
||||
AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_REMOVE_ADS, ui.btn_buyremovead as btn_watchAd, SetTextString1);
|
||||
}
|
||||
|
||||
ui.btn_go_ad.SetClick(() =>
|
||||
{
|
||||
ui.type.selectedIndex = 1;
|
||||
});
|
||||
ui.btn_go_lucky.SetClick(() =>
|
||||
{
|
||||
ui.type.selectedIndex = 0;
|
||||
});
|
||||
|
||||
InitView();
|
||||
// var fileName = GameHelper.GetBackgroundName(1);
|
||||
// Debug.Log($"fileName======{fileName}");
|
||||
// TextureHelper.SetImgLoader(ui.no_ad_pic.picture, fileName, null, "Background/");
|
||||
//
|
||||
// var fileName1 = GameHelper.GetBackgroundName(2);
|
||||
// Debug.Log($"fileName1======{fileName1}");
|
||||
//
|
||||
// TextureHelper.SetImgLoader(ui.lucky_pic.picture, fileName1, null, "Background/");
|
||||
|
||||
|
||||
|
||||
// var fileName = GameHelper.GetBackgroundName(1);
|
||||
// var task = new List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)>();
|
||||
// task.Add((ui.lucky_pic.picture, fileName, null, "Background/", FolderNames.BackgroundName));
|
||||
// var fileName1 = GameHelper.GetBackgroundName(2);
|
||||
// task.Add((ui.no_ad_pic.picture, fileName1, null, "Background/", FolderNames.BackgroundName));
|
||||
// TextureHelper.SetImgLoaders(task);
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
}
|
||||
#endregion
|
||||
void pay_success(object str)
|
||||
{
|
||||
string type = (string)str;
|
||||
Debug.Log($"pay_success type================{type}");
|
||||
if (type == IAPPayManager.PRODUCT_REMOVE_ADS)
|
||||
{
|
||||
var gold = list[1].coins_quantity;
|
||||
var start = GameHelper.GetUICenterPosition(ui.text_goldnum2);
|
||||
var end = GameHelper.GetUICenterPosition(ui.gold.GetChild("icon"));
|
||||
|
||||
var rewardData = new RewardData();
|
||||
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
|
||||
{
|
||||
startPosition = start,
|
||||
endPosition = end,
|
||||
};
|
||||
rewardData.AddReward(rewardSingleData);
|
||||
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
||||
rewardData.AddCompleted((isScu) =>
|
||||
{
|
||||
DOVirtual.DelayedCall(0.5f, () =>
|
||||
{
|
||||
var startNum = DataMgr.Coin.Value - gold;
|
||||
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f,
|
||||
value => { ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); });
|
||||
});
|
||||
});
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
||||
|
||||
|
||||
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AdcomingUI_Close);
|
||||
SaveData.GetSaveObject().is_get_removead = true;
|
||||
SaveData.SaveDataFunc();
|
||||
InitView();
|
||||
|
||||
|
||||
}
|
||||
else if (type == IAPPayManager.PRODUCT_FIRST_GIFT)
|
||||
{
|
||||
var start = GameHelper.GetUICenterPosition(ui.text_goldnum);
|
||||
var end = GameHelper.GetUICenterPosition(ui.gold.GetChild("icon"));
|
||||
var gold = list[0].coins_quantity;
|
||||
|
||||
var rewardData = new RewardData();
|
||||
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
|
||||
{
|
||||
startPosition = start,
|
||||
endPosition = end,
|
||||
};
|
||||
rewardData.AddReward(rewardSingleData);
|
||||
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
||||
rewardData.AddCompleted((isScu) =>
|
||||
{
|
||||
DOVirtual.DelayedCall(0.5f, () =>
|
||||
{
|
||||
var startNum = DataMgr.Coin.Value - gold;
|
||||
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f,
|
||||
value => { ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); });
|
||||
});
|
||||
});
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
||||
SaveData.GetSaveObject().is_get_packreward = true;
|
||||
|
||||
SaveData.SaveDataFunc();
|
||||
|
||||
InitView();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//初始化页面逻辑
|
||||
private int gold_num = 300;
|
||||
private int back_num = 1;
|
||||
private int out_num = 1;
|
||||
private int refresh_num = 1;
|
||||
private void InitView()
|
||||
{
|
||||
gold_num = list[0].coins_quantity;
|
||||
back_num = list[0].props_quantity[1];
|
||||
out_num = list[0].props_quantity[0];
|
||||
refresh_num = list[0].props_quantity[2];
|
||||
|
||||
ui.text_time.SetVar("time", ConfigSystem.GetCommonConf().RemoveADsPackDuration.ToString()).FlushVars();
|
||||
|
||||
ui.btn_close.SetClick(CtrlCloseUI);
|
||||
ui.btn_luck_close.SetClick(CtrlCloseUI);
|
||||
ui.text_goldnum.text = "x" + GameHelper.Get101Str(gold_num);
|
||||
ui.text_backnum1.text = "x" + back_num;
|
||||
ui.text_outnum.text = "x" + out_num;
|
||||
ui.text_refreshnum.text = "x" + refresh_num;
|
||||
var buy_text = ui.btn_buypack.GetChild("title") as GTextField;
|
||||
buy_text.SetVar("price", list[0].Paid_price.ToString()).FlushVars();
|
||||
|
||||
ui.text_goldnum2.text = "x" + GameHelper.Get101Str(list[1].coins_quantity);
|
||||
var buy_text1 = ui.btn_buyremovead.GetChild("title") as GTextField;
|
||||
buy_text1.SetVar("price", list[1].Paid_price.ToString()).FlushVars();
|
||||
|
||||
if (!GameHelper.IsAdModelOfPay())
|
||||
{
|
||||
ui.pay_type.selectedIndex = 1;
|
||||
decimal price_pack = (decimal)list[0].Paid_price2;
|
||||
ui.btn_max_pack.title = GameHelper.Get102Str(price_pack);
|
||||
bool is_get = SaveData.GetSaveObject().is_get_packreward;
|
||||
Debug.Log($"is_get================{is_get}");
|
||||
if (is_get)
|
||||
{
|
||||
ui.btn_max_pack.enabled = false;
|
||||
ui.btn_max_pack.SetClick(() => { });
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ui.btn_max_pack.SetClick(() =>
|
||||
{
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)Math.Round(price_pack * 100),
|
||||
sku = IAPPayManager.PRODUCT_FIRST_GIFT,
|
||||
currency = "USD"
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
});
|
||||
}
|
||||
decimal price_remove = (decimal)list[1].Paid_price2;
|
||||
ui.btn_max_remove.title = GameHelper.Get102Str(price_remove);
|
||||
bool is_get1 = SaveData.GetSaveObject().is_get_removead;
|
||||
Debug.Log($"is_get1================{is_get1}");
|
||||
if (is_get1)
|
||||
{
|
||||
HallManager.Instance.UpdateSecondEvent += RemoveAdCountDown;
|
||||
ui.btn_max_remove.enabled = false;
|
||||
ui.btn_max_remove.SetClick(() => { });
|
||||
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
|
||||
if (cd > 24 * 3600)
|
||||
{
|
||||
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_max_remove.SetClick(() =>
|
||||
{
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)Math.Round(price_remove * 100),
|
||||
sku = IAPPayManager.PRODUCT_REMOVE_ADS,
|
||||
currency = "USD"
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.pay_type.selectedIndex = 0;
|
||||
AdExchangeManager.Instance.Start();
|
||||
SetTextString1();
|
||||
|
||||
decimal price_remove = (decimal)list[1].Paid_price2;
|
||||
bool is_get1 = SaveData.GetSaveObject().is_get_removead;
|
||||
|
||||
if (is_get1)
|
||||
{
|
||||
HallManager.Instance.UpdateSecondEvent += RemoveAdCountDown;
|
||||
|
||||
ui.btn_buyremovead.enabled = false;
|
||||
ui.btn_buyremovead.SetClick(() => { });
|
||||
|
||||
var lastTimes = SaveData.GetSaveObject()._watch_ad_cd;
|
||||
if (GameHelper.GetNowTime() < lastTimes)
|
||||
{
|
||||
|
||||
}
|
||||
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
|
||||
if (cd > 24 * 3600)
|
||||
{
|
||||
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void RemoveAdCountDown()
|
||||
{
|
||||
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
|
||||
if (cd > 0)
|
||||
{
|
||||
if (cd > 24 * 3600)
|
||||
{
|
||||
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
|
||||
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
|
||||
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SaveData.GetSaveObject().is_get_removead = false;
|
||||
SaveData.GetSaveObject().remove_ad_time = 0;
|
||||
InitView();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTextString1()
|
||||
{
|
||||
var remove_need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_REMOVE_ADS);
|
||||
var pack_need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_FIRST_GIFT);
|
||||
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
|
||||
|
||||
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
|
||||
ui.tips1.SetVar("num", pack_need.ToString()).FlushVars();
|
||||
ui.tips2.SetVar("num", remove_need.ToString()).FlushVars();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace RedHotRoast
|
||||
ui.com_gold.y += Screen.safeArea.y;
|
||||
|
||||
}
|
||||
ui.gift_switch.selectedIndex = 1;
|
||||
ui.gift_switch.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;
|
||||
|
||||
total_item = 8;
|
||||
selectIndex = DataMgr.PlayerAvatarId.Value;
|
||||
@@ -143,6 +143,8 @@ namespace RedHotRoast
|
||||
// ui.btn_credits.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 2); });
|
||||
ui.btn_restore.SetClick(() =>
|
||||
{
|
||||
//恢复购买按钮
|
||||
IAPPayManager.Instance.OnRestoreButtonClicked();
|
||||
// ApplePayManager.Instance.AppleRestore((success, message) =>
|
||||
// {
|
||||
// if (success)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,146 +1,146 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FGUI.ZM_Common_01;
|
||||
using SGModule.NetKit;
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class PassunlockUI : BaseUI
|
||||
{
|
||||
private PassunlockUICtrl ctrl;
|
||||
private PassunlockModel model;
|
||||
private FGUI.ZM_Pack_16.com_passunlock ui;
|
||||
|
||||
public btn_watchAd btn_WatchAd;
|
||||
|
||||
public PassunlockUI(PassunlockUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.PassunlockUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_Pack_16";
|
||||
uiInfo.assetName = "com_passunlock";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.PassunlockModel) as PassunlockModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
AdExchangeManager.Instance.Destroy();
|
||||
GameHelper.CallShowTurn();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.ZM_Pack_16.com_passunlock;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
if (GameHelper.IsAdModelOfPay()) {
|
||||
ui.pay_type.selectedIndex = 0;
|
||||
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.battle_pass), ui.btn_buypass as btn_watchAd,SetTextString);
|
||||
|
||||
AdExchangeManager.Instance.Start();
|
||||
SetTextString();
|
||||
|
||||
} else {
|
||||
ui.pay_type.selectedIndex = 1;
|
||||
decimal price = (decimal)GameHelper.GetCommonModel().Passportgift2;
|
||||
ui.btn_max_pay.title = GameHelper.Get102Str(price);
|
||||
|
||||
ui.btn_max_pay.SetClick(() => {
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)Math.Round(price * 100),
|
||||
sku = PurchasingManager.GetPaySku(PayType.battle_pass),
|
||||
currency = "USD"
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
});
|
||||
}
|
||||
ui.gift_switch.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;
|
||||
InitView();
|
||||
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.master_pass_show);
|
||||
|
||||
var fileName = GameHelper.GetBackgroundName(3);
|
||||
TextureHelper.SetImgLoader(ui.loader.picture, fileName, null, "Background/", FolderNames.BackgroundName);
|
||||
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||||
}
|
||||
#endregion
|
||||
void pay_success(object str)
|
||||
{
|
||||
string type = (string)str;
|
||||
string purch_number = "";
|
||||
|
||||
if (type == PurchasingManager.GetPaySku(PayType.battle_pass))
|
||||
{
|
||||
CtrlCloseUI();
|
||||
}
|
||||
// if (purch_number != "")
|
||||
// {
|
||||
// GameHelper.SendRevenueToAF(purch_number);
|
||||
// }
|
||||
}
|
||||
//初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
ui.btn_close.SetClick(CtrlCloseUI);
|
||||
int gold = 0;
|
||||
|
||||
List<Passportrewards> Passportrewards_list = ConfigSystem.GetConfig<Passportrewards>();
|
||||
for (int i = 0; i < Passportrewards_list.Count; i++)
|
||||
{
|
||||
|
||||
if (Passportrewards_list[i].Paid_rewards_type == 0) gold += Passportrewards_list[i].Paid_rewards_num;
|
||||
|
||||
}
|
||||
ui.text_allgold.text = GameHelper.Get101Str(gold);
|
||||
// ui.btn_buypass.GetChild("title").text = "$" + ConfigSystem.GetConfig<CommonModel>().Passportgift;
|
||||
|
||||
}
|
||||
|
||||
public void SetTextString()
|
||||
{
|
||||
var need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.battle_pass));
|
||||
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
|
||||
|
||||
ui.tips.SetVar("num", need.ToString()).FlushVars();
|
||||
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FGUI.ZM_Common_01;
|
||||
using SGModule.NetKit;
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class PassunlockUI : BaseUI
|
||||
{
|
||||
private PassunlockUICtrl ctrl;
|
||||
private PassunlockModel model;
|
||||
private FGUI.ZM_Pack_16.com_passunlock ui;
|
||||
|
||||
public btn_watchAd btn_WatchAd;
|
||||
|
||||
public PassunlockUI(PassunlockUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.PassunlockUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_Pack_16";
|
||||
uiInfo.assetName = "com_passunlock";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.PassunlockModel) as PassunlockModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
AdExchangeManager.Instance.Destroy();
|
||||
GameHelper.CallShowTurn();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.ZM_Pack_16.com_passunlock;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
if (GameHelper.IsAdModelOfPay()) {
|
||||
ui.pay_type.selectedIndex = 0;
|
||||
AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_PASS_BONUS, ui.btn_buypass as btn_watchAd,SetTextString);
|
||||
|
||||
AdExchangeManager.Instance.Start();
|
||||
SetTextString();
|
||||
|
||||
} else {
|
||||
ui.pay_type.selectedIndex = 1;
|
||||
decimal price = (decimal)GameHelper.GetCommonModel().Passportgift2;
|
||||
ui.btn_max_pay.title = GameHelper.Get102Str(price);
|
||||
|
||||
ui.btn_max_pay.SetClick(() => {
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)Math.Round(price * 100),
|
||||
sku = IAPPayManager.PRODUCT_PASS_BONUS,
|
||||
currency = "USD"
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
});
|
||||
}
|
||||
ui.gift_switch.selectedIndex = GameHelper.IsGiftSwitch() ? 1 : 0;
|
||||
InitView();
|
||||
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.master_pass_show);
|
||||
|
||||
var fileName = GameHelper.GetBackgroundName(3);
|
||||
TextureHelper.SetImgLoader(ui.loader.picture, fileName, null, "Background/", FolderNames.BackgroundName);
|
||||
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
}
|
||||
#endregion
|
||||
void pay_success(object str)
|
||||
{
|
||||
string type = (string)str;
|
||||
string purch_number = "";
|
||||
|
||||
if (type == IAPPayManager.PRODUCT_PASS_BONUS)
|
||||
{
|
||||
CtrlCloseUI();
|
||||
}
|
||||
// if (purch_number != "")
|
||||
// {
|
||||
// GameHelper.SendRevenueToAF(purch_number);
|
||||
// }
|
||||
}
|
||||
//初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
ui.btn_close.SetClick(CtrlCloseUI);
|
||||
int gold = 0;
|
||||
|
||||
List<Passportrewards> Passportrewards_list = ConfigSystem.GetConfig<Passportrewards>();
|
||||
for (int i = 0; i < Passportrewards_list.Count; i++)
|
||||
{
|
||||
|
||||
if (Passportrewards_list[i].Paid_rewards_type == 0) gold += Passportrewards_list[i].Paid_rewards_num;
|
||||
|
||||
}
|
||||
ui.text_allgold.text = GameHelper.Get101Str(gold);
|
||||
// ui.btn_buypass.GetChild("title").text = "$" + ConfigSystem.GetConfig<CommonModel>().Passportgift;
|
||||
|
||||
}
|
||||
|
||||
public void SetTextString()
|
||||
{
|
||||
var need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_PASS_BONUS);
|
||||
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
|
||||
|
||||
ui.tips.SetVar("num", need.ToString()).FlushVars();
|
||||
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,14 +60,14 @@ namespace RedHotRoast
|
||||
{
|
||||
uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
|
||||
uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
|
||||
uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
|
||||
}
|
||||
|
||||
@@ -102,30 +102,24 @@ namespace RedHotRoast
|
||||
bool is_maxPay = false; // 第三方支付
|
||||
string type = (string)str;
|
||||
string purch_number = "";
|
||||
if (type.Contains("buy_gold"))
|
||||
if (PurchasingManager.ShopProductMap.TryGetValue(type, out var shopIdx))
|
||||
{
|
||||
if (type.StartsWith("buy_gold"))
|
||||
int suffix_num = int.Parse(shopIdx);
|
||||
|
||||
purch_number = ConfigSystem.GetConfig<Paidcoins>()[suffix_num].Payment_amount2.ToString();
|
||||
|
||||
if (!UIManager.Instance.IsExistUI(UIConst.BuygoldUI))
|
||||
{
|
||||
int startIndex = "buy_gold".Length;
|
||||
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
int suffix_num = int.Parse(suffix);
|
||||
|
||||
purch_number = ConfigSystem.GetConfig<Paidcoins>()[suffix_num].Payment_amount2.ToString();
|
||||
|
||||
if (!UIManager.Instance.IsExistUI(UIConst.BuygoldUI))
|
||||
{
|
||||
List<Paidcoins> list = ConfigSystem.GetConfig<Paidcoins>();
|
||||
// GameHelper.AddGoldNumber(list[suffix_num].Actual_coins);
|
||||
int gold_num = list[suffix_num].Actual_coins;
|
||||
GetPayReward(gold_num);
|
||||
SaveData.GetSaveObject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
|
||||
SaveData.SaveDataFunc();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
}
|
||||
List<Paidcoins> list = ConfigSystem.GetConfig<Paidcoins>();
|
||||
// GameHelper.AddGoldNumber(list[suffix_num].Actual_coins);
|
||||
int gold_num = list[suffix_num].Actual_coins;
|
||||
GetPayReward(gold_num);
|
||||
SaveData.GetSaveObject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
|
||||
SaveData.SaveDataFunc();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
}
|
||||
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.battle_pass))
|
||||
else if (type == IAPPayManager.PRODUCT_PASS_BONUS)
|
||||
{
|
||||
SaveData.GetSaveObject().is_get_battlepass = true;
|
||||
int gold = 0;
|
||||
@@ -158,7 +152,7 @@ namespace RedHotRoast
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
}
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.buy_one))
|
||||
else if (type == IAPPayManager.PRODUCT_SPACE_BONUS)
|
||||
{
|
||||
SaveData.GetSaveObject().have_slot = true;
|
||||
SaveData.SaveDataFunc();
|
||||
@@ -167,7 +161,7 @@ namespace RedHotRoast
|
||||
|
||||
purch_number = GameHelper.GetCommonModel().addspace2.ToString();
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.remove_ad))
|
||||
else if (type == IAPPayManager.PRODUCT_REMOVE_ADS)
|
||||
{
|
||||
SaveData.GetSaveObject().remove_ad_time = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().RemoveADsPackDuration * 3600;
|
||||
SaveData.GetSaveObject().is_get_removead = true;
|
||||
@@ -179,7 +173,7 @@ namespace RedHotRoast
|
||||
GameHelper.ShowTips("purchase_succ", true);
|
||||
purch_number = ConfigSystem.GetConfig<Paidgift>()[1].Paid_price2.ToString();
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.pack_reward))
|
||||
else if (type == IAPPayManager.PRODUCT_FIRST_GIFT)
|
||||
{
|
||||
List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
|
||||
int gold_num = list[0].coins_quantity;
|
||||
@@ -199,40 +193,38 @@ namespace RedHotRoast
|
||||
GameHelper.ShowTips("purchase_succ", true);
|
||||
purch_number = ConfigSystem.GetConfig<Paidgift>()[0].Paid_price2.ToString();
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.fail_pack))
|
||||
{
|
||||
List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
|
||||
purch_number = ConfigSystem.GetConfig<Paidgift>()[2].Paid_price2.ToString();
|
||||
//ui?.setBtnAds();
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.resurgence);
|
||||
|
||||
// DataMgr.Coin.Value += ConfigSystem.GetConfig<PaidgiftModel>().DataList[1].coins_quantity;
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
int back_num = list[2].props_quantity[1];
|
||||
int out_num = list[2].props_quantity[0];
|
||||
int refresh_num = list[2].props_quantity[2];
|
||||
//GameHelper.addGoldNumber(gold_num);
|
||||
int gold_num = list[2].coins_quantity;
|
||||
if (!UIManager.Instance.IsExistUI(UIConst.ResurgenceUI)) DataMgr.Coin.Value += gold_num;
|
||||
GameHelper.AddItemNumber(0, out_num);
|
||||
GameHelper.AddItemNumber(1, back_num);
|
||||
GameHelper.AddItemNumber(2, refresh_num);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
|
||||
SaveData.SaveDataFunc();
|
||||
|
||||
}
|
||||
else if (type == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
{
|
||||
SaveData.GetSaveObject().is_get_ThreeDaysGift = true;
|
||||
SaveData.SaveDataFunc();
|
||||
purch_number = ConfigSystem.GetConfig<Multigift>()[0].Paid_price2.ToString();
|
||||
}
|
||||
else if (type.StartsWith("vip_club"))
|
||||
// else if (type == PurchasingManager.GetPaySku(PayType.fail_pack))
|
||||
// {
|
||||
// List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
|
||||
// purch_number = ConfigSystem.GetConfig<Paidgift>()[2].Paid_price2.ToString();
|
||||
// //ui?.setBtnAds();
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.resurgence);
|
||||
//
|
||||
// // DataMgr.Coin.Value += ConfigSystem.GetConfig<PaidgiftModel>().DataList[1].coins_quantity;
|
||||
// // GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
|
||||
// int back_num = list[2].props_quantity[1];
|
||||
// int out_num = list[2].props_quantity[0];
|
||||
// int refresh_num = list[2].props_quantity[2];
|
||||
// //GameHelper.addGoldNumber(gold_num);
|
||||
// int gold_num = list[2].coins_quantity;
|
||||
// if (!UIManager.Instance.IsExistUI(UIConst.ResurgenceUI)) DataMgr.Coin.Value += gold_num;
|
||||
// GameHelper.AddItemNumber(0, out_num);
|
||||
// GameHelper.AddItemNumber(1, back_num);
|
||||
// GameHelper.AddItemNumber(2, refresh_num);
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
|
||||
// SaveData.SaveDataFunc();
|
||||
//
|
||||
// }
|
||||
// else if (type == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
// {
|
||||
// SaveData.GetSaveObject().is_get_ThreeDaysGift = true;
|
||||
// SaveData.SaveDataFunc();
|
||||
// purch_number = ConfigSystem.GetConfig<Multigift>()[0].Paid_price2.ToString();
|
||||
// }
|
||||
else if (PurchasingManager.VipProductMap.TryGetValue(type, out var vipIdx))
|
||||
{
|
||||
is_maxPay = true;
|
||||
int startIndex = "vip_club".Length;
|
||||
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
int suffixNum = int.Parse(suffix);
|
||||
int suffixNum = int.Parse(vipIdx);
|
||||
|
||||
if (!MaxPayManager.isIOSPay)
|
||||
{
|
||||
@@ -287,16 +279,36 @@ namespace RedHotRoast
|
||||
// 付费上报BI
|
||||
BIManager.Instance.TrackPurchase(purch_number.As<double>(), "USD", payType.ToString(), type, "paid");
|
||||
|
||||
Debug.Log("付费收益上报AF----------- " + revenue);
|
||||
adCallbackInfo.Clear();
|
||||
adCallbackInfo.Add("appsflyer_id", AppsFlyer.getAppsFlyerId());
|
||||
adCallbackInfo.Add("customer_user_id", GameHelper.GetLoginModel().Uid.ToString());
|
||||
adCallbackInfo.Add("af_currency", "USD");
|
||||
adCallbackInfo.Add("af_revenue", revenue.ToString(CultureInfo.InvariantCulture));
|
||||
AppsFlyer.sendEvent("af_purchase", adCallbackInfo);
|
||||
// Debug.Log("付费收益上报AF----------- " + revenue);
|
||||
// adCallbackInfo.Clear();
|
||||
// adCallbackInfo.Add("appsflyer_id", AppsFlyer.getAppsFlyerId());
|
||||
// adCallbackInfo.Add("customer_user_id", GameHelper.GetLoginModel().Uid.ToString());
|
||||
// adCallbackInfo.Add("af_currency", "USD");
|
||||
// adCallbackInfo.Add("af_revenue", revenue.ToString(CultureInfo.InvariantCulture));
|
||||
// AppsFlyer.sendEvent("af_purchase", adCallbackInfo);
|
||||
|
||||
TrackKit.SendEvent(AfPurchaseTrack.Event, AfPurchaseTrack.Property.af_revenue, (int)(purch_number.As<decimal>() * 10000));
|
||||
|
||||
|
||||
|
||||
|
||||
var payData = new ApplePayData
|
||||
{
|
||||
sku = type,
|
||||
currency = "USD",
|
||||
amount = (int)(purch_number.As<decimal>() * 100),
|
||||
isCompleted = true
|
||||
};
|
||||
//上报给服务器,用来做数据分析
|
||||
PurchasingManager.ApplePayCreate<ApplePayData>(payData, (response) =>
|
||||
{
|
||||
Debug.Log($"[付费收益] Purchase-----type--{type}----{response.IsSuccess}");
|
||||
|
||||
if (response.IsSuccess)
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -307,9 +307,9 @@ namespace RedHotRoast
|
||||
{
|
||||
if (Screen.safeArea.y != 0)
|
||||
{
|
||||
ui.btn_gold.y += 68;
|
||||
ui.btn_close.y += 68;
|
||||
ui.sc_list.y += 68;
|
||||
ui.btn_gold.y += 58;
|
||||
ui.btn_close.y += 58;
|
||||
ui.sc_list.y += 38;
|
||||
}
|
||||
|
||||
var eventName = GameHelper.IsAdModelOfPay() ? ADEventTrack.Event : ADEventTrack.MaxPayEvent;
|
||||
|
||||
@@ -1,423 +1,423 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DG.Tweening;
|
||||
using FairyGUI;
|
||||
using FGUI.LG_secretAlbums;
|
||||
using SGModule.Common.Helper;
|
||||
using SGModule.NetKit;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class SecretAlbumsNextUI : BaseUI
|
||||
{
|
||||
private SecretAlbumsNextUICtrl ctrl;
|
||||
private SecretAlbumsNextModel model;
|
||||
private FGUI.LG_secretAlbums.com_scAlbumPreview ui;
|
||||
|
||||
public SecretAlbumsNextUI(SecretAlbumsNextUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.SecretAlbumsNextUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "LG_secretAlbums";
|
||||
uiInfo.assetName = "com_scAlbumPreview";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.SecretAlbumsModel) as SecretAlbumsModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
HallManager.Instance.UpdateSecondEvent -= UpWatchAdsBtn;
|
||||
|
||||
// 清理 Loader 的材质和贴图
|
||||
foreach (var loader in loader_list)
|
||||
{
|
||||
if (loader == null || loader.isDisposed) continue;
|
||||
|
||||
// 释放材质到材质池
|
||||
if (loader.material != null)
|
||||
{
|
||||
TextureHelper.CancelImageBlur(loader); // 自动返回材质池
|
||||
loader.material = null;
|
||||
}
|
||||
|
||||
// 清理 NTexture
|
||||
if (loader.texture != null)
|
||||
{
|
||||
if (loader.texture.destroyMethod == DestroyMethod.Destroy)
|
||||
loader.texture.Dispose(); // 销毁 NTexture 对象
|
||||
loader.texture = null;
|
||||
}
|
||||
}
|
||||
loader_list.Clear();
|
||||
|
||||
// 强制卸载未使用的资源
|
||||
Resources.UnloadUnusedAssets();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.LG_secretAlbums.com_scAlbumPreview;
|
||||
}
|
||||
|
||||
private AlbumPreviewData _albumPreviewData;
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
if (args == null) return;
|
||||
|
||||
_albumPreviewData = (AlbumPreviewData)args;
|
||||
|
||||
InitView();
|
||||
|
||||
var event_names = ADEventTrack.Property.secret_albums_show + (_albumPreviewData.Index + 1);
|
||||
|
||||
var event_type = _albumPreviewData.PayType == (int)UnlockPayType.Ad ? ADEventTrack.Event : ADEventTrack.MaxPayEvent;
|
||||
TrackKit.SendEvent(event_type, event_names);
|
||||
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, InitView);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, InitView);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
void pay_success(object str)
|
||||
{
|
||||
string type = (string)str;
|
||||
string purch_number = "";
|
||||
|
||||
if (type.StartsWith("secret_albnums"))
|
||||
{
|
||||
int startIndex = "secret_albnums".Length;
|
||||
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
int suffix_num = int.Parse(suffix);
|
||||
|
||||
Log.Info("Secret_pay_success", $"index================:{suffix_num}");
|
||||
// 判断是否已存在,避免重复添加
|
||||
if (!DataMgr.SecretUnlockList.Value.Contains(suffix_num))
|
||||
{
|
||||
DataMgr.SecretUnlockList.Value.Add(suffix_num);
|
||||
DataMgr.SecretUnlockList.Save();
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockSecretSuccess);
|
||||
}
|
||||
GameHelper.ShowTips("purchase_succ", true);
|
||||
InitView();
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> _secretData;
|
||||
|
||||
private bool is_unlock = false; //当前专辑是否解锁
|
||||
private List<GLoader> loader_list = new List<GLoader>();
|
||||
//初始化页面逻辑
|
||||
private void InitView(object a = null)
|
||||
{
|
||||
// 先清理上一次的 loader 和任务
|
||||
foreach (var l in loader_list)
|
||||
{
|
||||
if (l != null && !l.isDisposed)
|
||||
{
|
||||
TextureHelper.CancelImageBlur(l); // 放回材质池
|
||||
if (l.texture != null)
|
||||
{
|
||||
l.texture.Dispose();
|
||||
l.texture = null;
|
||||
}
|
||||
if (l.material != null) l.material = null;
|
||||
}
|
||||
}
|
||||
loader_list.Clear();
|
||||
_tasks.Clear();
|
||||
|
||||
|
||||
//专辑解锁状态
|
||||
is_unlock = DataMgr.SecretUnlockList.Value.Contains(_albumPreviewData.Index);
|
||||
|
||||
UpWatchAdsBtn();
|
||||
|
||||
HallManager.Instance.UpdateSecondEvent += UpWatchAdsBtn;
|
||||
|
||||
ui.btn_close.SetClick(CtrlCloseUI);
|
||||
|
||||
ui.old_price.text = GameHelper.getPrice((decimal)_albumPreviewData.Price);
|
||||
|
||||
ui.btn_pay.title = GameHelper.getPrice((decimal)_albumPreviewData.DiscountPrice);
|
||||
|
||||
|
||||
_secretData = SplitStringToList(_albumPreviewData.Name2);
|
||||
|
||||
|
||||
ui.list.itemRenderer = ItemRender;
|
||||
ui.list.numItems = _secretData.Count;
|
||||
|
||||
ui.pay_type.selectedIndex = !is_unlock ? _albumPreviewData.PayType : (int)UnlockPayType.None;
|
||||
if (is_unlock)
|
||||
{
|
||||
ui.pay_type.selectedIndex = (int)UnlockPayType.None;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_albumPreviewData.SubscribeUnlock == 1)
|
||||
{
|
||||
ui.vip.selectedIndex = 1;
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
ui.has_vip.selectedIndex = 1;
|
||||
ui.btn_vip.x = 540;
|
||||
// ui.btn_vip.y -= 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.has_vip.selectedIndex = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.vip.selectedIndex = 0;
|
||||
}
|
||||
ui.pay_type.selectedIndex = _albumPreviewData.PayType;
|
||||
}
|
||||
var _type = "secret_albnums" + _albumPreviewData.Index;
|
||||
ui.btn_pay.SetClick(() =>
|
||||
{
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)Math.Round(_albumPreviewData.DiscountPrice * 100),
|
||||
sku = _type,
|
||||
currency = "USD"
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
});
|
||||
ui.btn_gold.title = _albumPreviewData.GoldCoins.ToString();
|
||||
ui.btn_gold.SetClick(() =>
|
||||
{
|
||||
if (GameHelper.Get101() >= _albumPreviewData.GoldCoins)
|
||||
{
|
||||
GameHelper.AddGold(-_albumPreviewData.GoldCoins);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _type);
|
||||
|
||||
string eventName = ADEventTrack.Property.secret_albums_success_ + (_albumPreviewData.Index + 1);
|
||||
TrackKit.SendEvent(ADEventTrack.SecretAlbums, eventName);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Update101);
|
||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.unlock_secretAlbums_resources);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("no_enough_gold", true);
|
||||
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
var AdCount = DataMgr.SecretUnlockADs.Value.GetValueOrDefault(_albumPreviewData.Index, 0);
|
||||
ui.btn_watch.ads.SetVar("ads", AdCount + "/" + _albumPreviewData.AD).FlushVars();
|
||||
ui.btn_watch.SetClick(() =>
|
||||
{
|
||||
|
||||
if (AdCount >= _albumPreviewData.AD)
|
||||
{
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _type);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowVideoAd("UnlockSecretAlbums", (isSuccess) =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
var adTimes = Convert.ToInt32(GameHelper.GetNowTime());
|
||||
DataMgr.SecretUnlockCd.Value[_albumPreviewData.Index] = adTimes + _albumPreviewData.CD;
|
||||
DataMgr.SecretUnlockCd.Save();
|
||||
|
||||
var currentAdCount = DataMgr.SecretUnlockADs.Value.GetValueOrDefault(_albumPreviewData.Index, 0);
|
||||
DataMgr.SecretUnlockADs.Value[_albumPreviewData.Index] = currentAdCount + 1;
|
||||
DataMgr.SecretUnlockADs.Save();
|
||||
|
||||
string eventName = ADEventTrack.Property.secret_albums_success_ + (_albumPreviewData.Index + 1);
|
||||
TrackKit.SendEvent(ADEventTrack.Event, eventName);
|
||||
|
||||
InitView();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
ui.btn_vip.SetClick(() =>
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.SecretAlbums, ADEventTrack.Property.secret_albums_click_ + (_albumPreviewData.Index + 1));
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
GameHelper.isVipUnlock = true;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _type);
|
||||
|
||||
string eventName = ADEventTrack.Property.vip_secret_albums_unclock_ + (_albumPreviewData.Index + 1);
|
||||
TrackKit.SendEvent(ADEventTrack.VipSecretAlbums, eventName);
|
||||
}
|
||||
else
|
||||
{
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open, 2);
|
||||
TrackKit.SendEvent(ADEventTrack.VipSecretAlbums, ADEventTrack.Property.vip_secret_albums_unclock);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)> _tasks = new();
|
||||
|
||||
private void ItemRender(int index, GObject obj)
|
||||
{
|
||||
var item = (item_scAlbumPreview)obj;
|
||||
var picture = (GLoader)item.com_pic_in.GetChild("picture");
|
||||
|
||||
if (!loader_list.Contains(picture))
|
||||
loader_list.Add(picture);
|
||||
|
||||
var state = GetSafe(_albumPreviewData.State, index);
|
||||
item.state.selectedIndex = is_unlock ? 0 : state;
|
||||
|
||||
var task = (picture, _secretData[index], (Action<NTexture>)(s =>
|
||||
{
|
||||
if (picture != null && !picture.isDisposed)
|
||||
{
|
||||
if (!is_unlock && state == 1)
|
||||
TextureHelper.SetImageBlur(picture);
|
||||
else
|
||||
TextureHelper.CancelImageBlur(picture);
|
||||
}
|
||||
}), $"SecretAlbums/{_albumPreviewData.Name}/", FolderNames.SecretName);
|
||||
|
||||
_tasks.Add(task);
|
||||
|
||||
item.btn_detail.SetClick(() =>
|
||||
{
|
||||
if (is_unlock)
|
||||
{
|
||||
var data = new DetailData
|
||||
{
|
||||
Name = _secretData[index],
|
||||
Name1 = $"SecretAlbums/{_albumPreviewData.Name}/"
|
||||
};
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretDetailUI_Open, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("not_unlocked", true);
|
||||
}
|
||||
});
|
||||
|
||||
if (index == _secretData.Count - 1)
|
||||
{
|
||||
TextureHelper.SetImgLoaders(_tasks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void UpWatchAdsBtn()
|
||||
{
|
||||
DataMgr.SecretUnlockCd.Value.TryGetValue(_albumPreviewData.Index, out var lastTimes);
|
||||
|
||||
|
||||
if (DataMgr.SecretUnlockADs.Value.TryGetValue(_albumPreviewData.Index, out var unlockAdValue) &&
|
||||
unlockAdValue >= _albumPreviewData.AD)
|
||||
{
|
||||
ui.btn_watch.can_buy.selectedIndex = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_watch.can_buy.selectedIndex = 0;
|
||||
if (GameHelper.GetNowTime() < lastTimes)
|
||||
{
|
||||
ui.btn_watch.enabled = false;
|
||||
ui.btn_watch.CD.selectedIndex = 1;
|
||||
ui.btn_watch.watch_cd.text =
|
||||
CommonHelper.TimeFormat(lastTimes - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_watch.enabled = true;
|
||||
ui.btn_watch.CD.selectedIndex = 0;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 拆分字符串为列表
|
||||
public static List<string> SplitStringToList(string input)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(input))
|
||||
return new List<string>();
|
||||
|
||||
// 支持英文逗号, 中文逗号,空格
|
||||
char[] separators = new char[] { ',', ',', ' ' };
|
||||
|
||||
return input
|
||||
.Split(separators, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(s => s.Trim()) // 去掉前后空白
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 安全获取列表或数组中的元素,如果越界则返回最后一个元素;如果为空则返回默认值。
|
||||
/// </summary>
|
||||
public static T GetSafe<T>(IList<T> list, int index, T defaultValue = default)
|
||||
{
|
||||
if (list == null || list.Count == 0)
|
||||
return defaultValue;
|
||||
|
||||
if (index < 0)
|
||||
return list[0];
|
||||
|
||||
if (index >= list.Count)
|
||||
return list[list.Count - 1];
|
||||
|
||||
return list[index];
|
||||
}
|
||||
}
|
||||
|
||||
public class DetailData
|
||||
{
|
||||
public string Name;
|
||||
public string Name1;
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DG.Tweening;
|
||||
using FairyGUI;
|
||||
using FGUI.LG_secretAlbums;
|
||||
using SGModule.Common.Helper;
|
||||
using SGModule.NetKit;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class SecretAlbumsNextUI : BaseUI
|
||||
{
|
||||
private SecretAlbumsNextUICtrl ctrl;
|
||||
private SecretAlbumsNextModel model;
|
||||
private FGUI.LG_secretAlbums.com_scAlbumPreview ui;
|
||||
|
||||
public SecretAlbumsNextUI(SecretAlbumsNextUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.SecretAlbumsNextUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "LG_secretAlbums";
|
||||
uiInfo.assetName = "com_scAlbumPreview";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.SecretAlbumsModel) as SecretAlbumsModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
HallManager.Instance.UpdateSecondEvent -= UpWatchAdsBtn;
|
||||
|
||||
// 清理 Loader 的材质和贴图
|
||||
foreach (var loader in loader_list)
|
||||
{
|
||||
if (loader == null || loader.isDisposed) continue;
|
||||
|
||||
// 释放材质到材质池
|
||||
if (loader.material != null)
|
||||
{
|
||||
TextureHelper.CancelImageBlur(loader); // 自动返回材质池
|
||||
loader.material = null;
|
||||
}
|
||||
|
||||
// 清理 NTexture
|
||||
if (loader.texture != null)
|
||||
{
|
||||
if (loader.texture.destroyMethod == DestroyMethod.Destroy)
|
||||
loader.texture.Dispose(); // 销毁 NTexture 对象
|
||||
loader.texture = null;
|
||||
}
|
||||
}
|
||||
loader_list.Clear();
|
||||
|
||||
// 强制卸载未使用的资源
|
||||
Resources.UnloadUnusedAssets();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.LG_secretAlbums.com_scAlbumPreview;
|
||||
}
|
||||
|
||||
private AlbumPreviewData _albumPreviewData;
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
if (args == null) return;
|
||||
|
||||
_albumPreviewData = (AlbumPreviewData)args;
|
||||
|
||||
InitView();
|
||||
|
||||
var event_names = ADEventTrack.Property.secret_albums_show + (_albumPreviewData.Index + 1);
|
||||
|
||||
var event_type = _albumPreviewData.PayType == (int)UnlockPayType.Ad ? ADEventTrack.Event : ADEventTrack.MaxPayEvent;
|
||||
TrackKit.SendEvent(event_type, event_names);
|
||||
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, InitView);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, InitView);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
void pay_success(object str)
|
||||
{
|
||||
string type = (string)str;
|
||||
string purch_number = "";
|
||||
|
||||
if (type.StartsWith("secret_albnums"))
|
||||
{
|
||||
int startIndex = "secret_albnums".Length;
|
||||
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
int suffix_num = int.Parse(suffix);
|
||||
|
||||
Log.Info("Secret_pay_success", $"index================:{suffix_num}");
|
||||
// 判断是否已存在,避免重复添加
|
||||
if (!DataMgr.SecretUnlockList.Value.Contains(suffix_num))
|
||||
{
|
||||
DataMgr.SecretUnlockList.Value.Add(suffix_num);
|
||||
DataMgr.SecretUnlockList.Save();
|
||||
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.UnlockSecretSuccess);
|
||||
}
|
||||
GameHelper.ShowTips("purchase_succ", true);
|
||||
InitView();
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> _secretData;
|
||||
|
||||
private bool is_unlock = false; //当前专辑是否解锁
|
||||
private List<GLoader> loader_list = new List<GLoader>();
|
||||
//初始化页面逻辑
|
||||
private void InitView(object a = null)
|
||||
{
|
||||
// 先清理上一次的 loader 和任务
|
||||
foreach (var l in loader_list)
|
||||
{
|
||||
if (l != null && !l.isDisposed)
|
||||
{
|
||||
TextureHelper.CancelImageBlur(l); // 放回材质池
|
||||
if (l.texture != null)
|
||||
{
|
||||
l.texture.Dispose();
|
||||
l.texture = null;
|
||||
}
|
||||
if (l.material != null) l.material = null;
|
||||
}
|
||||
}
|
||||
loader_list.Clear();
|
||||
_tasks.Clear();
|
||||
|
||||
|
||||
//专辑解锁状态
|
||||
is_unlock = DataMgr.SecretUnlockList.Value.Contains(_albumPreviewData.Index);
|
||||
|
||||
UpWatchAdsBtn();
|
||||
|
||||
HallManager.Instance.UpdateSecondEvent += UpWatchAdsBtn;
|
||||
|
||||
ui.btn_close.SetClick(CtrlCloseUI);
|
||||
|
||||
ui.old_price.text = GameHelper.getPrice((decimal)_albumPreviewData.Price);
|
||||
|
||||
ui.btn_pay.title = GameHelper.getPrice((decimal)_albumPreviewData.DiscountPrice);
|
||||
|
||||
|
||||
_secretData = SplitStringToList(_albumPreviewData.Name2);
|
||||
|
||||
|
||||
ui.list.itemRenderer = ItemRender;
|
||||
ui.list.numItems = _secretData.Count;
|
||||
|
||||
ui.pay_type.selectedIndex = !is_unlock ? _albumPreviewData.PayType : (int)UnlockPayType.None;
|
||||
if (is_unlock)
|
||||
{
|
||||
ui.pay_type.selectedIndex = (int)UnlockPayType.None;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_albumPreviewData.SubscribeUnlock == 1)
|
||||
{
|
||||
ui.vip.selectedIndex = 1;
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
ui.has_vip.selectedIndex = 1;
|
||||
ui.btn_vip.x = 540;
|
||||
// ui.btn_vip.y -= 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.has_vip.selectedIndex = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.vip.selectedIndex = 0;
|
||||
}
|
||||
ui.pay_type.selectedIndex = _albumPreviewData.PayType;
|
||||
}
|
||||
var _type = "secret_albnums" + _albumPreviewData.Index;
|
||||
ui.btn_pay.SetClick(() =>
|
||||
{
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)Math.Round(_albumPreviewData.DiscountPrice * 100),
|
||||
sku = _type,
|
||||
currency = "USD"
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
});
|
||||
ui.btn_gold.title = _albumPreviewData.GoldCoins.ToString();
|
||||
ui.btn_gold.SetClick(() =>
|
||||
{
|
||||
if (GameHelper.Get101() >= _albumPreviewData.GoldCoins)
|
||||
{
|
||||
GameHelper.AddGold(-_albumPreviewData.GoldCoins);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, _type);
|
||||
|
||||
string eventName = ADEventTrack.Property.secret_albums_success_ + (_albumPreviewData.Index + 1);
|
||||
TrackKit.SendEvent(ADEventTrack.SecretAlbums, eventName);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.Update101);
|
||||
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.unlock_secretAlbums_resources);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("no_enough_gold", true);
|
||||
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
var AdCount = DataMgr.SecretUnlockADs.Value.GetValueOrDefault(_albumPreviewData.Index, 0);
|
||||
ui.btn_watch.ads.SetVar("ads", AdCount + "/" + _albumPreviewData.AD).FlushVars();
|
||||
ui.btn_watch.SetClick(() =>
|
||||
{
|
||||
|
||||
if (AdCount >= _albumPreviewData.AD)
|
||||
{
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, _type);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowVideoAd("UnlockSecretAlbums", (isSuccess) =>
|
||||
{
|
||||
if (isSuccess)
|
||||
{
|
||||
var adTimes = Convert.ToInt32(GameHelper.GetNowTime());
|
||||
DataMgr.SecretUnlockCd.Value[_albumPreviewData.Index] = adTimes + _albumPreviewData.CD;
|
||||
DataMgr.SecretUnlockCd.Save();
|
||||
|
||||
var currentAdCount = DataMgr.SecretUnlockADs.Value.GetValueOrDefault(_albumPreviewData.Index, 0);
|
||||
DataMgr.SecretUnlockADs.Value[_albumPreviewData.Index] = currentAdCount + 1;
|
||||
DataMgr.SecretUnlockADs.Save();
|
||||
|
||||
string eventName = ADEventTrack.Property.secret_albums_success_ + (_albumPreviewData.Index + 1);
|
||||
TrackKit.SendEvent(ADEventTrack.Event, eventName);
|
||||
|
||||
InitView();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
ui.btn_vip.SetClick(() =>
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.SecretAlbums, ADEventTrack.Property.secret_albums_click_ + (_albumPreviewData.Index + 1));
|
||||
if (GameHelper.GetVipLevel() > 0)
|
||||
{
|
||||
GameHelper.isVipUnlock = true;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, _type);
|
||||
|
||||
string eventName = ADEventTrack.Property.vip_secret_albums_unclock_ + (_albumPreviewData.Index + 1);
|
||||
TrackKit.SendEvent(ADEventTrack.VipSecretAlbums, eventName);
|
||||
}
|
||||
else
|
||||
{
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open, 2);
|
||||
TrackKit.SendEvent(ADEventTrack.VipSecretAlbums, ADEventTrack.Property.vip_secret_albums_unclock);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)> _tasks = new();
|
||||
|
||||
private void ItemRender(int index, GObject obj)
|
||||
{
|
||||
var item = (item_scAlbumPreview)obj;
|
||||
var picture = (GLoader)item.com_pic_in.GetChild("picture");
|
||||
|
||||
if (!loader_list.Contains(picture))
|
||||
loader_list.Add(picture);
|
||||
|
||||
var state = GetSafe(_albumPreviewData.State, index);
|
||||
item.state.selectedIndex = is_unlock ? 0 : state;
|
||||
|
||||
var task = (picture, _secretData[index], (Action<NTexture>)(s =>
|
||||
{
|
||||
if (picture != null && !picture.isDisposed)
|
||||
{
|
||||
if (!is_unlock && state == 1)
|
||||
TextureHelper.SetImageBlur(picture);
|
||||
else
|
||||
TextureHelper.CancelImageBlur(picture);
|
||||
}
|
||||
}), $"SecretAlbums/{_albumPreviewData.Name}/", FolderNames.SecretName);
|
||||
|
||||
_tasks.Add(task);
|
||||
|
||||
item.btn_detail.SetClick(() =>
|
||||
{
|
||||
if (is_unlock)
|
||||
{
|
||||
var data = new DetailData
|
||||
{
|
||||
Name = _secretData[index],
|
||||
Name1 = $"SecretAlbums/{_albumPreviewData.Name}/"
|
||||
};
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretDetailUI_Open, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameHelper.ShowTips("not_unlocked", true);
|
||||
}
|
||||
});
|
||||
|
||||
if (index == _secretData.Count - 1)
|
||||
{
|
||||
TextureHelper.SetImgLoaders(_tasks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void UpWatchAdsBtn()
|
||||
{
|
||||
DataMgr.SecretUnlockCd.Value.TryGetValue(_albumPreviewData.Index, out var lastTimes);
|
||||
|
||||
|
||||
if (DataMgr.SecretUnlockADs.Value.TryGetValue(_albumPreviewData.Index, out var unlockAdValue) &&
|
||||
unlockAdValue >= _albumPreviewData.AD)
|
||||
{
|
||||
ui.btn_watch.can_buy.selectedIndex = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_watch.can_buy.selectedIndex = 0;
|
||||
if (GameHelper.GetNowTime() < lastTimes)
|
||||
{
|
||||
ui.btn_watch.enabled = false;
|
||||
ui.btn_watch.CD.selectedIndex = 1;
|
||||
ui.btn_watch.watch_cd.text =
|
||||
CommonHelper.TimeFormat(lastTimes - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_watch.enabled = true;
|
||||
ui.btn_watch.CD.selectedIndex = 0;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 拆分字符串为列表
|
||||
public static List<string> SplitStringToList(string input)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(input))
|
||||
return new List<string>();
|
||||
|
||||
// 支持英文逗号, 中文逗号,空格
|
||||
char[] separators = new char[] { ',', ',', ' ' };
|
||||
|
||||
return input
|
||||
.Split(separators, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(s => s.Trim()) // 去掉前后空白
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 安全获取列表或数组中的元素,如果越界则返回最后一个元素;如果为空则返回默认值。
|
||||
/// </summary>
|
||||
public static T GetSafe<T>(IList<T> list, int index, T defaultValue = default)
|
||||
{
|
||||
if (list == null || list.Count == 0)
|
||||
return defaultValue;
|
||||
|
||||
if (index < 0)
|
||||
return list[0];
|
||||
|
||||
if (index >= list.Count)
|
||||
return list[list.Count - 1];
|
||||
|
||||
return list[index];
|
||||
}
|
||||
}
|
||||
|
||||
public class DetailData
|
||||
{
|
||||
public string Name;
|
||||
public string Name1;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,150 +1,150 @@
|
||||
|
||||
using FGUI.ZM_Common_01;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class SubUnlockUI : BaseUI
|
||||
{
|
||||
private SubUnlockUICtrl ctrl;
|
||||
private SubUnlockModel model;
|
||||
private FGUI.LG_Unlock.com_SubUnlock ui;
|
||||
|
||||
public SubUnlockUI(SubUnlockUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.SubUnlockUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "LG_Unlock";
|
||||
uiInfo.assetName = "com_SubUnlock";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.SubUnlockModel) as SubUnlockModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.LG_Unlock.com_SubUnlock;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
InitView();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, refrsh);
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, refrsh);
|
||||
}
|
||||
#endregion
|
||||
private void refrsh(object a = null)
|
||||
{
|
||||
GameHelper.ShowTips("unlock_vip", true);
|
||||
CtrlCloseUI();
|
||||
}
|
||||
|
||||
//初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
ui.btn_close.SetClick(() =>
|
||||
{
|
||||
CtrlCloseUI();
|
||||
});
|
||||
var vip_list = ConfigSystem.GetConfig<VipClub>();
|
||||
ui.text_unlockLive.SetVar("num", GameHelper.GetCommonModel().UnlockLive[1].ToString()).FlushVars();
|
||||
ui.text_unlockAlbum.SetVar("num", GameHelper.GetCommonModel().UnlockSecret[1].ToString()).FlushVars();
|
||||
ui.btn_vip0.text_price.text = GameHelper.getPrice((decimal)vip_list[0].DiscountPrice);
|
||||
ui.btn_vip1.text_price.text = GameHelper.getPrice((decimal)vip_list[1].DiscountPrice);
|
||||
ui.btn_vip2.text_price.text = GameHelper.getPrice((decimal)vip_list[2].DiscountPrice);
|
||||
|
||||
if (GameHelper.GetVipLevel() - 1 >= 0)
|
||||
{
|
||||
ui.btn_vip0.enabled = false;
|
||||
}
|
||||
|
||||
ui.btn_vip0.SetClick(() =>
|
||||
{
|
||||
string _type = "vip_club" + 0;
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)System.Math.Round(vip_list[0].DiscountPrice * 100),
|
||||
sku = PurchasingManager.GetPaySku(PayType.weekly_subscription),
|
||||
currency = "USD",
|
||||
shopName = _type
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
});
|
||||
|
||||
if (GameHelper.GetVipLevel() - 1 >= 1)
|
||||
{
|
||||
ui.btn_vip1.enabled = false;
|
||||
}
|
||||
|
||||
ui.btn_vip1.SetClick(() =>
|
||||
{
|
||||
string _type = "vip_club" + 1;
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)System.Math.Round(vip_list[1].DiscountPrice * 100),
|
||||
sku = PurchasingManager.GetPaySku(PayType.monthly_subscription),
|
||||
currency = "USD",
|
||||
shopName = _type
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
});
|
||||
|
||||
if (GameHelper.GetVipLevel() - 1 >= 2)
|
||||
{
|
||||
ui.btn_vip2.enabled = false;
|
||||
}
|
||||
|
||||
ui.btn_vip2.SetClick(() =>
|
||||
{
|
||||
string _type = "vip_club" + 2;
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)System.Math.Round(vip_list[2].DiscountPrice * 100),
|
||||
sku = PurchasingManager.GetPaySku(PayType.yearly_subscription),
|
||||
currency = "USD",
|
||||
shopName = _type
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
using FGUI.ZM_Common_01;
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class SubUnlockUI : BaseUI
|
||||
{
|
||||
private SubUnlockUICtrl ctrl;
|
||||
private SubUnlockModel model;
|
||||
private FGUI.LG_Unlock.com_SubUnlock ui;
|
||||
|
||||
public SubUnlockUI(SubUnlockUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.SubUnlockUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "LG_Unlock";
|
||||
uiInfo.assetName = "com_SubUnlock";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
//model = ModuleManager.Instance.GetModel(ModelConst.SubUnlockModel) as SubUnlockModel;
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.LG_Unlock.com_SubUnlock;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
InitView();
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, refrsh);
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, refrsh);
|
||||
}
|
||||
#endregion
|
||||
private void refrsh(object a = null)
|
||||
{
|
||||
GameHelper.ShowTips("unlock_vip", true);
|
||||
CtrlCloseUI();
|
||||
}
|
||||
|
||||
//初始化页面逻辑
|
||||
private void InitView()
|
||||
{
|
||||
ui.btn_close.SetClick(() =>
|
||||
{
|
||||
CtrlCloseUI();
|
||||
});
|
||||
var vip_list = ConfigSystem.GetConfig<VipClub>();
|
||||
ui.text_unlockLive.SetVar("num", GameHelper.GetCommonModel().UnlockLive[1].ToString()).FlushVars();
|
||||
ui.text_unlockAlbum.SetVar("num", GameHelper.GetCommonModel().UnlockSecret[1].ToString()).FlushVars();
|
||||
ui.btn_vip0.text_price.text = GameHelper.getPrice((decimal)vip_list[0].DiscountPrice);
|
||||
ui.btn_vip1.text_price.text = GameHelper.getPrice((decimal)vip_list[1].DiscountPrice);
|
||||
ui.btn_vip2.text_price.text = GameHelper.getPrice((decimal)vip_list[2].DiscountPrice);
|
||||
|
||||
if (GameHelper.GetVipLevel() - 1 >= 0)
|
||||
{
|
||||
ui.btn_vip0.enabled = false;
|
||||
}
|
||||
|
||||
ui.btn_vip0.SetClick(() =>
|
||||
{
|
||||
string _type = "vip_club" + 0;
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)System.Math.Round(vip_list[0].DiscountPrice * 100),
|
||||
sku = IAPPayManager.PRODUCT_VIP_WEEK,
|
||||
currency = "USD",
|
||||
shopName = _type
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
});
|
||||
|
||||
if (GameHelper.GetVipLevel() - 1 >= 1)
|
||||
{
|
||||
ui.btn_vip1.enabled = false;
|
||||
}
|
||||
|
||||
ui.btn_vip1.SetClick(() =>
|
||||
{
|
||||
string _type = "vip_club" + 1;
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)System.Math.Round(vip_list[1].DiscountPrice * 100),
|
||||
sku = IAPPayManager.PRODUCT_VIP_MONTH,
|
||||
currency = "USD",
|
||||
shopName = _type
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
});
|
||||
|
||||
if (GameHelper.GetVipLevel() - 1 >= 2)
|
||||
{
|
||||
ui.btn_vip2.enabled = false;
|
||||
}
|
||||
|
||||
ui.btn_vip2.SetClick(() =>
|
||||
{
|
||||
string _type = "vip_club" + 2;
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)System.Math.Round(vip_list[2].DiscountPrice * 100),
|
||||
sku = IAPPayManager.PRODUCT_VIP_YEAR,
|
||||
currency = "USD",
|
||||
shopName = _type
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,430 +1,430 @@
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
using FGUI.threeDaysGift;
|
||||
using Spine.Unity;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using SGModule.NetKit;
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class ThreeDaysGiftUI : BaseUI
|
||||
{
|
||||
private ThreeDaysGiftUICtrl ctrl;
|
||||
private ThreeDaysGiftModel model;
|
||||
private FGUI.threeDaysGift.com_three_days ui;
|
||||
|
||||
public ThreeDaysGiftUI(ThreeDaysGiftUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.ThreeDaysGiftUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "threeDaysGift";
|
||||
uiInfo.assetName = "com_three_days";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
HallManager.Instance.UpdateSecondEvent -= InitView;
|
||||
GameHelper.showGameUI = true;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.pack_close);
|
||||
GameHelper.CallShowTurn();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.threeDaysGift.com_three_days;
|
||||
}
|
||||
private Action closeCallback;
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
|
||||
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.three_days_gift_show);
|
||||
|
||||
list = ConfigSystem.GetConfig<Multigift>();
|
||||
|
||||
ui.btn_close.SetClick(() =>
|
||||
{
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.ThreeDaysGiftUIClose);
|
||||
CtrlCloseUI();
|
||||
});
|
||||
|
||||
ui.groups.visible = false;
|
||||
|
||||
var ske_bg = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_bg, Fx_Type.fx_three_gift, ref closeCallback);
|
||||
ske_bg.state.SetAnimation(0, "3_days", false);
|
||||
ske_bg.state.Complete += (a) =>
|
||||
{
|
||||
ske_bg.state.SetAnimation(0, "3_days_dj", false);
|
||||
};
|
||||
|
||||
DOVirtual.DelayedCall(0.5f, () =>
|
||||
{
|
||||
ui.groups.visible = true;
|
||||
});
|
||||
|
||||
|
||||
InitView();
|
||||
HallManager.Instance.UpdateSecondEvent += InitView;
|
||||
//
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.rewardMul_close, rewardMul_close);
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.rewardMul_close, rewardMul_close);
|
||||
}
|
||||
#endregion
|
||||
void pay_success(object str)
|
||||
{
|
||||
string type = (string)str;
|
||||
if (type == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
{
|
||||
|
||||
// var start = Vector2.zero;
|
||||
// if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day1) {
|
||||
// start = GameHelper.GetUICenterPosition(ui.day1.item1.lab_num);
|
||||
// } else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day2) {
|
||||
// start = GameHelper.GetUICenterPosition(ui.day2.item1.lab_num);
|
||||
// } else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day3) {
|
||||
// start = GameHelper.GetUICenterPosition(ui.day3.item1.lab_num);
|
||||
// }
|
||||
//
|
||||
// var rewardData = new RewardData();
|
||||
// var end = GameHelper.GetUICenterPosition(ui.node_end);
|
||||
//
|
||||
// var rewardSingleData = new RewardSingleData(101, list[1].coins_quantity, RewardOrigin.AdTask)
|
||||
// {
|
||||
// startPosition = start,
|
||||
// endPosition = end
|
||||
// };
|
||||
//
|
||||
// rewardData.AddReward(rewardSingleData);
|
||||
// rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
||||
// rewardData.AddCompleted(success =>
|
||||
// {
|
||||
// // if (success)
|
||||
// // {
|
||||
// // RefreshGold(awardNum);
|
||||
// // }
|
||||
// });
|
||||
//
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
||||
// // DataMgr.Coin.Value -= list[1].coins_quantity;
|
||||
//
|
||||
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AdcomingUI_Close);
|
||||
// SaveData.GetSaveObject().is_get_removead = true;
|
||||
// InitView();
|
||||
|
||||
ui.pay_type.selectedIndex = 2;
|
||||
}
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.noads_refresh);
|
||||
|
||||
}
|
||||
|
||||
void rewardMul_close(object str)
|
||||
{
|
||||
if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day1)
|
||||
{
|
||||
TrackKit.SendEvent(ThreeDaysGiftEventTrack.Event, ThreeDaysGiftEventTrack.Property.three_day1_success);
|
||||
}
|
||||
else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day2)
|
||||
{
|
||||
TrackKit.SendEvent(ThreeDaysGiftEventTrack.Event, ThreeDaysGiftEventTrack.Property.three_day2_success);
|
||||
}
|
||||
else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day3)
|
||||
{
|
||||
TrackKit.SendEvent(ThreeDaysGiftEventTrack.Event, ThreeDaysGiftEventTrack.Property.three_day3_success);
|
||||
}
|
||||
|
||||
SaveData.GetSaveObject().three_gift_got_index++;
|
||||
SaveData.GetSaveObject().last_got_three_gift_time = GameHelper.GetNowTime();
|
||||
|
||||
}
|
||||
|
||||
private List<Multigift> list;
|
||||
|
||||
// int adNums = AdExchangeManager.Instance.GetLookRewardADNum();
|
||||
// adNums++;
|
||||
// AdExchangeManager.Instance.SetLookRewardADNum(adNums);
|
||||
private void InitView()
|
||||
{
|
||||
ui.text_have.text = Language.GetContentParams("owner_ad", AdExchangeManager.Instance.GetLookRewardADNum());
|
||||
ui.need_text.text = Language.GetContentParams("need_ad", list[0].Paid_price);
|
||||
|
||||
|
||||
|
||||
initItem(0);
|
||||
initItem(1);
|
||||
initItem(2);
|
||||
|
||||
FGUI.threeDaysGift.btn_watchAd btn_buypack = (ui.btn_buypack as FGUI.threeDaysGift.btn_watchAd);
|
||||
GObject pack_title = ui.btn_buypack.GetChild("btn_text");
|
||||
|
||||
if (SaveData.GetSaveObject().is_get_ThreeDaysGift)
|
||||
{
|
||||
ui.pay_type.selectedIndex = 2;
|
||||
var isToday = GameHelper.InToday(SaveData.GetSaveObject().last_got_three_gift_time, 0, true);
|
||||
int three_gift_got_index = SaveData.GetSaveObject().three_gift_got_index;
|
||||
if (isToday || (three_gift_got_index > (int)rewardState.day3))
|
||||
{
|
||||
ui.btn_get.grayed = true;
|
||||
ui.btn_get.SetClick(() =>
|
||||
{
|
||||
if (three_gift_got_index < (int)rewardState.day3)
|
||||
{
|
||||
GameHelper.ShowTips("pick_tomorrow",true);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_get.SetClick(() =>
|
||||
{
|
||||
getReward();
|
||||
ui.btn_get.SetClick(() => { });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!GameHelper.IsAdModelOfPay())
|
||||
{
|
||||
ui.pay_type.selectedIndex = 1;
|
||||
decimal price_pack = (decimal)list[0].Paid_price2;
|
||||
ui.btn_max_pack.title = GameHelper.Get102Str(price_pack);
|
||||
bool is_get = SaveData.GetSaveObject().is_get_ThreeDaysGift;
|
||||
if (is_get)
|
||||
{
|
||||
ui.btn_max_pack.enabled = false;
|
||||
ui.btn_max_pack.SetClick(() => { });
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ui.btn_max_pack.SetClick(() =>
|
||||
{
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)Math.Round(price_pack * 100),
|
||||
sku =PurchasingManager.GetPaySku(PayType.three_days_gift),
|
||||
currency = "USD"
|
||||
};
|
||||
MaxPayManager.Instance.Buy(maxPayData);
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.pay_type.selectedIndex = 0;
|
||||
|
||||
bool is_get = SaveData.GetSaveObject().is_get_ThreeDaysGift;
|
||||
if (is_get)
|
||||
{
|
||||
btn_buypack.buy_state.selectedIndex = 0;
|
||||
btn_buypack.can_buy.selectedIndex = 1;
|
||||
ui.btn_buypack.grayed = true;
|
||||
pack_title.text = Language.GetContent("claimed");
|
||||
ui.btn_buypack.SetClick(() =>
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
else if (AdExchangeManager.Instance.GetLookRewardADNum() >= list[0].Paid_price)
|
||||
{
|
||||
btn_buypack.buy_state.selectedIndex = 1;
|
||||
btn_buypack.can_buy.selectedIndex = 0;
|
||||
btn_buypack.SetClick(() =>
|
||||
{
|
||||
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.three_days_gift_buy_success);
|
||||
// SaveData.GetSaveObject().look_ad_numbers
|
||||
int adNums = AdExchangeManager.Instance.GetLookRewardADNum();
|
||||
adNums -= (int)list[0].Paid_price;
|
||||
AdExchangeManager.Instance.SetLookRewardADNum(adNums);
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, PurchasingManager.GetPaySku(PayType.three_days_gift));
|
||||
|
||||
// getReward();
|
||||
ui.btn_buypack.SetClick(() => { });
|
||||
});
|
||||
}
|
||||
else if (SaveData.GetSaveObject()._watch_ad_cd > GameHelper.GetNowTime())
|
||||
{
|
||||
btn_buypack.buy_state.selectedIndex = 0;
|
||||
btn_buypack.can_buy.selectedIndex = 1;
|
||||
pack_title.text = CommonHelper.TimeFormat(SaveData.GetSaveObject()._watch_ad_cd - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
|
||||
btn_buypack.SetClick(() => { });
|
||||
}
|
||||
else
|
||||
{
|
||||
btn_buypack.buy_state.selectedIndex = 0;
|
||||
btn_buypack.can_buy.selectedIndex = 0;
|
||||
|
||||
pack_title.text = Language.GetContent("watch_ad");
|
||||
btn_buypack.SetClick(() =>
|
||||
{
|
||||
|
||||
GameHelper.ShowVideoAd("ThreeDaysGift", (issuccess) =>
|
||||
{
|
||||
if (issuccess)
|
||||
{
|
||||
SaveData.GetSaveObject()._watch_ad_cd = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().exchangeCD;
|
||||
InitView();
|
||||
}
|
||||
});
|
||||
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.three_days_gift_click);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initItem(int index)
|
||||
{
|
||||
com_item day = null;
|
||||
if (index == 0)
|
||||
{
|
||||
day = ui.day1;
|
||||
}
|
||||
else if (index == 1)
|
||||
{
|
||||
day = ui.day2;
|
||||
}
|
||||
else if (index == 2)
|
||||
{
|
||||
day = ui.day3;
|
||||
}
|
||||
|
||||
if (SaveData.GetSaveObject().three_gift_got_index - 1 > index)
|
||||
{
|
||||
day.img_select.visible = true;
|
||||
if (SaveData.GetSaveObject().three_gift_got_index - 1 > 2)
|
||||
{
|
||||
day.img_select2.visible = true;
|
||||
}
|
||||
}
|
||||
if (index == 2)
|
||||
{
|
||||
day.state.selectedIndex = 3;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
item_reward item = day.GetChild("item" + (i + 2)) as item_reward;
|
||||
item.visible = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
day.state.selectedIndex = list[index].props_quantity.Length;
|
||||
}
|
||||
|
||||
|
||||
setItemUrl(day.item1.loader_, GiftType.coin);
|
||||
day.item1.lab_num.text = "x" + list[index].coins_quantity;
|
||||
|
||||
for (int i = 0; i < list[index].props_quantity.Length; i++)
|
||||
{
|
||||
item_reward item = (day.GetChild("item" + (i + 2)) as item_reward);
|
||||
setItemUrl(item.loader_, (GiftType)list[index].props_type[i]);
|
||||
item.visible = true;
|
||||
item.lab_num.text = "x" + list[index].props_quantity[i];
|
||||
}
|
||||
}
|
||||
|
||||
private void setItemUrl(GLoader loader, GiftType urltype)
|
||||
{
|
||||
if (urltype == GiftType.coin) loader.url = "ui://threeDaysGift/3DAYS_prs_001";
|
||||
else if (urltype == GiftType.move_out) loader.url = "ui://threeDaysGift/3DAYS_prs_003";
|
||||
else if (urltype == GiftType.refresh) loader.url = "ui://threeDaysGift/3DAYS_prs_002";
|
||||
else if (urltype == GiftType.undo) loader.url = "ui://threeDaysGift/3DAYS_prs_004";
|
||||
}
|
||||
|
||||
private void getReward()
|
||||
{
|
||||
int index = SaveData.GetSaveObject().three_gift_got_index;
|
||||
|
||||
com_item item = null;
|
||||
if (index == (int)rewardState.day1)
|
||||
{
|
||||
item = ui.day1;
|
||||
}
|
||||
else if (index == (int)rewardState.day2)
|
||||
{
|
||||
item = ui.day2;
|
||||
}
|
||||
else if (index == (int)rewardState.day3)
|
||||
{
|
||||
item = ui.day3;
|
||||
}
|
||||
item.img_select.visible = true;
|
||||
|
||||
|
||||
List<int> types = new List<int>();
|
||||
List<int> rewards = new List<int>();
|
||||
types.Add((int)GiftType.coin);
|
||||
rewards.Add(list[index - 1].coins_quantity);
|
||||
for (int i = 0; i < list[index - 1].props_quantity.Length; i++)
|
||||
{
|
||||
types.Add(list[index - 1].props_type[i]); // GiftType 类型
|
||||
rewards.Add(list[index - 1].props_quantity[i]);
|
||||
}
|
||||
GiftData data = new GiftData();
|
||||
data.type = types;
|
||||
data.reward = rewards;
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.RewardMulNewUI_Open, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
enum rewardState
|
||||
{
|
||||
day1 = 1,
|
||||
day2,
|
||||
day3
|
||||
}
|
||||
public class GiftData
|
||||
{
|
||||
public List<int> type;
|
||||
public List<int> reward;
|
||||
public string uiName;
|
||||
}
|
||||
|
||||
public enum GiftType : int
|
||||
{
|
||||
coin = 101,
|
||||
move_out = 0,
|
||||
undo = 1,
|
||||
refresh = 2,
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
using FGUI.threeDaysGift;
|
||||
using Spine.Unity;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using SGModule.NetKit;
|
||||
|
||||
namespace RedHotRoast
|
||||
{
|
||||
public class ThreeDaysGiftUI : BaseUI
|
||||
{
|
||||
private ThreeDaysGiftUICtrl ctrl;
|
||||
private ThreeDaysGiftModel model;
|
||||
private FGUI.threeDaysGift.com_three_days ui;
|
||||
|
||||
public ThreeDaysGiftUI(ThreeDaysGiftUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.ThreeDaysGiftUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "threeDaysGift";
|
||||
uiInfo.assetName = "com_three_days";
|
||||
uiInfo.layerType = UILayerType.Popup;
|
||||
uiInfo.isNeedOpenAnim = false;
|
||||
uiInfo.isNeedCloseAnim = false;
|
||||
uiInfo.isNeedUIMask = true;
|
||||
}
|
||||
|
||||
#region 生命周期
|
||||
protected override void OnInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
HallManager.Instance.UpdateSecondEvent -= InitView;
|
||||
GameHelper.showGameUI = true;
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.pack_close);
|
||||
GameHelper.CallShowTurn();
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.threeDaysGift.com_three_days;
|
||||
}
|
||||
private Action closeCallback;
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
|
||||
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.three_days_gift_show);
|
||||
|
||||
list = ConfigSystem.GetConfig<Multigift>();
|
||||
|
||||
ui.btn_close.SetClick(() =>
|
||||
{
|
||||
GameDispatcher.Instance.Dispatch(GameMsg.ThreeDaysGiftUIClose);
|
||||
CtrlCloseUI();
|
||||
});
|
||||
|
||||
ui.groups.visible = false;
|
||||
|
||||
var ske_bg = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_bg, Fx_Type.fx_three_gift, ref closeCallback);
|
||||
ske_bg.state.SetAnimation(0, "3_days", false);
|
||||
ske_bg.state.Complete += (a) =>
|
||||
{
|
||||
ske_bg.state.SetAnimation(0, "3_days_dj", false);
|
||||
};
|
||||
|
||||
DOVirtual.DelayedCall(0.5f, () =>
|
||||
{
|
||||
ui.groups.visible = true;
|
||||
});
|
||||
|
||||
|
||||
InitView();
|
||||
HallManager.Instance.UpdateSecondEvent += InitView;
|
||||
//
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnHide()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnDisplay(object args)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 消息
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
// GameDispatcher.Instance.AddListener(GameMsg.rewardMul_close, rewardMul_close);
|
||||
}
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
// GameDispatcher.Instance.RemoveListener(GameMsg.rewardMul_close, rewardMul_close);
|
||||
}
|
||||
#endregion
|
||||
void pay_success(object str)
|
||||
{
|
||||
// string type = (string)str;
|
||||
// if (type == PurchasingManager.GetPaySku(PayType.three_days_gift))
|
||||
// {
|
||||
//
|
||||
// // var start = Vector2.zero;
|
||||
// // if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day1) {
|
||||
// // start = GameHelper.GetUICenterPosition(ui.day1.item1.lab_num);
|
||||
// // } else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day2) {
|
||||
// // start = GameHelper.GetUICenterPosition(ui.day2.item1.lab_num);
|
||||
// // } else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day3) {
|
||||
// // start = GameHelper.GetUICenterPosition(ui.day3.item1.lab_num);
|
||||
// // }
|
||||
// //
|
||||
// // var rewardData = new RewardData();
|
||||
// // var end = GameHelper.GetUICenterPosition(ui.node_end);
|
||||
// //
|
||||
// // var rewardSingleData = new RewardSingleData(101, list[1].coins_quantity, RewardOrigin.AdTask)
|
||||
// // {
|
||||
// // startPosition = start,
|
||||
// // endPosition = end
|
||||
// // };
|
||||
// //
|
||||
// // rewardData.AddReward(rewardSingleData);
|
||||
// // rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
|
||||
// // rewardData.AddCompleted(success =>
|
||||
// // {
|
||||
// // // if (success)
|
||||
// // // {
|
||||
// // // RefreshGold(awardNum);
|
||||
// // // }
|
||||
// // });
|
||||
// //
|
||||
// // GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
|
||||
// // // DataMgr.Coin.Value -= list[1].coins_quantity;
|
||||
// //
|
||||
// // UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AdcomingUI_Close);
|
||||
// // SaveData.GetSaveObject().is_get_removead = true;
|
||||
// // InitView();
|
||||
//
|
||||
// ui.pay_type.selectedIndex = 2;
|
||||
// }
|
||||
// // GameDispatcher.Instance.Dispatch(GameMsg.noads_refresh);
|
||||
//
|
||||
}
|
||||
|
||||
void rewardMul_close(object str)
|
||||
{
|
||||
if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day1)
|
||||
{
|
||||
TrackKit.SendEvent(ThreeDaysGiftEventTrack.Event, ThreeDaysGiftEventTrack.Property.three_day1_success);
|
||||
}
|
||||
else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day2)
|
||||
{
|
||||
TrackKit.SendEvent(ThreeDaysGiftEventTrack.Event, ThreeDaysGiftEventTrack.Property.three_day2_success);
|
||||
}
|
||||
else if (SaveData.GetSaveObject().three_gift_got_index == (int)rewardState.day3)
|
||||
{
|
||||
TrackKit.SendEvent(ThreeDaysGiftEventTrack.Event, ThreeDaysGiftEventTrack.Property.three_day3_success);
|
||||
}
|
||||
|
||||
SaveData.GetSaveObject().three_gift_got_index++;
|
||||
SaveData.GetSaveObject().last_got_three_gift_time = GameHelper.GetNowTime();
|
||||
|
||||
}
|
||||
|
||||
private List<Multigift> list;
|
||||
|
||||
// int adNums = AdExchangeManager.Instance.GetLookRewardADNum();
|
||||
// adNums++;
|
||||
// AdExchangeManager.Instance.SetLookRewardADNum(adNums);
|
||||
private void InitView()
|
||||
{
|
||||
ui.text_have.text = Language.GetContentParams("owner_ad", AdExchangeManager.Instance.GetLookRewardADNum());
|
||||
ui.need_text.text = Language.GetContentParams("need_ad", list[0].Paid_price);
|
||||
|
||||
|
||||
|
||||
initItem(0);
|
||||
initItem(1);
|
||||
initItem(2);
|
||||
|
||||
FGUI.threeDaysGift.btn_watchAd btn_buypack = (ui.btn_buypack as FGUI.threeDaysGift.btn_watchAd);
|
||||
GObject pack_title = ui.btn_buypack.GetChild("btn_text");
|
||||
|
||||
if (SaveData.GetSaveObject().is_get_ThreeDaysGift)
|
||||
{
|
||||
ui.pay_type.selectedIndex = 2;
|
||||
var isToday = GameHelper.InToday(SaveData.GetSaveObject().last_got_three_gift_time, 0, true);
|
||||
int three_gift_got_index = SaveData.GetSaveObject().three_gift_got_index;
|
||||
if (isToday || (three_gift_got_index > (int)rewardState.day3))
|
||||
{
|
||||
ui.btn_get.grayed = true;
|
||||
ui.btn_get.SetClick(() =>
|
||||
{
|
||||
if (three_gift_got_index < (int)rewardState.day3)
|
||||
{
|
||||
GameHelper.ShowTips("pick_tomorrow",true);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_get.SetClick(() =>
|
||||
{
|
||||
getReward();
|
||||
ui.btn_get.SetClick(() => { });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!GameHelper.IsAdModelOfPay())
|
||||
{
|
||||
ui.pay_type.selectedIndex = 1;
|
||||
decimal price_pack = (decimal)list[0].Paid_price2;
|
||||
ui.btn_max_pack.title = GameHelper.Get102Str(price_pack);
|
||||
bool is_get = SaveData.GetSaveObject().is_get_ThreeDaysGift;
|
||||
if (is_get)
|
||||
{
|
||||
ui.btn_max_pack.enabled = false;
|
||||
ui.btn_max_pack.SetClick(() => { });
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ui.btn_max_pack.SetClick(() =>
|
||||
{
|
||||
// ApplePayClass maxPayData = new ApplePayClass
|
||||
// {
|
||||
// amount = (int)Math.Round(price_pack * 100),
|
||||
// sku =PurchasingManager.GetPaySku(PayType.three_days_gift),
|
||||
// currency = "USD"
|
||||
// };
|
||||
// MaxPayManager.Instance.Buy(maxPayData);
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.pay_type.selectedIndex = 0;
|
||||
|
||||
bool is_get = SaveData.GetSaveObject().is_get_ThreeDaysGift;
|
||||
if (is_get)
|
||||
{
|
||||
btn_buypack.buy_state.selectedIndex = 0;
|
||||
btn_buypack.can_buy.selectedIndex = 1;
|
||||
ui.btn_buypack.grayed = true;
|
||||
pack_title.text = Language.GetContent("claimed");
|
||||
ui.btn_buypack.SetClick(() =>
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
else if (AdExchangeManager.Instance.GetLookRewardADNum() >= list[0].Paid_price)
|
||||
{
|
||||
btn_buypack.buy_state.selectedIndex = 1;
|
||||
btn_buypack.can_buy.selectedIndex = 0;
|
||||
btn_buypack.SetClick(() =>
|
||||
{
|
||||
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.three_days_gift_buy_success);
|
||||
// SaveData.GetSaveObject().look_ad_numbers
|
||||
int adNums = AdExchangeManager.Instance.GetLookRewardADNum();
|
||||
adNums -= (int)list[0].Paid_price;
|
||||
AdExchangeManager.Instance.SetLookRewardADNum(adNums);
|
||||
// GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, PurchasingManager.GetPaySku(PayType.three_days_gift));
|
||||
|
||||
// getReward();
|
||||
ui.btn_buypack.SetClick(() => { });
|
||||
});
|
||||
}
|
||||
else if (SaveData.GetSaveObject()._watch_ad_cd > GameHelper.GetNowTime())
|
||||
{
|
||||
btn_buypack.buy_state.selectedIndex = 0;
|
||||
btn_buypack.can_buy.selectedIndex = 1;
|
||||
pack_title.text = CommonHelper.TimeFormat(SaveData.GetSaveObject()._watch_ad_cd - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
|
||||
btn_buypack.SetClick(() => { });
|
||||
}
|
||||
else
|
||||
{
|
||||
btn_buypack.buy_state.selectedIndex = 0;
|
||||
btn_buypack.can_buy.selectedIndex = 0;
|
||||
|
||||
pack_title.text = Language.GetContent("watch_ad");
|
||||
btn_buypack.SetClick(() =>
|
||||
{
|
||||
|
||||
GameHelper.ShowVideoAd("ThreeDaysGift", (issuccess) =>
|
||||
{
|
||||
if (issuccess)
|
||||
{
|
||||
SaveData.GetSaveObject()._watch_ad_cd = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().exchangeCD;
|
||||
InitView();
|
||||
}
|
||||
});
|
||||
TrackKit.SendEvent(GameHelper.GetEventName(), ADEventTrack.Property.three_days_gift_click);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initItem(int index)
|
||||
{
|
||||
com_item day = null;
|
||||
if (index == 0)
|
||||
{
|
||||
day = ui.day1;
|
||||
}
|
||||
else if (index == 1)
|
||||
{
|
||||
day = ui.day2;
|
||||
}
|
||||
else if (index == 2)
|
||||
{
|
||||
day = ui.day3;
|
||||
}
|
||||
|
||||
if (SaveData.GetSaveObject().three_gift_got_index - 1 > index)
|
||||
{
|
||||
day.img_select.visible = true;
|
||||
if (SaveData.GetSaveObject().three_gift_got_index - 1 > 2)
|
||||
{
|
||||
day.img_select2.visible = true;
|
||||
}
|
||||
}
|
||||
if (index == 2)
|
||||
{
|
||||
day.state.selectedIndex = 3;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
item_reward item = day.GetChild("item" + (i + 2)) as item_reward;
|
||||
item.visible = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
day.state.selectedIndex = list[index].props_quantity.Length;
|
||||
}
|
||||
|
||||
|
||||
setItemUrl(day.item1.loader_, GiftType.coin);
|
||||
day.item1.lab_num.text = "x" + list[index].coins_quantity;
|
||||
|
||||
for (int i = 0; i < list[index].props_quantity.Length; i++)
|
||||
{
|
||||
item_reward item = (day.GetChild("item" + (i + 2)) as item_reward);
|
||||
setItemUrl(item.loader_, (GiftType)list[index].props_type[i]);
|
||||
item.visible = true;
|
||||
item.lab_num.text = "x" + list[index].props_quantity[i];
|
||||
}
|
||||
}
|
||||
|
||||
private void setItemUrl(GLoader loader, GiftType urltype)
|
||||
{
|
||||
if (urltype == GiftType.coin) loader.url = "ui://threeDaysGift/3DAYS_prs_001";
|
||||
else if (urltype == GiftType.move_out) loader.url = "ui://threeDaysGift/3DAYS_prs_003";
|
||||
else if (urltype == GiftType.refresh) loader.url = "ui://threeDaysGift/3DAYS_prs_002";
|
||||
else if (urltype == GiftType.undo) loader.url = "ui://threeDaysGift/3DAYS_prs_004";
|
||||
}
|
||||
|
||||
private void getReward()
|
||||
{
|
||||
int index = SaveData.GetSaveObject().three_gift_got_index;
|
||||
|
||||
com_item item = null;
|
||||
if (index == (int)rewardState.day1)
|
||||
{
|
||||
item = ui.day1;
|
||||
}
|
||||
else if (index == (int)rewardState.day2)
|
||||
{
|
||||
item = ui.day2;
|
||||
}
|
||||
else if (index == (int)rewardState.day3)
|
||||
{
|
||||
item = ui.day3;
|
||||
}
|
||||
item.img_select.visible = true;
|
||||
|
||||
|
||||
List<int> types = new List<int>();
|
||||
List<int> rewards = new List<int>();
|
||||
types.Add((int)GiftType.coin);
|
||||
rewards.Add(list[index - 1].coins_quantity);
|
||||
for (int i = 0; i < list[index - 1].props_quantity.Length; i++)
|
||||
{
|
||||
types.Add(list[index - 1].props_type[i]); // GiftType 类型
|
||||
rewards.Add(list[index - 1].props_quantity[i]);
|
||||
}
|
||||
GiftData data = new GiftData();
|
||||
data.type = types;
|
||||
data.reward = rewards;
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.RewardMulNewUI_Open, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
enum rewardState
|
||||
{
|
||||
day1 = 1,
|
||||
day2,
|
||||
day3
|
||||
}
|
||||
public class GiftData
|
||||
{
|
||||
public List<int> type;
|
||||
public List<int> reward;
|
||||
public string uiName;
|
||||
}
|
||||
|
||||
public enum GiftType : int
|
||||
{
|
||||
coin = 101,
|
||||
move_out = 0,
|
||||
undo = 1,
|
||||
refresh = 2,
|
||||
}
|
||||
|
||||
@@ -182,13 +182,13 @@ namespace RedHotRoast
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, InitView);
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
|
||||
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, InitView);
|
||||
}
|
||||
|
||||
@@ -221,6 +221,8 @@ namespace RedHotRoast
|
||||
ui.btn_restore.visible = !GameHelper.IsGiftSwitch();
|
||||
ui.btn_restore.SetClick(() =>
|
||||
{
|
||||
IAPPayManager.Instance.OnRestoreButtonClicked();
|
||||
|
||||
// ApplePayManager.Instance.AppleRestore((success, message) =>
|
||||
// {
|
||||
// Debug.Log($"[barry] restore success message: {message}---- {JsonConvert.SerializeObject(message)}");
|
||||
@@ -258,7 +260,7 @@ namespace RedHotRoast
|
||||
ApplePayClass maxPayData = new ApplePayClass
|
||||
{
|
||||
amount = (int)System.Math.Round(vip_list[_level].DiscountPrice * 100),
|
||||
sku = PurchasingManager.GetPaySku(GetTypeByIndex(_level)),
|
||||
sku = GetTypeByIndex(_level),
|
||||
currency = "USD",
|
||||
shopName = _type
|
||||
};
|
||||
@@ -278,14 +280,14 @@ namespace RedHotRoast
|
||||
ui.vip_icon_loader.url = $"ui://LG_Common/vip_{lv}";
|
||||
}
|
||||
|
||||
private PayType GetTypeByIndex(int index)
|
||||
private string GetTypeByIndex(int index)
|
||||
{
|
||||
return index switch
|
||||
{
|
||||
0 => PayType.weekly_subscription,
|
||||
1 => PayType.monthly_subscription,
|
||||
2 => PayType.yearly_subscription,
|
||||
_ => PayType.weekly_subscription
|
||||
0 => IAPPayManager.PRODUCT_VIP_WEEK,
|
||||
1 => IAPPayManager.PRODUCT_VIP_MONTH,
|
||||
2 => IAPPayManager.PRODUCT_VIP_YEAR,
|
||||
_ => IAPPayManager.PRODUCT_VIP_WEEK
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+176
-119
@@ -1,30 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
// using SGModule.ApplePay;
|
||||
using SGModule.NetKit;
|
||||
using UnityEngine;
|
||||
using RedHotRoast;
|
||||
// using UnityEngine.Purchasing;
|
||||
using Newtonsoft.Json;
|
||||
using SGModule.Net;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public enum PayType
|
||||
{
|
||||
buy_one,
|
||||
buy_one_off,
|
||||
buy_gold_1,
|
||||
buy_gold_2,
|
||||
buy_gold_3,
|
||||
buy_gold_4,
|
||||
buy_gold_5,
|
||||
remove_ad,
|
||||
battle_pass,
|
||||
pack_reward,
|
||||
fail_pack,
|
||||
three_days_gift,
|
||||
weekly_subscription,
|
||||
monthly_subscription,
|
||||
yearly_subscription,
|
||||
}
|
||||
// public enum PayType
|
||||
// {
|
||||
// buy_one,
|
||||
// buy_one_off,
|
||||
// buy_gold_1,
|
||||
// buy_gold_2,
|
||||
// buy_gold_3,
|
||||
// buy_gold_4,
|
||||
// buy_gold_5,
|
||||
// remove_ad,
|
||||
// battle_pass,
|
||||
// pack_reward,
|
||||
// fail_pack,
|
||||
// three_days_gift,
|
||||
// weekly_subscription,
|
||||
// monthly_subscription,
|
||||
// yearly_subscription,
|
||||
// }
|
||||
|
||||
public class PurchasingManager
|
||||
{
|
||||
@@ -32,42 +31,42 @@ public class PurchasingManager
|
||||
private static readonly List<ApplePay> PayConfig = ConfigSystem.GetConfig<ApplePay>();
|
||||
private static readonly List<ApplePay2> PayConfig2 = ConfigSystem.GetConfig<ApplePay2>();
|
||||
|
||||
public static string GetPaySku(PayType key)
|
||||
{
|
||||
string keys = "";
|
||||
|
||||
if (PayConfig != null)
|
||||
{
|
||||
foreach (var data in PayConfig)
|
||||
{
|
||||
if (data.payKey != key.ToString()) continue;
|
||||
keys = data.sku;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
public static int GetVipLvFormConfig(string sku)
|
||||
{
|
||||
var lv = 1;
|
||||
|
||||
if (GetPaySku(PayType.weekly_subscription) == sku)
|
||||
{
|
||||
lv = 1;
|
||||
}
|
||||
else if (GetPaySku(PayType.monthly_subscription) == sku)
|
||||
{
|
||||
lv = 2;
|
||||
}
|
||||
else if (GetPaySku(PayType.yearly_subscription) == sku)
|
||||
{
|
||||
lv = 3;
|
||||
}
|
||||
|
||||
return lv;
|
||||
}
|
||||
// public static string GetPaySku(PayType key)
|
||||
// {
|
||||
// string keys = "";
|
||||
//
|
||||
// if (PayConfig != null)
|
||||
// {
|
||||
// foreach (var data in PayConfig)
|
||||
// {
|
||||
// if (data.payKey != key.ToString()) continue;
|
||||
// keys = data.sku;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return keys;
|
||||
// }
|
||||
//
|
||||
// public static int GetVipLvFormConfig(string sku)
|
||||
// {
|
||||
// var lv = 1;
|
||||
//
|
||||
// if (GetPaySku(PayType.weekly_subscription) == sku)
|
||||
// {
|
||||
// lv = 1;
|
||||
// }
|
||||
// else if (GetPaySku(PayType.monthly_subscription) == sku)
|
||||
// {
|
||||
// lv = 2;
|
||||
// }
|
||||
// else if (GetPaySku(PayType.yearly_subscription) == sku)
|
||||
// {
|
||||
// lv = 3;
|
||||
// }
|
||||
//
|
||||
// return lv;
|
||||
// }
|
||||
|
||||
|
||||
public static void Purchase(ApplePayData payData)
|
||||
@@ -75,13 +74,28 @@ public class PurchasingManager
|
||||
//本地测试
|
||||
// TestIOSPay(payData);
|
||||
// return;
|
||||
|
||||
|
||||
|
||||
|
||||
Debug.Log($"[Apple Pay] unity Purchase--0-----: {payData.sku}");
|
||||
// ApplePayManager.Instance.Purchase(payData.sku, ApplePaySuccessCallback(payData), 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)
|
||||
@@ -112,7 +126,7 @@ public class PurchasingManager
|
||||
// var sku = SetSku(payData);
|
||||
//
|
||||
// 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}");
|
||||
//
|
||||
// SendEventClickByName(sku, "open");
|
||||
@@ -148,31 +162,69 @@ public class PurchasingManager
|
||||
// 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 = "";
|
||||
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;
|
||||
}
|
||||
{ IAPPayManager.PRODUCT_SHOP_1, "0" },
|
||||
{ IAPPayManager.PRODUCT_SHOP_2, "1" },
|
||||
{ IAPPayManager.PRODUCT_SHOP_3, "2" },
|
||||
{ IAPPayManager.PRODUCT_SHOP_4, "3" },
|
||||
{ IAPPayManager.PRODUCT_SHOP_5, "4" }
|
||||
};
|
||||
|
||||
// 订阅商品映射表
|
||||
public static readonly Dictionary<string, string> VipProductMap = new Dictionary<string, string>
|
||||
{
|
||||
{ IAPPayManager.PRODUCT_VIP_WEEK, "0" },
|
||||
{ IAPPayManager.PRODUCT_VIP_MONTH, "1" },
|
||||
{ IAPPayManager.PRODUCT_VIP_YEAR, "2" },
|
||||
};
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void SendEventClickByName(string name, string type)
|
||||
|
||||
public static void SendEventClickByName(string name, string type)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
@@ -183,64 +235,60 @@ public class PurchasingManager
|
||||
string successTrackKey = null;
|
||||
string openTrackKey = null;
|
||||
|
||||
if (name == GetPaySku(PayType.pack_reward))
|
||||
if (name == IAPPayManager.PRODUCT_FIRST_GIFT)
|
||||
{
|
||||
clickTrackKey = ADEventTrack.Property.lucky_gift_click;
|
||||
successTrackKey = ADEventTrack.Property.lucky_gift_receive;
|
||||
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;
|
||||
successTrackKey = ADEventTrack.Property.remove_ad_receive;
|
||||
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;
|
||||
successTrackKey = ADEventTrack.Property.master_pass_receive;
|
||||
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;
|
||||
successTrackKey = ADEventTrack.Property.buy_one_success;
|
||||
openTrackKey = ADEventTrack.Property.buy_one_show;
|
||||
}
|
||||
else if (name == GetPaySku(PayType.buy_one_off))
|
||||
{
|
||||
// clickTrackKey = ADEventTrack.Property.BuyOneOffClick;
|
||||
// successTrackKey = ADEventTrack.Property.BuyOneOffSuccess;
|
||||
// openTrackKey = ADEventTrack.Property.BuyOneOffShow;
|
||||
}
|
||||
else if (name == GetPaySku(PayType.fail_pack))
|
||||
{
|
||||
clickTrackKey = ADEventTrack.Property.fail_click;
|
||||
successTrackKey = ADEventTrack.Property.fail_buy_success;
|
||||
openTrackKey = ADEventTrack.Property.fail_show;
|
||||
}
|
||||
else if (name == GetPaySku(PayType.three_days_gift))
|
||||
{
|
||||
clickTrackKey = ADEventTrack.Property.three_days_gift_click;
|
||||
successTrackKey = ADEventTrack.Property.three_days_gift_buy_success;
|
||||
openTrackKey = ADEventTrack.Property.three_days_gift_show;
|
||||
}
|
||||
// else if (name == GetPaySku(PayType.buy_one_off))
|
||||
// {
|
||||
// // clickTrackKey = ADEventTrack.Property.BuyOneOffClick;
|
||||
// // successTrackKey = ADEventTrack.Property.BuyOneOffSuccess;
|
||||
// // openTrackKey = ADEventTrack.Property.BuyOneOffShow;
|
||||
// }
|
||||
// else if (name == GetPaySku(PayType.fail_pack))
|
||||
// {
|
||||
// clickTrackKey = ADEventTrack.Property.fail_click;
|
||||
// successTrackKey = ADEventTrack.Property.fail_buy_success;
|
||||
// openTrackKey = ADEventTrack.Property.fail_show;
|
||||
// }
|
||||
// else if (name == GetPaySku(PayType.three_days_gift))
|
||||
// {
|
||||
// clickTrackKey = ADEventTrack.Property.three_days_gift_click;
|
||||
// successTrackKey = ADEventTrack.Property.three_days_gift_buy_success;
|
||||
// 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;
|
||||
string suffix = name[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
clickTrackKey = ADEventTrack.Property.gold_click_ + suffix;
|
||||
successTrackKey = ADEventTrack.Property.shop_receive_ + suffix;
|
||||
clickTrackKey = ADEventTrack.Property.gold_click_ + idx;
|
||||
successTrackKey = ADEventTrack.Property.shop_receive_ + idx;
|
||||
openTrackKey = ADEventTrack.Property.shop_show;
|
||||
}
|
||||
|
||||
if (name.StartsWith("vip_club"))
|
||||
else if (VipProductMap.TryGetValue(name, out var vipIdx))
|
||||
{
|
||||
int startIndex = "vip_club".Length;
|
||||
string suffix = name[startIndex..]; // 截取 "gold" 后的所有字符
|
||||
clickTrackKey = ADEventTrack.Property.vip_click_ + suffix;
|
||||
successTrackKey = ADEventTrack.Property.vip_success_ + suffix;
|
||||
clickTrackKey = ADEventTrack.Property.vip_click_ + vipIdx;
|
||||
successTrackKey = ADEventTrack.Property.vip_success_ + vipIdx;
|
||||
openTrackKey = ADEventTrack.Property.buy_one_show;
|
||||
}
|
||||
|
||||
@@ -254,13 +302,20 @@ public class PurchasingManager
|
||||
}
|
||||
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
|
||||
{
|
||||
@@ -276,6 +331,8 @@ public class ApplePayData
|
||||
public string shopName;
|
||||
[JsonProperty("type")]
|
||||
public string type;
|
||||
[JsonProperty("isCompleted")]
|
||||
public bool isCompleted;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace RedHotRoast {
|
||||
b = GetCommonConf().IsOrganic == 1;
|
||||
}
|
||||
|
||||
Debug.Log($"下载---------开关:{b}");
|
||||
// Debug.Log($"下载---------开关:{b}");
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
+36
-9
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user