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

This commit is contained in:
2026-05-09 09:37:34 +08:00
parent 1599bf4bbb
commit ee55c03120
1011 changed files with 167108 additions and 33552 deletions
+442 -442
View File
@@ -1,443 +1,443 @@
using System;
using System.Collections.Generic;
using DG.Tweening;
using FGUI.ZM_Common_01;
using UnityEngine;
using FairyGUI;
using IgnoreOPS;
using Newtonsoft.Json;
using SGModule.Common.Helper;
using SGModule.NetKit;
using BallKingdomCrush;
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.AD_Event,
// ClickProperty = _ => ADEventTrack.Property.lucky_gift_click,
// SuccessProperty = _ => ADEventTrack.Property.lucky_gift_receive
// },
// [remove_ad] = new EventTrackMapping {
// EventKey = ADEventTrack.AD_Event,
// ClickProperty = _ => ADEventTrack.Property.remove_ad_click,
// SuccessProperty = _ => ADEventTrack.Property.remove_ad_receive
// },
// [battle_pass] = new EventTrackMapping {
// EventKey = ADEventTrack.AD_Event,
// ClickProperty = _ => ADEventTrack.Property.master_pass_click,
// SuccessProperty = _ => ADEventTrack.Property.master_pass_receive
// },
// [buy_one] = new EventTrackMapping {
// EventKey = ADEventTrack.AD_Event,
// ClickProperty = _ => ADEventTrack.Property.buy_one_click,
// SuccessProperty = _ => ADEventTrack.Property.buy_one_success
// },
// ["buy_gold"] = new EventTrackMapping {
// EventKey = ADEventTrack.AD_Event,
// ClickProperty = suffix => ADEventTrack.Property.shop_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);
string name = _data.type.Contains("shop") ? _data.shopName : _data.type;
SendEventClickByName(_data.type, "success");
DOVirtual.DelayedCall(0.1f, () =>
{
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, name);
});
}
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;
int cd = lastTimes - Convert.ToInt32(GameHelper.GetNowTime());
if (cd > 24 * 3600)
{
item.Value.btn_text.text = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
}
else
{
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<Paidcoins> coinList = ConfigSystem.GetConfig<Paidcoins>();
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 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.shop_click_ + suffix;
eventSuccName = ADEventTrack.Property.shop_receive_ + suffix;
}
if (type == "success" && eventSuccName != "")
{
TrackKit.SendEvent(ADEventTrack.AD_Event, eventSuccName);
}
else if (type == "click" && eventClickName != "")
{
TrackKit.SendEvent(ADEventTrack.AD_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 DG.Tweening;
using FGUI.ZM_Common_01;
using UnityEngine;
using FairyGUI;
using IgnoreOPS;
using Newtonsoft.Json;
using SGModule.Common.Helper;
using SGModule.NetKit;
using BallKingdomCrush;
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.AD_Event,
// ClickProperty = _ => ADEventTrack.Property.lucky_gift_click,
// SuccessProperty = _ => ADEventTrack.Property.lucky_gift_receive
// },
// [remove_ad] = new EventTrackMapping {
// EventKey = ADEventTrack.AD_Event,
// ClickProperty = _ => ADEventTrack.Property.remove_ad_click,
// SuccessProperty = _ => ADEventTrack.Property.remove_ad_receive
// },
// [battle_pass] = new EventTrackMapping {
// EventKey = ADEventTrack.AD_Event,
// ClickProperty = _ => ADEventTrack.Property.master_pass_click,
// SuccessProperty = _ => ADEventTrack.Property.master_pass_receive
// },
// [buy_one] = new EventTrackMapping {
// EventKey = ADEventTrack.AD_Event,
// ClickProperty = _ => ADEventTrack.Property.buy_one_click,
// SuccessProperty = _ => ADEventTrack.Property.buy_one_success
// },
// ["buy_gold"] = new EventTrackMapping {
// EventKey = ADEventTrack.AD_Event,
// ClickProperty = suffix => ADEventTrack.Property.shop_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);
string name = _data.type.Contains("shop") ? _data.shopName : _data.type;
SendEventClickByName(_data.type, "success");
DOVirtual.DelayedCall(0.1f, () =>
{
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, name);
});
}
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;
int cd = lastTimes - Convert.ToInt32(GameHelper.GetNowTime());
if (cd > 24 * 3600)
{
item.Value.btn_text.text = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
}
else
{
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<Paidcoins> coinList = ConfigSystem.GetConfig<Paidcoins>();
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 == IAPPayManager.PRODUCT_THREE_DAY)
{
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 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 == IAPPayManager.PRODUCT_THREE_DAY)
{
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.shop_click_ + suffix;
eventSuccName = ADEventTrack.Property.shop_receive_ + suffix;
}
if (type == "success" && eventSuccName != "")
{
TrackKit.SendEvent(ADEventTrack.AD_Event, eventSuccName);
}
else if (type == "click" && eventClickName != "")
{
TrackKit.SendEvent(ADEventTrack.AD_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;
}
+61 -61
View File
@@ -1,61 +1,61 @@
using System.Collections;
using UnityEngine;
using AppsFlyerSDK;
using System.Collections.Generic;
using System;
using BallKingdomCrush;
using DG.Tweening;
using SGModule.NetKit;
namespace DontConfuse
{
internal class AppsFlyerObjectScript1 : MonoBehaviour, IAppsFlyerConversionData
{
void Start()
{
AppsFlyer.initSDK("h8pivQvBQbZtoxhkSY7BJ6", null, this);
AppsFlyer.startSDK();
#if UNITY_EDITOR
NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
#endif
}
void Update()
{
}
// Mark AppsFlyer CallBacks
public void onConversionDataSuccess(string conversionData)
{
AppsFlyer.AFLog("didReceiveConversionData", conversionData);
Dictionary<string, object> conversionDataDictionary = AppsFlyer.CallbackStringToDictionary(conversionData);
// add deferred deeplink logic here
SuperApplication.Instance.attribution =
conversionDataDictionary.GetValueOrDefault("af_status")?.ToString();
NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
}
public void onConversionDataFail(string error)
{
AppsFlyer.AFLog("didReceiveConversionDataWithError", error);
NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
}
public void onAppOpenAttribution(string attributionData)
{
AppsFlyer.AFLog("onAppOpenAttribution", attributionData);
Dictionary<string, object> attributionDataDictionary = AppsFlyer.CallbackStringToDictionary(attributionData);
// add direct deeplink logic here
}
public void onAppOpenAttributionFailure(string error)
{
AppsFlyer.AFLog("onAppOpenAttributionFailure", error);
}
}
}
// using System.Collections;
// using UnityEngine;
// using AppsFlyerSDK;
// using System.Collections.Generic;
// using System;
// using BallKingdomCrush;
// using DG.Tweening;
// using SGModule.NetKit;
//
// namespace DontConfuse
// {
//
//
// internal class AppsFlyerObjectScript1 : MonoBehaviour, IAppsFlyerConversionData
// {
// void Start()
// {
// AppsFlyer.initSDK("h8pivQvBQbZtoxhkSY7BJ6", null, this);
// AppsFlyer.startSDK();
//
// #if UNITY_EDITOR
// NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
// #endif
// }
// void Update()
// {
//
// }
//
// // Mark AppsFlyer CallBacks
// public void onConversionDataSuccess(string conversionData)
// {
// AppsFlyer.AFLog("didReceiveConversionData", conversionData);
// Dictionary<string, object> conversionDataDictionary = AppsFlyer.CallbackStringToDictionary(conversionData);
// // add deferred deeplink logic here
// SuperApplication.Instance.attribution =
// conversionDataDictionary.GetValueOrDefault("af_status")?.ToString();
//
// NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
// }
//
// public void onConversionDataFail(string error)
// {
// AppsFlyer.AFLog("didReceiveConversionDataWithError", error);
//
// NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
// }
//
// public void onAppOpenAttribution(string attributionData)
// {
// AppsFlyer.AFLog("onAppOpenAttribution", attributionData);
// Dictionary<string, object> attributionDataDictionary = AppsFlyer.CallbackStringToDictionary(attributionData);
// // add direct deeplink logic here
// }
//
// public void onAppOpenAttributionFailure(string error)
// {
// AppsFlyer.AFLog("onAppOpenAttributionFailure", error);
// }
// }
// }
+280 -280
View File
@@ -1,280 +1,280 @@
using System;
using System.Collections.Generic;
using System.Linq;
using IgnoreOPS;
using Spine.Unity;
using BallKingdomCrush;
using UnityEngine;
public class CreatAnimalCard : MonoBehaviour
{
private GameObject card_item;
public static CreatAnimalCard instance;
private List<Sprite> img_list;
public Camera orthoCamera; // 这个变量应该被设置为您想要调整大小的正交相机
private void Awake()
{
instance = this;
card_item = Resources.Load<GameObject>("card/card_item/card_");
img_list = new List<Sprite>();
// img_list = Resources.LoadAll<Sprite>("card/card_sprite").ToList();
// img_list.Sort((x, y) => String.Compare(x.name, y.name));
for (int i = 0; i < 16; i++)
{
img_list.Add(Resources.Load<Sprite>("card/card_sprite/" + i));
}
orthoCamera = GameObject.Find("GameCamera").GetComponent<Camera>();
float size = (float)Math.Round(28.125f / ((float)Screen.width / Screen.height), 4);
string type = SystemInfo.deviceModel.ToLower().Trim();
// Debug.Log($"type==========={type}");
if (type.Substring(0, 3) == "ipa")
{//iPad机型
size = 49.9f;
}
orthoCamera.orthographicSize = size;
}
public void SetCameraVisible(bool visible)
{
orthoCamera.SetActive(visible);
GameHelper.ShowSheepPlayUI(visible);
}
// Start is called before the first frame update
public List<List<Card_item>> card_item_list = new List<List<Card_item>>();
public List<List<Card_item>> CreatCardNew(int all_card_numbers, int card_type_max, int card_layer, int extra_max, List<List<Vector2>> map_list, List<Vector2> left_extra_list,
List<Vector2> right_extra_list)
{
//all_card_numbers *= 3;
int money_rate = ConfigSystem.GetCommonConf().rewardrate;
List<int> type_list = new List<int>();
List<int> this_timetype_list = new List<int>();
// Debug.Log(card_layer);
card_item_list.Clear();
// ---------- 新增:先从0~15中挑选 card_type_max 个不同的类型 ----------
List<int> allTypes = Enumerable.Range(0, 15).ToList(); // [0,1,2,...,15]
List<int> chosenTypes = new List<int>();
for (int i = 0; i < card_type_max; i++)
{
int idx = UnityEngine.Random.Range(0, allTypes.Count);
chosenTypes.Add(allTypes[idx]);
allTypes.RemoveAt(idx); // 确保不重复
}
// ---------------------------------------------------------------
// 打印选出来的类型池
Debug.Log($"[CreatCardNew] 随机选出的 {card_type_max} 个类型: {string.Join(",", chosenTypes)}");
for (int i = 0; i < all_card_numbers; i++)
{
int type = 0;
var randomNum = UnityEngine.Random.Range(0, 100);
// Debug.Log($"[creat] money_rate------------ {randomNum}==={money_rate}");
if (GameHelper.IsGiftSwitch() && randomNum < money_rate)
{
type = 15; // 金币
}
else
{
// 在挑选好的类型池里再随机
type = chosenTypes[UnityEngine.Random.Range(0, chosenTypes.Count)];
}
// if (GameHelper.IsGiftSwitch() && type == 15)
// {
// type = UnityEngine.Random.Range(0, card_type_max - 1);
// }
#if UNITY_EDITOR
type = 1;
#endif
Debug.Log($"[CreatCardNew] 随机选出的 类型: {type}");
type_list.Add(type);
type_list.Add(type);
type_list.Add(type);
if (!this_timetype_list.Contains(type)) this_timetype_list.Add(type);
}
SaveData.GetSaveObject().this_time_cardtype = this_timetype_list.Count;
for (int i = 0; i < card_layer; i++)
{
card_item_list.Add(new List<Card_item>());
}
if (left_extra_list.Count > 0 || right_extra_list.Count > 0)
{
for (int i = 0; i < left_extra_list.Count; i++)
{
Card_item _tempObject = new()
{
pos_x = left_extra_list[i].x,
pos_y = left_extra_list[i].y,
_layer = i
};
card_item_list[i].Add(_tempObject);
}
for (int i = 0; i < right_extra_list.Count; i++)
{
Card_item _tempObject1 = new()
{
pos_x = right_extra_list[i].x,
pos_y = right_extra_list[i].y,
_layer = i
};
card_item_list[i].Add(_tempObject1);
}
}
var nums = 0;
for (int i = 0; i < map_list.Count; i++)
{
nums += map_list[i].Count;
}
for (int i = 0; i < nums; i++)
{
Card_item _tempObject = new();
int layer = getMaplayer(map_list);//确定层数
int pos = UnityEngine.Random.Range(0, map_list[layer].Count);
_tempObject.pos_x = map_list[layer][pos].x;
_tempObject.pos_y = map_list[layer][pos].y;
_tempObject._layer = layer;
card_item_list[layer].Add(_tempObject);
map_list[layer].RemoveAt(pos);
}
for (int i = 0; i < card_item_list.Count; i++)
{
card_item_list[i].Sort((x, y) => y.pos_y.CompareTo(x.pos_y));
}
int index = 0;
for (int i = 0; i < card_item_list.Count; i++)
{
float z_offset = 0;//用来微调每层之间的z值,让下层盖住上层
float last_posy = 0;
for (int j = 0; j < card_item_list[i].Count; j++)
{
if (last_posy != card_item_list[i][j].pos_y)
{
z_offset += 0.05f;
last_posy = card_item_list[i][j].pos_y;
}
GameObject temp = Instantiate(card_item, new Vector3(card_item_list[i][j].pos_x, card_item_list[i][j].pos_y, 400 - card_item_list[i][j]._layer - z_offset), Quaternion.identity, gameObject.transform);
index = UnityEngine.Random.Range(0, type_list.Count);
temp.GetComponent<SpriteRenderer>().sprite = img_list[type_list[index]];
card_item_list[i][j].sheep_card = temp;
card_item_list[i][j].card_type = type_list[index];
temp.gameObject.name = i + "-" + j;
type_list.RemoveAt(index);
}
}
return card_item_list;
}
public void creatSaveCard(List<List<Card_item>> card_item_list)
{
this.card_item_list = card_item_list;
for (int i = 0; i < card_item_list.Count; i++)
{
for (int j = 0; j < card_item_list[i].Count; j++)
{
GameObject temp;
// if (card_item_list[i][j].is_out)
// {
// temp = Instantiate(card_item, new Vector3(card_item_list[i][j].pos_x, card_item_list[i][j].pos_y, 400 - card_item_list[i][j].out_layer), Quaternion.identity, gameObject.transform);
// }
// else
temp = Instantiate(card_item, new Vector3(card_item_list[i][j].pos_x, card_item_list[i][j].pos_y, 400 - card_item_list[i][j]._layer), Quaternion.identity, gameObject.transform);
temp.GetComponent<SpriteRenderer>().sprite = img_list[card_item_list[i][j].card_type];
card_item_list[i][j].sheep_card = temp;
if (card_item_list[i][j].in_slot || card_item_list[i][j].is_out) temp.transform.localScale = new Vector3(4.628f, 4.628f, 1);
temp.gameObject.name = i + "-" + j;
}
}
}
private GameObject Popup;
void Update()
{
if (Input.GetMouseButtonDown(0))
{
if (Popup == null) Popup = GameObject.Find("Popup");
if (Popup.transform.childCount != 0) return;
Ray ray = orthoCamera.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
int layerMask = 1 << 6; // 只与第8层的碰撞器碰撞
// 如果射线与layerMask指定层的碰撞器发生碰撞
if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
{
// Debug.Log("Hit " + hit.collider.gameObject.name);
GameDispatcher.Instance.Dispatch(GameMsg.card_click, hit.collider.gameObject.name);
// 在此处添加点击物体后的逻辑
}
else
{
// Debug.Log("No hit");
}
}
}
private GameObject disappear01;
private GameObject disappear02;
public void creatSpine(int type, Vector3 vec3)
{
if (disappear01 == null) disappear01 = Resources.Load<GameObject>("card/bg_img/fx_disaappear_1");
if (disappear02 == null) disappear02 = Resources.Load<GameObject>("card/bg_img/fx_disaappear_2");
if (type == 1)
{
SkeletonAnimation temp = Instantiate(disappear01, new Vector3(vec3.x, vec3.y, 110), Quaternion.identity, gameObject.transform).GetComponent<SkeletonAnimation>();
temp.AnimationState.SetAnimation(0, "disappear01", true);
temp.AnimationState.Complete += (trackEntry) =>
{
Destroy(temp.gameObject);
};
}
if (type == 2)
{
SkeletonAnimation temp = Instantiate(disappear02, new Vector3(vec3.x, vec3.y, 110), Quaternion.identity, gameObject.transform).GetComponent<SkeletonAnimation>();
temp.AnimationState.SetAnimation(0, "disappear02", true);
temp.AnimationState.Complete += (trackEntry) =>
{
Destroy(temp.gameObject);
};
}
// temp.GetComponent<SpriteRenderer>().sprite = img_list[card_item_list[i][j].card_type];
}
int getMaplayer(List<List<Vector2>> map_list)
{
int layer = UnityEngine.Random.Range(0, map_list.Count);//确定层数
if (map_list[layer].Count == 0)
{
layer = getMaplayer(map_list);
}
return layer;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using IgnoreOPS;
using Spine.Unity;
using BallKingdomCrush;
using UnityEngine;
public class CreatAnimalCard : MonoBehaviour
{
private GameObject card_item;
public static CreatAnimalCard instance;
private List<Sprite> img_list;
public Camera orthoCamera; // 这个变量应该被设置为您想要调整大小的正交相机
private void Awake()
{
instance = this;
card_item = Resources.Load<GameObject>("card/card_item/card_");
img_list = new List<Sprite>();
// img_list = Resources.LoadAll<Sprite>("card/card_sprite").ToList();
// img_list.Sort((x, y) => String.Compare(x.name, y.name));
for (int i = 0; i < 16; i++)
{
img_list.Add(Resources.Load<Sprite>("card/card_sprite/" + i));
}
orthoCamera = GameObject.Find("GameCamera").GetComponent<Camera>();
float size = (float)Math.Round(28.125f / ((float)Screen.width / Screen.height), 4);
string type = SystemInfo.deviceModel.ToLower().Trim();
// Debug.Log($"type==========={type}");
if (type.Substring(0, 3) == "ipa")
{//iPad机型
size = 49.9f;
}
orthoCamera.orthographicSize = size;
}
public void SetCameraVisible(bool visible)
{
orthoCamera.SetActive(visible);
GameHelper.ShowSheepPlayUI(visible);
}
// Start is called before the first frame update
public List<List<Card_item>> card_item_list = new List<List<Card_item>>();
public List<List<Card_item>> CreatCardNew(int all_card_numbers, int card_type_max, int card_layer, int extra_max, List<List<Vector2>> map_list, List<Vector2> left_extra_list,
List<Vector2> right_extra_list)
{
//all_card_numbers *= 3;
int money_rate = ConfigSystem.GetCommonConf().rewardrate;
List<int> type_list = new List<int>();
List<int> this_timetype_list = new List<int>();
// Debug.Log(card_layer);
card_item_list.Clear();
// ---------- 新增:先从0~15中挑选 card_type_max 个不同的类型 ----------
List<int> allTypes = Enumerable.Range(0, 15).ToList(); // [0,1,2,...,15]
List<int> chosenTypes = new List<int>();
for (int i = 0; i < card_type_max; i++)
{
int idx = UnityEngine.Random.Range(0, allTypes.Count);
chosenTypes.Add(allTypes[idx]);
allTypes.RemoveAt(idx); // 确保不重复
}
// ---------------------------------------------------------------
// 打印选出来的类型池
Debug.Log($"[CreatCardNew] 随机选出的 {card_type_max} 个类型: {string.Join(",", chosenTypes)}");
for (int i = 0; i < all_card_numbers; i++)
{
int type = 0;
var randomNum = UnityEngine.Random.Range(0, 100);
// Debug.Log($"[creat] money_rate------------ {randomNum}==={money_rate}");
if (GameHelper.IsGiftSwitch() && randomNum < money_rate)
{
type = 15; // 金币
}
else
{
// 在挑选好的类型池里再随机
type = chosenTypes[UnityEngine.Random.Range(0, chosenTypes.Count)];
}
// if (GameHelper.IsGiftSwitch() && type == 15)
// {
// type = UnityEngine.Random.Range(0, card_type_max - 1);
// }
#if UNITY_EDITOR
// type = 1;
#endif
Debug.Log($"[CreatCardNew] 随机选出的 类型: {type}");
type_list.Add(type);
type_list.Add(type);
type_list.Add(type);
if (!this_timetype_list.Contains(type)) this_timetype_list.Add(type);
}
SaveData.GetSaveObject().this_time_cardtype = this_timetype_list.Count;
for (int i = 0; i < card_layer; i++)
{
card_item_list.Add(new List<Card_item>());
}
if (left_extra_list.Count > 0 || right_extra_list.Count > 0)
{
for (int i = 0; i < left_extra_list.Count; i++)
{
Card_item _tempObject = new()
{
pos_x = left_extra_list[i].x,
pos_y = left_extra_list[i].y,
_layer = i
};
card_item_list[i].Add(_tempObject);
}
for (int i = 0; i < right_extra_list.Count; i++)
{
Card_item _tempObject1 = new()
{
pos_x = right_extra_list[i].x,
pos_y = right_extra_list[i].y,
_layer = i
};
card_item_list[i].Add(_tempObject1);
}
}
var nums = 0;
for (int i = 0; i < map_list.Count; i++)
{
nums += map_list[i].Count;
}
for (int i = 0; i < nums; i++)
{
Card_item _tempObject = new();
int layer = getMaplayer(map_list);//确定层数
int pos = UnityEngine.Random.Range(0, map_list[layer].Count);
_tempObject.pos_x = map_list[layer][pos].x;
_tempObject.pos_y = map_list[layer][pos].y;
_tempObject._layer = layer;
card_item_list[layer].Add(_tempObject);
map_list[layer].RemoveAt(pos);
}
for (int i = 0; i < card_item_list.Count; i++)
{
card_item_list[i].Sort((x, y) => y.pos_y.CompareTo(x.pos_y));
}
int index = 0;
for (int i = 0; i < card_item_list.Count; i++)
{
float z_offset = 0;//用来微调每层之间的z值,让下层盖住上层
float last_posy = 0;
for (int j = 0; j < card_item_list[i].Count; j++)
{
if (last_posy != card_item_list[i][j].pos_y)
{
z_offset += 0.05f;
last_posy = card_item_list[i][j].pos_y;
}
GameObject temp = Instantiate(card_item, new Vector3(card_item_list[i][j].pos_x, card_item_list[i][j].pos_y, 400 - card_item_list[i][j]._layer - z_offset), Quaternion.identity, gameObject.transform);
index = UnityEngine.Random.Range(0, type_list.Count);
temp.GetComponent<SpriteRenderer>().sprite = img_list[type_list[index]];
card_item_list[i][j].sheep_card = temp;
card_item_list[i][j].card_type = type_list[index];
temp.gameObject.name = i + "-" + j;
type_list.RemoveAt(index);
}
}
return card_item_list;
}
public void creatSaveCard(List<List<Card_item>> card_item_list)
{
this.card_item_list = card_item_list;
for (int i = 0; i < card_item_list.Count; i++)
{
for (int j = 0; j < card_item_list[i].Count; j++)
{
GameObject temp;
// if (card_item_list[i][j].is_out)
// {
// temp = Instantiate(card_item, new Vector3(card_item_list[i][j].pos_x, card_item_list[i][j].pos_y, 400 - card_item_list[i][j].out_layer), Quaternion.identity, gameObject.transform);
// }
// else
temp = Instantiate(card_item, new Vector3(card_item_list[i][j].pos_x, card_item_list[i][j].pos_y, 400 - card_item_list[i][j]._layer), Quaternion.identity, gameObject.transform);
temp.GetComponent<SpriteRenderer>().sprite = img_list[card_item_list[i][j].card_type];
card_item_list[i][j].sheep_card = temp;
if (card_item_list[i][j].in_slot || card_item_list[i][j].is_out) temp.transform.localScale = new Vector3(4.628f, 4.628f, 1);
temp.gameObject.name = i + "-" + j;
}
}
}
private GameObject Popup;
void Update()
{
if (Input.GetMouseButtonDown(0))
{
if (Popup == null) Popup = GameObject.Find("Popup");
if (Popup.transform.childCount != 0) return;
Ray ray = orthoCamera.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
int layerMask = 1 << 6; // 只与第8层的碰撞器碰撞
// 如果射线与layerMask指定层的碰撞器发生碰撞
if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
{
// Debug.Log("Hit " + hit.collider.gameObject.name);
GameDispatcher.Instance.Dispatch(GameMsg.card_click, hit.collider.gameObject.name);
// 在此处添加点击物体后的逻辑
}
else
{
// Debug.Log("No hit");
}
}
}
private GameObject disappear01;
private GameObject disappear02;
public void creatSpine(int type, Vector3 vec3)
{
if (disappear01 == null) disappear01 = Resources.Load<GameObject>("card/bg_img/fx_disaappear_1");
if (disappear02 == null) disappear02 = Resources.Load<GameObject>("card/bg_img/fx_disaappear_2");
if (type == 1)
{
SkeletonAnimation temp = Instantiate(disappear01, new Vector3(vec3.x, vec3.y, 110), Quaternion.identity, gameObject.transform).GetComponent<SkeletonAnimation>();
temp.AnimationState.SetAnimation(0, "disappear01", true);
temp.AnimationState.Complete += (trackEntry) =>
{
Destroy(temp.gameObject);
};
}
if (type == 2)
{
SkeletonAnimation temp = Instantiate(disappear02, new Vector3(vec3.x, vec3.y, 110), Quaternion.identity, gameObject.transform).GetComponent<SkeletonAnimation>();
temp.AnimationState.SetAnimation(0, "disappear02", true);
temp.AnimationState.Complete += (trackEntry) =>
{
Destroy(temp.gameObject);
};
}
// temp.GetComponent<SpriteRenderer>().sprite = img_list[card_item_list[i][j].card_type];
}
int getMaplayer(List<List<Vector2>> map_list)
{
int layer = UnityEngine.Random.Range(0, map_list.Count);//确定层数
if (map_list[layer].Count == 0)
{
layer = getMaplayer(map_list);
}
return layer;
}
}
+54 -54
View File
@@ -1,55 +1,55 @@
using UnityEngine;
using System.Collections.Generic;
using SGModule.Common;
namespace BallKingdomCrush
{
public static class AppConst
{
#region Field
#if GAME_RELEASE
public static bool IsEnabledEngineLog = true;
#else
public static bool IsEnabledEngineLog = true;
#endif
public const LogType EnabledFilterLogType =
LogType.Log | LogType.Warning | LogType.Error | LogType.Assert |
LogType.Exception;
public const bool IsRunInBG = true;
public const int SleepTimeoutMode = SleepTimeout.NeverSleep;
public const int AntiAliasing = 0;
public const int HighFrameRate = 60;
public const int LowFrameRate = 45;
public const float HDHighViewScale = 1f;
public const float HDLowViewScale = 0.9f;
public const float PixelsPerUnit = 100f;
public static Vector2Int StandardResolution = new Vector2Int(1080, 1920);
public static Vector2Int UIResolution = new Vector2Int(1080, 1920);
public static bool UseInternalSetting = true;
public static bool IsMultiLangue = true;
public static string CurrMultiLangue = "en";
public static string DefaultLangue = "en";
public static string InternalLangue = "en";
public static string DeviceLangue = "en";
public static List<string> CtrlDisableList = new List<string>();
#endregion
public static bool isPt()
{
if (CurrMultiLangue == "pt") return true;
return false;
}
}
using UnityEngine;
using System.Collections.Generic;
using SGModule.Common;
namespace BallKingdomCrush
{
public static class AppConst
{
#region Field
#if GAME_RELEASE
public static bool IsEnabledEngineLog = false;
#else
public static bool IsEnabledEngineLog = true;
#endif
public const LogType EnabledFilterLogType =
LogType.Log | LogType.Warning | LogType.Error | LogType.Assert |
LogType.Exception;
public const bool IsRunInBG = true;
public const int SleepTimeoutMode = SleepTimeout.NeverSleep;
public const int AntiAliasing = 0;
public const int HighFrameRate = 60;
public const int LowFrameRate = 45;
public const float HDHighViewScale = 1f;
public const float HDLowViewScale = 0.9f;
public const float PixelsPerUnit = 100f;
public static Vector2Int StandardResolution = new Vector2Int(1080, 1920);
public static Vector2Int UIResolution = new Vector2Int(1080, 1920);
public static bool UseInternalSetting = true;
public static bool IsMultiLangue = true;
public static string CurrMultiLangue = "en";
public static string DefaultLangue = "en";
public static string InternalLangue = "en";
public static string DeviceLangue = "en";
public static List<string> CtrlDisableList = new List<string>();
#endregion
public static bool isPt()
{
if (CurrMultiLangue == "pt") return true;
return false;
}
}
}
+404
View File
@@ -0,0 +1,404 @@
// ============================================================
// IAPPayManager.cs
// IAP 接入使用(MonoBehaviour
//
// 将此脚本挂到场景中的任意 GameObject 即可运行示例。
// 请将商品 ID 替换为你在 App Store Connect / Google Play Console 中配置的真实 ID。
// ============================================================
using System.Collections;
using System.Collections.Generic;
using SDK_IAP;
using UnityEngine;
using UnityEngine.Purchasing;
namespace BallKingdomCrush
{
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 = "comwackyllamagamegift199"; //首充 消耗品
public static string PRODUCT_REMOVE_ADS = "comwackyllamagameremove299"; //移除广告 消耗品
public static string PRODUCT_PASS_BONUS = "comwackyllamagamepass999"; //通行证礼包 消耗品
public static string PRODUCT_SPACE_BONUS = "comwackyllamagamespace2499"; //加一格礼包 非消耗品
public static string PRODUCT_SHOP_1 = "comwackyllamagameshop199"; //商店档位1 消耗品
public static string PRODUCT_SHOP_2 = "comwackyllamagameshop399"; //商店档位2 消耗品
public static string PRODUCT_SHOP_3= "comwackyllamagameshop999"; //商店档位3 消耗品
public static string PRODUCT_SHOP_4 = "comwackyllamagameshop1999"; //商店档位4 消耗品
public static string PRODUCT_SHOP_5 = "comwackyllamagameshop3999"; //商店档位5 消耗品
public static string PRODUCT_THREE_DAY = "comwackyllamagamethreeday399"; //三天礼包 消耗品
public static string PRODUCT_VIP_WEEK = "comwackyllamagamesub999"; // 周订阅 Subscription
public static string PRODUCT_VIP_MONTH = "comwackyllamagamesub2999"; // 月订阅 Subscription
public static string PRODUCT_VIP_YEAR = "comwackyllamagamesub9999"; // 年订阅 Subscription
// ──────────────────────────────────────────────────────────
// 生命周期
// ──────────────────────────────────────────────────────────
private void Awake()
{
// 确保单例唯一性
if (_instance != null && _instance != this)
{
Debug.LogWarning("[IAP Google] 检测到多个 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 Google] 开始初始化...");
IAPManager.Init(products, OnInitCallback);
}
// Init 完成回调(与 OnInitialized 事件等价,二选一即可)
private void OnInitCallback(bool success)
{
if (success)
{
Debug.Log("[IAP Google] 初始化成功!");
ShowProductPrices();
}
else
{
Debug.LogError("[IAP Google] 初始化失败,请检查网络或 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 Google] 商品: {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 Google] 购买成功: {productName} ({result.productId}) | tid={result.transactionId}");
onSuccess?.Invoke();
}
else
{
Debug.LogWarning($"[IAP Google] 购买失败: {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 Google] 订阅成功: {subscriptionName} ({result.productId}) | tid={result.transactionId}");
ShowSubscriptionInfo();
onSuccess?.Invoke();
}
else
{
Debug.LogWarning($"[IAP Google] 订阅失败: {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 Google] 恢复购买流程完成(实际恢复内容通过 OnDeliver 发放)");
else
Debug.LogWarning($"[IAP Google] 恢复购买失败: {result.error}");
});
}
// ──────────────────────────────────────────────────────────
// 权益检查
// ──────────────────────────────────────────────────────────
/// <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 Google] {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权限
}
});
}
// ──────────────────────────────────────────────────────────
// 订阅信息查询
// ──────────────────────────────────────────────────────────
public void ShowSubscriptionInfo()
{
var info = IAPManager.GetSubscriptionInfo(PRODUCT_VIP_MONTH);
Debug.Log($"[IAP Google] VIP 订阅状态:");
Debug.Log($" isSubscribed = {info.isSubscribed}");
Debug.Log($" isExpired = {info.isExpired}");
Debug.Log($" expireDate = {info.expireDate:yyyy-MM-dd HH:mm:ss}");
Debug.Log($" isAutoRenewing= {info.isAutoRenewing}");
}
// ──────────────────────────────────────────────────────────
// 全局发货处理(OnDeliver 事件接收)
// ──────────────────────────────────────────────────────────
/// <summary>
/// 统一发货处理入口。
/// 无论是新购买、补单、还是恢复购买,都会触发此方法。
/// ⚠️ 幂等保护已由 DeliverGuardLite 处理,此处无需再判重。
/// </summary>
private void HandleDeliver(string productId)
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
if (!IsValidProduct(productId))
{
Debug.LogWarning($"[IAP Google] 非法商品ID,拒绝发货: {productId}");
return;
}
Debug.Log($"[IAP Google] 发货通知: {productId}");
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, productId);
PurchasingManager.SendEventClickByName(productId,"open");
PurchasingManager.SendEventClickByName(productId,"success");
// switch (productId)
// {
// // 消耗品
// case PRODUCT_FIRST_GIFT:
// Debug.Log("[IAP Google] 发放首充礼包 - 100金币");
// // GoldManager.Add(100);
// break;
//
// case PRODUCT_REMOVE_ADS:
// Debug.Log("[IAP Google] 发放移除广告权益");
// // AdsManager.Disable();
// break;
//
// case PRODUCT_PASS_BONUS:
// Debug.Log("[IAP Google] 发放通行证礼包");
// // PassBonusManager.Grant();
// break;
//
// case PRODUCT_SHOP_1:
// Debug.Log("[IAP Google] 发放商店档位1奖励");
// // ShopManager.GrantReward(1);
// break;
//
// case PRODUCT_SHOP_2:
// Debug.Log("[IAP Google] 发放商店档位2奖励");
// // ShopManager.GrantReward(2);
// break;
//
// case PRODUCT_SHOP_3:
// Debug.Log("[IAP Google] 发放商店档位3奖励");
// // ShopManager.GrantReward(3);
// break;
//
// case PRODUCT_SHOP_4:
// Debug.Log("[IAP Google] 发放商店档位4奖励");
// // ShopManager.GrantReward(4);
// break;
//
// case PRODUCT_SHOP_5:
// Debug.Log("[IAP Google] 发放商店档位5奖励");
// // ShopManager.GrantReward(5);
// break;
//
// case PRODUCT_THREE_DAY:
// Debug.Log("[IAP Google] 发放三天礼包");
// // ThreeDayManager.Grant();
// break;
//
// // 非消耗品
// case PRODUCT_SPACE_BONUS:
// Debug.Log("[IAP Google] 增加背包空间一格");
// // InventoryManager.AddSpace(1);
// break;
//
// // 订阅
// case PRODUCT_VIP_WEEK:
// Debug.Log("[IAP Google] 激活VIP周卡");
// // VipManager.Activate(7);
// break;
//
// case PRODUCT_VIP_MONTH:
// Debug.Log("[IAP Google] 激活VIP月卡");
// // VipManager.Activate(30);
// break;
//
// case PRODUCT_VIP_YEAR:
// Debug.Log("[IAP Google] 激活VIP年卡");
// // VipManager.Activate(365);
// break;
//
// default:
// Debug.LogWarning($"[IAP Google] 未知商品 ID: {productId}");
// break;
// }
}
/// <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;
}
}
}
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3bad0553c6454cc99003afafb3208acf
timeCreated: 1778204916
+1 -1
View File
@@ -11,7 +11,7 @@ public class LoveLegendRoot : MonoBehaviour
{
public void Awake()
{
#if UNITY_EDITOR || !GAME_RELEASE
#if UNITY_EDITOR || GAME_RELEASE
GameObject.Find("IngameDebugConsole").SetActive(false);
#endif
SdkConfigMgr.Init();
+141 -139
View File
@@ -1,140 +1,142 @@
// #if UNITY_EDITOR
// #endif
using System.Linq;
using FairyGUI;
using IgnoreOPS;
using SGModule.NetKit;
using Unity.VisualScripting;
using UnityEngine;
namespace BallKingdomCrush
{
public class MainScene : BaseScene
{
public override int SceneIdx => 0;
protected override void OnEnter()
{
}
protected override void OnLeave()
{
}
protected override void OnSwitchSceneComplete(object param = null)
{
StartUpAppProcess();
}
private void StartUpAppProcess()
{
OnPermanentAssetsInitComplete();
}
private void OnPermanentAssetsInitComplete(object param = null)
{
CtrlDispatcher.Instance.AddListener(CtrlMsg.Login_Succeed, OnLoginSucceed);
var isAssetBundleLoad = false;
// SuperApplication.Instance.AddComponent<AppsFlyerObjectScript1>();
#if !UNITY_EDITOR && UNITY_ANDROID
// MaxADKit.Init();
#endif
#if UNITY_EDITOR
isAssetBundleLoad = false;
#else
isAssetBundleLoad = false;
#endif
if (isAssetBundleLoad)
{
int value = 0;
LegendFileKit.GetLocalAssetBundle(
max => { GameDispatcher.Instance.Dispatch(GameMsg.UpdateHotFixMax, max + 1); }, () =>
{
value++;
// GameDispatcher.Instance.Dispatch(GameMsg.UpdateHotFixProgress, value);
});
}
else
{
OnInitAsset();
}
UnityManager.Instance.DakaiACT();
AppDispatcher.Instance.AddListener(AppMsg.UI_LoadingInitAsset, OnInitAsset);
TrackKit.TrackLoginFunnel(LoginFunnelEventType.AfSend);
TrackKit.TrackLoginFunnel(LoginFunnelEventType.AfRecv, "success");
}
private void OnLoginSucceed(object param = null)
{
CtrlDispatcher.Instance.RemoveListener(CtrlMsg.Login_Succeed, OnLoginSucceed);
}
private void OnInitAsset(object param = null)
{
AppDispatcher.Instance.Dispatch(AppMsg.AppManagerRegister);
AppDispatcher.Instance.Dispatch(AppMsg.InitUIMgr);
// NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
AppDispatcher.Instance.AddListener(AppMsg.LoginInit, OnLoadingComplete);
// PreferencesMgr.Instance.InitPreferences();
// NetworkDispatcher.Instance.Dispatch(NetworkMsg.GetConfig);
}
private void OnLoadingComplete(object param = null)
{
if (GameHelper.IsGiftSwitch())
{
UnityManager.Instance.InitACT();
}
//初始化Live数据
PreDownloadManager.InitializeLiveData();
// Debug.Log("OnLoadingComplete------------");
CtrlDispatcher.Instance.Dispatch(CtrlMsg.Game_StartReady);
TimerHelper.mEasy.AddTimer(0.5f, () =>
{
AudioManager.Instance.InitDefaultButtonClickSound(AudioConst.UIButtonDefault);
ModuleManager.Instance.AllModuleGameStart();
ShowScene();
SaveingPotHelper.CheckSaveingPot();
SaveingPotHelper.TestingClearTime();
if (GameHelper.IsGiftSwitch())
{
PreDownloadManager.StartDownloadAlbumsPicture();
//预下载视频
PreDownloadManager.StartDownload();
PreDownloadManager.StartDownloadSecretPicture();
}
});
}
public static bool is_open = false;
private void ShowScene()
{
if (is_open) return;
is_open = true;
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.GameLoginUI_Open);
}
public override void Dispose()
{
}
}
// #if UNITY_EDITOR
// #endif
using System.Linq;
using FairyGUI;
using IgnoreOPS;
using SGModule.NetKit;
using Unity.VisualScripting;
using UnityEngine;
namespace BallKingdomCrush
{
public class MainScene : BaseScene
{
public override int SceneIdx => 0;
protected override void OnEnter()
{
}
protected override void OnLeave()
{
}
protected override void OnSwitchSceneComplete(object param = null)
{
StartUpAppProcess();
}
private void StartUpAppProcess()
{
OnPermanentAssetsInitComplete();
}
private void OnPermanentAssetsInitComplete(object param = null)
{
CtrlDispatcher.Instance.AddListener(CtrlMsg.Login_Succeed, OnLoginSucceed);
var isAssetBundleLoad = false;
// SuperApplication.Instance.AddComponent<AppsFlyerObjectScript1>();
#if !UNITY_EDITOR && UNITY_ANDROID
// MaxADKit.Init();
#endif
#if UNITY_EDITOR
isAssetBundleLoad = false;
#else
isAssetBundleLoad = false;
#endif
if (isAssetBundleLoad)
{
int value = 0;
LegendFileKit.GetLocalAssetBundle(
max => { GameDispatcher.Instance.Dispatch(GameMsg.UpdateHotFixMax, max + 1); }, () =>
{
value++;
// GameDispatcher.Instance.Dispatch(GameMsg.UpdateHotFixProgress, value);
});
}
else
{
OnInitAsset();
}
UnityManager.Instance.DakaiACT();
AppDispatcher.Instance.AddListener(AppMsg.UI_LoadingInitAsset, OnInitAsset);
TrackKit.TrackLoginFunnel(LoginFunnelEventType.AfSend);
TrackKit.TrackLoginFunnel(LoginFunnelEventType.AfRecv, "success");
}
private void OnLoginSucceed(object param = null)
{
CtrlDispatcher.Instance.RemoveListener(CtrlMsg.Login_Succeed, OnLoginSucceed);
}
private void OnInitAsset(object param = null)
{
AppDispatcher.Instance.Dispatch(AppMsg.AppManagerRegister);
AppDispatcher.Instance.Dispatch(AppMsg.InitUIMgr);
#if UNITY_EDITOR
NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
#endif
AppDispatcher.Instance.AddListener(AppMsg.LoginInit, OnLoadingComplete);
// PreferencesMgr.Instance.InitPreferences();
// NetworkDispatcher.Instance.Dispatch(NetworkMsg.GetConfig);
}
private void OnLoadingComplete(object param = null)
{
if (GameHelper.IsGiftSwitch())
{
UnityManager.Instance.InitACT();
}
//初始化Live数据
PreDownloadManager.InitializeLiveData();
// Debug.Log("OnLoadingComplete------------");
CtrlDispatcher.Instance.Dispatch(CtrlMsg.Game_StartReady);
TimerHelper.mEasy.AddTimer(0.5f, () =>
{
AudioManager.Instance.InitDefaultButtonClickSound(AudioConst.UIButtonDefault);
ModuleManager.Instance.AllModuleGameStart();
ShowScene();
SaveingPotHelper.CheckSaveingPot();
SaveingPotHelper.TestingClearTime();
if (GameHelper.IsGiftSwitch())
{
PreDownloadManager.StartDownloadAlbumsPicture();
//预下载视频
PreDownloadManager.StartDownload();
PreDownloadManager.StartDownloadSecretPicture();
}
});
}
public static bool is_open = false;
private void ShowScene()
{
if (is_open) return;
is_open = true;
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.GameLoginUI_Open);
}
public override void Dispose()
{
}
}
}
File diff suppressed because it is too large Load Diff
+221 -221
View File
@@ -1,222 +1,222 @@
using System;
using FairyGUI;
using Spine.Unity;
using System.Collections.Generic;
using SGModule.NetKit;
using FGUI.ZM_Common_01;
using IgnoreOPS;
using FGUI.ZM_AddCell_12;
namespace BallKingdomCrush
{
public class AddViewUI : BaseUI
{
private AddViewUICtrl ctrl;
private AddViewModel model;
private FGUI.ZM_AddCell_12.com_addView ui;
public int ad_cool_down = 120;
public btn_watchAd btn_WatchAd;
private Action closeCallback;
private bool isAutoPop = false;
public AddViewUI(AddViewUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.AddViewUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_AddCell_12";
uiInfo.assetName = "com_addView";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.AddViewModel) as AddViewModel;
}
protected override void OnClose()
{
GameHelper.showGameUI = true;
HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
if (GameHelper.IsAdModelOfPay())
{
AdExchangeManager.Instance.Destroy();
}
if (isAutoPop)
{
GameHelper.CallShowTurn();
}
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_AddCell_12.com_addView;
}
protected override void OnOpenBefore(object args)
{
if (args != null)
{
isAutoPop = (bool)args;
}
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.buy_one_show);
// var sk = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_node as GGraph, Fx_Type.fx_add, ref closeCallback);
// sk.state.SetAnimation(0, "animation", true);
// ad_cool_down = ConfigSystem.GetCommonConf().exchangeCD;
// btn_WatchAd = ui.btn_watch as btn_watchAd;
if (GameHelper.IsAdModelOfPay())
{
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.buy_one), ui.btn_watch as btn_watchAd, SetTextString);
ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.Start();
SetTextString();
}
else
{
ui.pay_type.selectedIndex = 1;
decimal price = (decimal)GameHelper.GetCommonModel().addspace2;
ui.btn_max_pay.title = GameHelper.getPrice(price);
ui.btn_max_pay.SetClick(() =>
{
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price * 100),
sku = PurchasingManager.GetPaySku(PayType.buy_one),
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
if (GameHelper.IsGiftSwitch())
{
ui.broad.visible = true;
}
else
{
ui.broad.visible = false;
}
InitView();
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
if (type == PurchasingManager.GetPaySku(PayType.buy_one))
{
CtrlCloseUI();
}
}
//初始化页面逻辑
private void InitView()
{
ui.btn_close.SetClick(() =>
{
CtrlCloseUI();
GameDispatcher.Instance.Dispatch(GameMsg.resurgence_close);
});
HallManager.Instance.UpdateSecondEvent += updateWatchCD;
InitBroadCast();
// checkBtnState();
}
void updateWatchCD()
{
broadtime++;
BroadCast();
}
public void SetTextString()
{
var need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.buy_one));
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.tips.SetVar("num", need.ToString()).FlushVars();
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
}
private int broadtime = 1;
private List<string> config_name_list = LevelAttemptsModel.config_name_list;
private List<string> config_money_list = LevelAttemptsModel.config_money_list;
private List<string[]> broad_list = new List<string[]>();
private void BroadCast()
{
if (broadtime % 3 == 0)
{
(ui.broad as com_broadcast_new).t1.Play(() =>
{
broad_list.RemoveAt(0);
int name_index = UnityEngine.Random.Range(0, config_name_list.Count);
int money_index = UnityEngine.Random.Range(0, config_money_list.Count);
broad_list.Add(new string[2] { config_name_list[name_index], config_money_list[money_index] });
for (int i = 0; i < 4; i++)
{
text_list[i].text = Language.GetContentParams("congratulations_des", new[] { broad_list[i][0], broad_list[i][1] });
}
});
}
}
private List<GTextField> text_list = new List<GTextField>();
private void InitBroadCast()
{
text_list.Add((ui.broad as com_broadcast_new).text_0);
text_list.Add((ui.broad as com_broadcast_new).text_1);
text_list.Add((ui.broad as com_broadcast_new).text_2);
text_list.Add((ui.broad as com_broadcast_new).text_3);
for (int i = 0; i < 4; i++)
{
int name_index = UnityEngine.Random.Range(0, config_name_list.Count);
int money_index = UnityEngine.Random.Range(0, config_money_list.Count);
broad_list.Add(new string[2] { config_name_list[name_index], config_money_list[money_index] });
text_list[i].text = Language.GetContentParams("congratulations_des", new[] { broad_list[i][0], broad_list[i][1] });
}
}
}
using System;
using FairyGUI;
using Spine.Unity;
using System.Collections.Generic;
using SGModule.NetKit;
using FGUI.ZM_Common_01;
using IgnoreOPS;
using FGUI.ZM_AddCell_12;
namespace BallKingdomCrush
{
public class AddViewUI : BaseUI
{
private AddViewUICtrl ctrl;
private AddViewModel model;
private FGUI.ZM_AddCell_12.com_addView ui;
public int ad_cool_down = 120;
public btn_watchAd btn_WatchAd;
private Action closeCallback;
private bool isAutoPop = false;
public AddViewUI(AddViewUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.AddViewUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_AddCell_12";
uiInfo.assetName = "com_addView";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.AddViewModel) as AddViewModel;
}
protected override void OnClose()
{
GameHelper.showGameUI = true;
HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
if (GameHelper.IsAdModelOfPay())
{
AdExchangeManager.Instance.Destroy();
}
if (isAutoPop)
{
GameHelper.CallShowTurn();
}
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_AddCell_12.com_addView;
}
protected override void OnOpenBefore(object args)
{
if (args != null)
{
isAutoPop = (bool)args;
}
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.buy_one_show);
// var sk = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_node as GGraph, Fx_Type.fx_add, ref closeCallback);
// sk.state.SetAnimation(0, "animation", true);
// ad_cool_down = ConfigSystem.GetCommonConf().exchangeCD;
// btn_WatchAd = ui.btn_watch as btn_watchAd;
if (GameHelper.IsAdModelOfPay())
{
AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_SPACE_BONUS, ui.btn_watch as btn_watchAd, SetTextString);
ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.Start();
SetTextString();
}
else
{
ui.pay_type.selectedIndex = 1;
decimal price = (decimal)GameHelper.GetCommonModel().addspace2;
ui.btn_max_pay.title = GameHelper.getPrice(price);
ui.btn_max_pay.SetClick(() =>
{
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price * 100),
sku = IAPPayManager.PRODUCT_SPACE_BONUS,//IAPPayManager.PRODUCT_SPACE_BONUS,
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
if (GameHelper.IsGiftSwitch())
{
ui.broad.visible = true;
}
else
{
ui.broad.visible = false;
}
InitView();
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
if (type == IAPPayManager.PRODUCT_SPACE_BONUS)
{
CtrlCloseUI();
}
}
//初始化页面逻辑
private void InitView()
{
ui.btn_close.SetClick(() =>
{
CtrlCloseUI();
GameDispatcher.Instance.Dispatch(GameMsg.resurgence_close);
});
HallManager.Instance.UpdateSecondEvent += updateWatchCD;
InitBroadCast();
// checkBtnState();
}
void updateWatchCD()
{
broadtime++;
BroadCast();
}
public void SetTextString()
{
var need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_SPACE_BONUS);
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.tips.SetVar("num", need.ToString()).FlushVars();
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
}
private int broadtime = 1;
private List<string> config_name_list = LevelAttemptsModel.config_name_list;
private List<string> config_money_list = LevelAttemptsModel.config_money_list;
private List<string[]> broad_list = new List<string[]>();
private void BroadCast()
{
if (broadtime % 3 == 0)
{
(ui.broad as com_broadcast_new).t1.Play(() =>
{
broad_list.RemoveAt(0);
int name_index = UnityEngine.Random.Range(0, config_name_list.Count);
int money_index = UnityEngine.Random.Range(0, config_money_list.Count);
broad_list.Add(new string[2] { config_name_list[name_index], config_money_list[money_index] });
for (int i = 0; i < 4; i++)
{
text_list[i].text = Language.GetContentParams("congratulations_des", new[] { broad_list[i][0], broad_list[i][1] });
}
});
}
}
private List<GTextField> text_list = new List<GTextField>();
private void InitBroadCast()
{
text_list.Add((ui.broad as com_broadcast_new).text_0);
text_list.Add((ui.broad as com_broadcast_new).text_1);
text_list.Add((ui.broad as com_broadcast_new).text_2);
text_list.Add((ui.broad as com_broadcast_new).text_3);
for (int i = 0; i < 4; i++)
{
int name_index = UnityEngine.Random.Range(0, config_name_list.Count);
int money_index = UnityEngine.Random.Range(0, config_money_list.Count);
broad_list.Add(new string[2] { config_name_list[name_index], config_money_list[money_index] });
text_list[i].text = Language.GetContentParams("congratulations_des", new[] { broad_list[i][0], broad_list[i][1] });
}
}
}
}
+232 -233
View File
@@ -1,234 +1,233 @@
using FairyGUI;
using SGModule.NetKit;
using Spine.Unity;
using System;
using System.Collections.Generic;
using DontConfuse;
using IgnoreOPS;
using FGUI.ZM_Common_01;
namespace BallKingdomCrush
{
public class AddViewoffUI : BaseUI
{
private AddViewoffUICtrl ctrl;
private AddViewoffModel model;
private FGUI.ZM_AddCell_12.com_addView_off ui;
private Action closeCallback;
private bool isAutoPop = false;
public AddViewoffUI(AddViewoffUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.AddViewoffUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_AddCell_12";
uiInfo.assetName = "com_addView_off";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.AddViewoffModel) as AddViewoffModel;
}
protected override void OnClose()
{
GameHelper.showGameUI = true;
HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
if (GameHelper.IsAdModelOfPay())
{
AdExchangeManager.Instance.Destroy();
}
closeCallback?.Invoke();
if (isAutoPop)
{
GameHelper.CallShowTurn();
}
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_AddCell_12.com_addView_off;
}
protected override void OnOpenBefore(object args)
{
if (args != null)
{
isAutoPop = (bool)args;
}
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.BuyOneOffShow);
// ad_cool_down = ConfigSystem.GetCommonConf().exchangeCD;
// btn_WatchAd = ui.btn_watch as btn_watchAd;
if (GameHelper.IsAdModelOfPay())
{
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.buy_one_off), ui.btn_watch as btn_watchAd, SetTextString);
ui.pay_type.selectedIndex = 0;
ui.text_old_price.text = GameHelper.GetCommonModel().addspace + "ADs";
btn_watchAd btn = ui.btn_watch as btn_watchAd;
AdExchangeManager.Instance.Start();
SetTextString();
}
else
{
ui.pay_type.selectedIndex = 1;
ui.text_old_price.text = GameHelper.getPrice((decimal)GameHelper.GetCommonModel().addspace2);
decimal price = (decimal)GameHelper.GetCommonModel().AddDiscount2;
ui.btn_max_pay.title = GameHelper.getPrice(price);
ui.btn_max_pay.SetClick(() =>
{
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price * 100),
sku = PurchasingManager.GetPaySku(PayType.buy_one_off),
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
if (GameHelper.IsGiftSwitch())
{
ui.broad.visible = true;
}
else
{
ui.broad.visible = false;
}
InitView();
InitBroadCast();
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
if (type == PurchasingManager.GetPaySku(PayType.buy_one_off))
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AddViewoffUI_Close);
SaveData.GetSaveObject().have_slot = true;
SaveData.SaveDataFunc();
GameDispatcher.Instance.Dispatch(GameMsg.Slot_refresh);
GameDispatcher.Instance.Dispatch(GameMsg.resurgence_close);
CtrlCloseUI();
}
}
//初始化页面逻辑
private void InitView()
{
// var tAnimation = FXManager.Instance.SetFx<SkeletonAnimation>(ui.tip_parent, Fx_Type.Fx_AddBoxTip, ref _closeCallback);
// tAnimation.state.AddAnimation(0, "animation", true, 0);
ui.btn_close.SetClick(() =>
{
GameDispatcher.Instance.Dispatch(GameMsg.resurgence_close);
CtrlCloseUI();
});
HallManager.Instance.UpdateSecondEvent += updateWatchCD;
// updateWatchCD();
// checkBtnState();
}
void updateWatchCD()
{
ui.text_time.text = CommonHelper.TimeFormat((int)SaveData.GetSaveObject().addview_off_time - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
broadtime++;
BroadCast();
}
public void SetTextString()
{
var need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.buy_one_off));
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.tips.SetVar("num", need.ToString()).FlushVars();
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
}
private int broadtime = 1;
private List<string> config_name_list = LevelAttemptsModel.config_name_list;
private List<string> config_money_list = LevelAttemptsModel.config_money_list;
private List<string[]> broad_list = new List<string[]>();
private void BroadCast()
{
if (broadtime % 3 == 0)
{
(ui.broad as com_broadcast_new).t1.Play(() =>
{
broad_list.RemoveAt(0);
int name_index = UnityEngine.Random.Range(0, config_name_list.Count);
int money_index = UnityEngine.Random.Range(0, config_money_list.Count);
broad_list.Add(new string[2] { config_name_list[name_index], config_money_list[money_index] });
for (int i = 0; i < 4; i++)
{
text_list[i].text = "Congratulations,User [color=#ad4800][size=36]" + broad_list[i][0] + "[/size][/color] !After purchasing the +1 Block Pack,play [color=#ad4800]" + broad_list[i][1] + "[/color] matcher to clear the level!";
}
});
}
}
private List<GTextField> text_list = new List<GTextField>();
private void InitBroadCast()
{
text_list.Add((ui.broad as com_broadcast_new).text_0);
text_list.Add((ui.broad as com_broadcast_new).text_1);
text_list.Add((ui.broad as com_broadcast_new).text_2);
text_list.Add((ui.broad as com_broadcast_new).text_3);
for (int i = 0; i < 4; i++)
{
int name_index = UnityEngine.Random.Range(0, config_name_list.Count);
int money_index = UnityEngine.Random.Range(0, config_money_list.Count);
broad_list.Add(new string[2] { config_name_list[name_index], config_money_list[money_index] });
text_list[i].text = "Congratulations,User [color=#ad4800][size=36]" + broad_list[i][0] + "[/size][/color] !After purchasing the +1 Block Pack,play [color=#ad4800]" + broad_list[i][1] + "[/color] matcher to clear the level!";
}
}
}
using FairyGUI;
using SGModule.NetKit;
using Spine.Unity;
using System;
using System.Collections.Generic;
using IgnoreOPS;
using FGUI.ZM_Common_01;
namespace BallKingdomCrush
{
public class AddViewoffUI : BaseUI
{
private AddViewoffUICtrl ctrl;
private AddViewoffModel model;
private FGUI.ZM_AddCell_12.com_addView_off ui;
private Action closeCallback;
private bool isAutoPop = false;
public AddViewoffUI(AddViewoffUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.AddViewoffUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_AddCell_12";
uiInfo.assetName = "com_addView_off";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.AddViewoffModel) as AddViewoffModel;
}
protected override void OnClose()
{
GameHelper.showGameUI = true;
HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
if (GameHelper.IsAdModelOfPay())
{
AdExchangeManager.Instance.Destroy();
}
closeCallback?.Invoke();
if (isAutoPop)
{
GameHelper.CallShowTurn();
}
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_AddCell_12.com_addView_off;
}
protected override void OnOpenBefore(object args)
{
if (args != null)
{
isAutoPop = (bool)args;
}
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.BuyOneOffShow);
// ad_cool_down = ConfigSystem.GetCommonConf().exchangeCD;
// btn_WatchAd = ui.btn_watch as btn_watchAd;
if (GameHelper.IsAdModelOfPay())
{
// AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.buy_one_off), ui.btn_watch as btn_watchAd, SetTextString);
// ui.pay_type.selectedIndex = 0;
// ui.text_old_price.text = GameHelper.GetCommonModel().addspace + "ADs";
// btn_watchAd btn = ui.btn_watch as btn_watchAd;
//
// AdExchangeManager.Instance.Start();
// SetTextString();
}
else
{
ui.pay_type.selectedIndex = 1;
ui.text_old_price.text = GameHelper.getPrice((decimal)GameHelper.GetCommonModel().addspace2);
decimal price = (decimal)GameHelper.GetCommonModel().AddDiscount2;
ui.btn_max_pay.title = GameHelper.getPrice(price);
ui.btn_max_pay.SetClick(() =>
{
// ApplePayClass maxPayData = new ApplePayClass
// {
// amount = (int)Math.Round(price * 100),
// sku = PurchasingManager.GetPaySku(PayType.buy_one_off),
// currency = "USD"
// };
// MaxPayManager.Instance.Buy(maxPayData);
});
}
if (GameHelper.IsGiftSwitch())
{
ui.broad.visible = true;
}
else
{
ui.broad.visible = false;
}
InitView();
InitBroadCast();
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
// if (type == PurchasingManager.GetPaySku(PayType.buy_one_off))
// {
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AddViewoffUI_Close);
// SaveData.GetSaveObject().have_slot = true;
// SaveData.SaveDataFunc();
// GameDispatcher.Instance.Dispatch(GameMsg.Slot_refresh);
// GameDispatcher.Instance.Dispatch(GameMsg.resurgence_close);
// CtrlCloseUI();
// }
}
//初始化页面逻辑
private void InitView()
{
// var tAnimation = FXManager.Instance.SetFx<SkeletonAnimation>(ui.tip_parent, Fx_Type.Fx_AddBoxTip, ref _closeCallback);
// tAnimation.state.AddAnimation(0, "animation", true, 0);
ui.btn_close.SetClick(() =>
{
GameDispatcher.Instance.Dispatch(GameMsg.resurgence_close);
CtrlCloseUI();
});
HallManager.Instance.UpdateSecondEvent += updateWatchCD;
// updateWatchCD();
// checkBtnState();
}
void updateWatchCD()
{
ui.text_time.text = CommonHelper.TimeFormat((int)SaveData.GetSaveObject().addview_off_time - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
broadtime++;
BroadCast();
}
public void SetTextString()
{
// var need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.buy_one_off));
// var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
//
// ui.tips.SetVar("num", need.ToString()).FlushVars();
// ui.ads.SetVar("num", myAd.ToString()).FlushVars();
}
private int broadtime = 1;
private List<string> config_name_list = LevelAttemptsModel.config_name_list;
private List<string> config_money_list = LevelAttemptsModel.config_money_list;
private List<string[]> broad_list = new List<string[]>();
private void BroadCast()
{
if (broadtime % 3 == 0)
{
(ui.broad as com_broadcast_new).t1.Play(() =>
{
broad_list.RemoveAt(0);
int name_index = UnityEngine.Random.Range(0, config_name_list.Count);
int money_index = UnityEngine.Random.Range(0, config_money_list.Count);
broad_list.Add(new string[2] { config_name_list[name_index], config_money_list[money_index] });
for (int i = 0; i < 4; i++)
{
text_list[i].text = "Congratulations,User [color=#ad4800][size=36]" + broad_list[i][0] + "[/size][/color] !After purchasing the +1 Block Pack,play [color=#ad4800]" + broad_list[i][1] + "[/color] matcher to clear the level!";
}
});
}
}
private List<GTextField> text_list = new List<GTextField>();
private void InitBroadCast()
{
text_list.Add((ui.broad as com_broadcast_new).text_0);
text_list.Add((ui.broad as com_broadcast_new).text_1);
text_list.Add((ui.broad as com_broadcast_new).text_2);
text_list.Add((ui.broad as com_broadcast_new).text_3);
for (int i = 0; i < 4; i++)
{
int name_index = UnityEngine.Random.Range(0, config_name_list.Count);
int money_index = UnityEngine.Random.Range(0, config_money_list.Count);
broad_list.Add(new string[2] { config_name_list[name_index], config_money_list[money_index] });
text_list[i].text = "Congratulations,User [color=#ad4800][size=36]" + broad_list[i][0] + "[/size][/color] !After purchasing the +1 Block Pack,play [color=#ad4800]" + broad_list[i][1] + "[/color] matcher to clear the level!";
}
}
}
}
+244 -244
View File
@@ -1,245 +1,245 @@
using UnityEngine;
using FairyGUI;
using SGModule.Net;
using System;
using Spine.Unity;
using SGModule.NetKit;
using IgnoreOPS;
using FGUI.ZM_Common_01;
namespace BallKingdomCrush
{
public class AddviewnewUI : BaseUI
{
private AddviewnewUICtrl ctrl;
private AddviewnewModel model;
private FGUI.ZM_AddCell_12.com_addView_new ui;
private bool is_off = false;
public AddviewnewUI(AddviewnewUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.AddviewnewUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_AddCell_12";
uiInfo.assetName = "com_addView_new";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.AddviewnewModel) as AddviewnewModel;
}
private Action closeCallback;
protected override void OnClose()
{
GameHelper.showGameUI = true;
HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
closeCallback?.Invoke();
AdExchangeManager.Instance.Destroy();
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_AddCell_12.com_addView_new;
}
protected override void OnOpenBefore(object args)
{
// if (ui.btn_watch is btn_watchAd watchAdBtn)
// {
// CommonTools.GetInstance.InitAdBtnAnim(watchAdBtn.icon_Parent);
// }
// if (SaveData.GetSaveObject().addview_off_time > GameHelper.GetNowTime()) is_off = true;
ui.text_out.text = "x" + GameHelper.GetItemNumber(0);
ui.text_back.text = "x" + GameHelper.GetItemNumber(1);
ui.text_refresh.text = "x" + GameHelper.GetItemNumber(2);
ui.text_level.text = "Level " + GameHelper.GetLevel();
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_show);
ui.btn_play.SetClick(() =>
{
GameHelper.gameType = 0;
GameDispatcher.Instance.Dispatch(GameMsg.OpenGame, false);
CtrlCloseUI();
});
// ui.btn_watch.GetChild("img_saveingpot").x += 20;
// ui.btn_watch.GetChild("img_saveingpot").y -= 33;
// ad_cool_down = ConfigSystem.GetCommonConf().exchangeCD;
// btn_WatchAd = ui.btn_watch as btn_watchAd;
if (GameHelper.IsAdModelOfPay())
{
if (is_off)
{
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.buy_one_off), ui.btn_watch as btn_watchAd, () =>
{
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_click);
SetTextString();
});
ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.Start();
}
else
{
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.buy_one), ui.btn_watch as btn_watchAd, () =>
{
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_click);
SetTextString();
});
ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.Start();
}
SetTextString();
}
else
{
ui.pay_type.selectedIndex = 1;
if (is_off)
{
decimal price = (decimal)GameHelper.GetCommonModel().AddDiscount2;
ui.btn_max_pay.title = GameHelper.getPrice(price);
ui.btn_max_pay.SetClick(() =>
{
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_click);
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price * 100),
sku = PurchasingManager.GetPaySku(PayType.buy_one_off),
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
else
{
decimal price = (decimal)GameHelper.GetCommonModel().addspace2;
ui.btn_max_pay.title = GameHelper.getPrice(price);
ui.btn_max_pay.SetClick(() =>
{
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_click);
ApplePayClass maxPayData = new ApplePayClass()
{
amount = (int)Math.Round(price * 100),
sku = PurchasingManager.GetPaySku(PayType.buy_one),
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
}
InitView();
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
GameDispatcher.Instance.AddListener(GameMsg.Sheep_item_refresh, SetItemNumber);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
GameDispatcher.Instance.RemoveListener(GameMsg.Sheep_item_refresh, SetItemNumber);
}
#endregion
void SetItemNumber(object a)
{
ui.text_out.text = "x" + GameHelper.GetItemNumber(0);
ui.text_back.text = "x" + GameHelper.GetItemNumber(1);
ui.text_refresh.text = "x" + GameHelper.GetItemNumber(2);
}
void pay_success(object str)
{
string type = (string)str;
if (type == PurchasingManager.GetPaySku(PayType.buy_one) || type == PurchasingManager.GetPaySku(PayType.buy_one_off))
{
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_success);
SaveData.GetSaveObject().have_slot = true;
SaveData.SaveDataFunc();
GameDispatcher.Instance.Dispatch(GameMsg.Slot_refresh);
ui.pay_type.selectedIndex = 2;
// SkeletonAnimation addeffect = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_parent1, Fx_Type.fx_addeffect, ref closeCallback);
// addeffect.state.SetAnimation(0, "animation", true);
// SkeletonAnimation addeffect1 = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_parent2, Fx_Type.fx_addarrow, ref closeCallback);
// addeffect1.state.SetAnimation(0, "animation", true);
// CtrlCloseUI();
}
}
//初始化页面逻辑
private void InitView()
{
var tAnimation = FXManager.Instance.SetFx<SkeletonAnimation>(ui.btn_up.ani_node, Fx_Type.fx_powerup, ref closeCallback);
tAnimation.state.SetAnimation(0, "animation", true);
ui.btn_close.SetClick(() =>
{
GameDispatcher.Instance.Dispatch(GameMsg.OpenGame);
CtrlCloseUI();
});
HallManager.Instance.UpdateSecondEvent += updateWatchCD;
ui.btn_addback.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SheepwindowUI_Open, 1);
});
ui.btn_addout.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SheepwindowUI_Open, 0);
});
ui.btn_addrefresh.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SheepwindowUI_Open, 2);
});
// updateWatchCD();
// checkBtnState();
}
void updateWatchCD()
{
}
public void SetTextString()
{
int need = 0;
if (is_off) need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.buy_one_off));
else need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.buy_one));
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
// ui.tips.SetVar("num", need.ToString()).FlushVars();
ui.ads.SetVar("num", myAd + "/").FlushVars();
ui.ads.SetVar("num1", need.ToString()).FlushVars();
}
}
using UnityEngine;
using FairyGUI;
using SGModule.Net;
using System;
using Spine.Unity;
using SGModule.NetKit;
using IgnoreOPS;
using FGUI.ZM_Common_01;
namespace BallKingdomCrush
{
public class AddviewnewUI : BaseUI
{
private AddviewnewUICtrl ctrl;
private AddviewnewModel model;
private FGUI.ZM_AddCell_12.com_addView_new ui;
private bool is_off = false;
public AddviewnewUI(AddviewnewUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.AddviewnewUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_AddCell_12";
uiInfo.assetName = "com_addView_new";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.AddviewnewModel) as AddviewnewModel;
}
private Action closeCallback;
protected override void OnClose()
{
GameHelper.showGameUI = true;
HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
closeCallback?.Invoke();
AdExchangeManager.Instance.Destroy();
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_AddCell_12.com_addView_new;
}
protected override void OnOpenBefore(object args)
{
// if (ui.btn_watch is btn_watchAd watchAdBtn)
// {
// CommonTools.GetInstance.InitAdBtnAnim(watchAdBtn.icon_Parent);
// }
// if (SaveData.GetSaveObject().addview_off_time > GameHelper.GetNowTime()) is_off = true;
ui.text_out.text = "x" + GameHelper.GetItemNumber(0);
ui.text_back.text = "x" + GameHelper.GetItemNumber(1);
ui.text_refresh.text = "x" + GameHelper.GetItemNumber(2);
ui.text_level.text = "Level " + GameHelper.GetLevel();
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_show);
ui.btn_play.SetClick(() =>
{
GameHelper.gameType = 0;
GameDispatcher.Instance.Dispatch(GameMsg.OpenGame, false);
CtrlCloseUI();
});
// ui.btn_watch.GetChild("img_saveingpot").x += 20;
// ui.btn_watch.GetChild("img_saveingpot").y -= 33;
// ad_cool_down = ConfigSystem.GetCommonConf().exchangeCD;
// btn_WatchAd = ui.btn_watch as btn_watchAd;
if (GameHelper.IsAdModelOfPay())
{
if (is_off)
{
// AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.buy_one_off), ui.btn_watch as btn_watchAd, () =>
// {
// TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_click);
// SetTextString();
// });
ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.Start();
}
else
{
AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_SPACE_BONUS, ui.btn_watch as btn_watchAd, () =>
{
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_click);
SetTextString();
});
ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.Start();
}
SetTextString();
}
else
{
ui.pay_type.selectedIndex = 1;
if (is_off)
{
decimal price = (decimal)GameHelper.GetCommonModel().AddDiscount2;
ui.btn_max_pay.title = GameHelper.getPrice(price);
ui.btn_max_pay.SetClick(() =>
{
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_click);
// ApplePayClass maxPayData = new ApplePayClass
// {
// amount = (int)Math.Round(price * 100),
// sku = PurchasingManager.GetPaySku(PayType.buy_one_off),
// currency = "USD"
// };
// MaxPayManager.Instance.Buy(maxPayData);
});
}
else
{
decimal price = (decimal)GameHelper.GetCommonModel().addspace2;
ui.btn_max_pay.title = GameHelper.getPrice(price);
ui.btn_max_pay.SetClick(() =>
{
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_click);
ApplePayClass maxPayData = new ApplePayClass()
{
amount = (int)Math.Round(price * 100),
sku = IAPPayManager.PRODUCT_SPACE_BONUS,
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
}
InitView();
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
GameDispatcher.Instance.AddListener(GameMsg.Sheep_item_refresh, SetItemNumber);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
GameDispatcher.Instance.RemoveListener(GameMsg.Sheep_item_refresh, SetItemNumber);
}
#endregion
void SetItemNumber(object a)
{
ui.text_out.text = "x" + GameHelper.GetItemNumber(0);
ui.text_back.text = "x" + GameHelper.GetItemNumber(1);
ui.text_refresh.text = "x" + GameHelper.GetItemNumber(2);
}
void pay_success(object str)
{
string type = (string)str;
// if (type == IAPPayManager.PRODUCT_SPACE_BONUS || type == PurchasingManager.GetPaySku(PayType.buy_one_off))
// {
// TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.kaiju_success);
// SaveData.GetSaveObject().have_slot = true;
// SaveData.SaveDataFunc();
// GameDispatcher.Instance.Dispatch(GameMsg.Slot_refresh);
// ui.pay_type.selectedIndex = 2;
// // SkeletonAnimation addeffect = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_parent1, Fx_Type.fx_addeffect, ref closeCallback);
// // addeffect.state.SetAnimation(0, "animation", true);
// // SkeletonAnimation addeffect1 = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_parent2, Fx_Type.fx_addarrow, ref closeCallback);
// // addeffect1.state.SetAnimation(0, "animation", true);
// // CtrlCloseUI();
// }
}
//初始化页面逻辑
private void InitView()
{
var tAnimation = FXManager.Instance.SetFx<SkeletonAnimation>(ui.btn_up.ani_node, Fx_Type.fx_powerup, ref closeCallback);
tAnimation.state.SetAnimation(0, "animation", true);
ui.btn_close.SetClick(() =>
{
GameDispatcher.Instance.Dispatch(GameMsg.OpenGame);
CtrlCloseUI();
});
HallManager.Instance.UpdateSecondEvent += updateWatchCD;
ui.btn_addback.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SheepwindowUI_Open, 1);
});
ui.btn_addout.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SheepwindowUI_Open, 0);
});
ui.btn_addrefresh.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SheepwindowUI_Open, 2);
});
// updateWatchCD();
// checkBtnState();
}
void updateWatchCD()
{
}
public void SetTextString()
{
// int need = 0;
// if (is_off) need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.buy_one_off));
// else need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_SPACE_BONUS);
// var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
//
// // ui.tips.SetVar("num", need.ToString()).FlushVars();
// ui.ads.SetVar("num", myAd + "/").FlushVars();
// ui.ads.SetVar("num1", need.ToString()).FlushVars();
}
}
}
+408 -408
View File
@@ -1,409 +1,409 @@
using System.Collections.Generic;
using FairyGUI;
using DG.Tweening;
using FGUI.ZM_Common_01;
using System;
using IgnoreOPS;
using SGModule.NetKit;
using UnityEngine;
using FGUI.ZM_Pass_14;
namespace BallKingdomCrush
{
public class LuckyPackUI : BaseUI
{
private LuckyPackUICtrl ctrl;
private LuckyPackModel model;
private FGUI.LG_LuckyGift.com_lucky ui;
private List<Paidgift> list;
public LuckyPackUI(LuckyPackUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.LuckyPackUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "LG_LuckyGift";
uiInfo.assetName = "com_lucky";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.PackrewardModel) as LuckyPackModel;
}
private List<GLoader> loader_list = new List<GLoader>();
protected override void OnClose()
{
AdExchangeManager.Instance.Destroy();
GameHelper.showGameUI = true;
HallManager.Instance.UpdateSecondEvent -= RemoveAdCountDown;
GameDispatcher.Instance.Dispatch(GameMsg.pack_close);
int three_gift_got_index = SaveData.GetSaveObject().three_gift_got_index;
if (GameHelper.isAutoPop && (three_gift_got_index <= (int)rewardState.day3))
{
uiCtrlDispatcher.Dispatch(UICtrlMsg.ThreeDaysGiftUI_Open);
GameHelper.isAutoPop = false;
}
GameHelper.CallShowTurn();
foreach (var t in loader_list)
{
if (t != null && !t.isDisposed && t.texture != null)
{
t.texture = null;
}
}
loader_list.Clear();
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_LuckyGift.com_lucky;
}
protected override void OnOpenBefore(object args)
{
if (GameHelper.IsGiftSwitch())
{
ui.state.selectedIndex = 1;
}
else
{
ui.state.selectedIndex = 0;
}
ui.gold.GetChild("text_gold").text = GameHelper.Get101Str(GameHelper.GetGoldNumber());
var needScroll = false;
if (args != null) needScroll = (bool)args;
ui.type.selectedIndex = needScroll ? 1 : 0;
Debug.Log($"needScroll============={needScroll}= {ui.type.selectedIndex}");
TrackKit.SendEvent(GameHelper.getTrackEvenName(), needScroll ? ADEventTrack.Property.remove_ad_show : ADEventTrack.Property.lucky_gift_show);
list = ConfigSystem.GetConfig<Paidgift>();
if (GameHelper.IsAdModelOfPay())
{
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.pack_reward), ui.btn_buypack as btn_watchAd, SetTextString1);
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.remove_ad), ui.btn_buyremovead as btn_watchAd, SetTextString1);
}
ui.btn_go_ad.SetClick(() =>
{
ui.type.selectedIndex = 1;
});
ui.btn_go_lucky.SetClick(() =>
{
ui.type.selectedIndex = 0;
});
if (!loader_list.Contains(ui.lucky_pic.picture))
{
loader_list.Add(ui.lucky_pic.picture);
}
if (!loader_list.Contains(ui.no_ad_pic.picture))
{
loader_list.Add(ui.no_ad_pic.picture);
}
InitView();
var fileName = GameHelper.GetBackgroundName(des_key.remove_ad_gift.ToString());
var task = new List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)>();
task.Add((ui.no_ad_pic.picture, fileName, null, "Background/", FolderNames.BackgroundName));
var fileName1 = GameHelper.GetBackgroundName(des_key.pack_gift.ToString());
task.Add((ui.lucky_pic.picture, fileName1, null, "Background/", FolderNames.BackgroundName));
TextureHelper.SetImgLoaders(task);
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
Debug.Log($"pay_success type================{type}");
if (type == PurchasingManager.GetPaySku(PayType.remove_ad))
{
var gold = list[1].coins_quantity;
var start = GameHelper.GetUICenterPosition(ui.text_goldnum2);
var end = GameHelper.GetUICenterPosition((ui.gold as com_gold).img);
var rewardData = new RewardData();
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
{
startPosition = start,
endPosition = end,
};
rewardData.AddReward(rewardSingleData);
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
rewardData.AddCompleted((isScu) =>
{
DOVirtual.DelayedCall(0.5f, () =>
{
var startNum = DataMgr.Coin.Value - gold;
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f,
value => { ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); }).OnComplete(() =>
{
// 动画完成时确保最终值被正确设置
ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)DataMgr.Coin.Value);
});
});
});
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AdcomingUI_Close);
SaveData.GetSaveObject().is_get_removead = true;
SaveData.SaveDataFunc();
InitView();
}
else if (type == PurchasingManager.GetPaySku(PayType.pack_reward))
{
var start = GameHelper.GetUICenterPosition(ui.text_goldnum);
var end = GameHelper.GetUICenterPosition((ui.gold as com_gold).img);
var gold = list[0].coins_quantity;
var rewardData = new RewardData();
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
{
startPosition = start,
endPosition = end,
};
rewardData.AddReward(rewardSingleData);
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
rewardData.AddCompleted((isScu) =>
{
DOVirtual.DelayedCall(0.5f, () =>
{
var startNum = DataMgr.Coin.Value - gold;
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f,
value => { ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); }).OnComplete(() =>
{
// 动画完成时确保最终值被正确设置
ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)DataMgr.Coin.Value);
});
});
});
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
SaveData.GetSaveObject().is_get_packreward = true;
SaveData.SaveDataFunc();
InitView();
}
}
//初始化页面逻辑
private int gold_num = 300;
private int back_num = 1;
private int out_num = 1;
private int refresh_num = 1;
private void InitView()
{
gold_num = list[0].coins_quantity;
back_num = list[0].props_quantity[1];
out_num = list[0].props_quantity[0];
refresh_num = list[0].props_quantity[2];
ui.text_time.SetVar("time", ConfigSystem.GetCommonConf().RemoveADsPackDuration.ToString()).FlushVars();
ui.btn_close.SetClick(CtrlCloseUI);
ui.text_goldnum.text = "x" + GameHelper.Get101Str(gold_num);
ui.text_backnum1.text = "x" + back_num;
ui.text_outnum.text = "x" + out_num;
ui.text_refreshnum.text = "x" + refresh_num;
var buy_text = ui.btn_buypack.GetChild("title") as GTextField;
buy_text.SetVar("price", list[0].Paid_price.ToString()).FlushVars();
ui.text_goldnum2.text = "x" + GameHelper.Get101Str(list[1].coins_quantity);
var buy_text1 = ui.btn_buyremovead.GetChild("title") as GTextField;
buy_text1.SetVar("price", list[1].Paid_price.ToString()).FlushVars();
if (!GameHelper.IsAdModelOfPay())
{
ui.pay_type.selectedIndex = 1;
decimal price_pack = (decimal)list[0].Paid_price2;
ui.btn_max_pack.title = GameHelper.Get102Str(price_pack);
bool is_get = SaveData.GetSaveObject().is_get_packreward;
Debug.Log($"is_get================{is_get}");
if (is_get)
{
ui.btn_max_pack.enabled = false;
ui.btn_max_pack.title = Language.GetContent("Received");
ui.btn_max_pack.SetClick(() => { });
}
else
{
ui.btn_max_pack.enabled = true;
ui.btn_max_pack.SetClick(() =>
{
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price_pack * 100),
sku = PurchasingManager.GetPaySku(PayType.pack_reward),
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
decimal price_remove = (decimal)list[1].Paid_price2;
ui.btn_max_remove.title = GameHelper.Get102Str(price_remove);
bool is_get1 = SaveData.GetSaveObject().is_get_removead;
Debug.Log($"is_get1================{is_get1}");
if (is_get1)
{
HallManager.Instance.UpdateSecondEvent += RemoveAdCountDown;
ui.btn_max_remove.enabled = false;
ui.btn_max_remove.SetClick(() => { });
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
if (cd > 24 * 3600)
{
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
}
else
{
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
}
}
else
{
(ui.btn_max_remove as FGUI.ZM_Common_01.btn_max_buy).state.selectedIndex = 0;
ui.btn_max_remove.enabled = true;
ui.btn_max_remove.SetClick(() =>
{
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price_remove * 100),
sku = PurchasingManager.GetPaySku(PayType.remove_ad),
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
}
else
{
AdExchangeManager.Instance.Start();
SetTextString1();
bool is_get = SaveData.GetSaveObject().is_get_packreward;
Debug.Log($"is_get================{is_get}");
if (is_get)
{
(ui.btn_buypack as btn_watchAd).buy_state.selectedIndex = 1;
(ui.btn_buypack as btn_watchAd).can_buy.selectedIndex = 1;
ui.btn_buypack.title = Language.GetContent("Received");
}
ui.pay_type.selectedIndex = 0;
ui.btn_buyremovead.title = Language.GetContent("Receive_");
decimal price_remove = (decimal)list[1].Paid_price2;
bool is_get1 = SaveData.GetSaveObject().is_get_removead;
if (is_get1)
{
HallManager.Instance.UpdateSecondEvent += RemoveAdCountDown;
ui.btn_buyremovead.enabled = false;
ui.btn_buyremovead.SetClick(() => { });
var lastTimes = SaveData.GetSaveObject()._watch_ad_cd;
if (GameHelper.GetNowTime() < lastTimes)
{
}
(ui.btn_buyremovead as btn_watchAd).buy_state.selectedIndex = 1;
(ui.btn_buyremovead as btn_watchAd).can_buy.selectedIndex = 1;
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
if (cd > 24 * 3600)
{
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
}
else
{
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
}
}
}
}
private void RemoveAdCountDown()
{
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
if (cd > 0)
{
if (cd > 24 * 3600)
{
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
}
else
{
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
}
}
else
{
HallManager.Instance.UpdateSecondEvent -= RemoveAdCountDown;
SaveData.GetSaveObject().is_get_removead = false;
SaveData.GetSaveObject().remove_ad_time = 0;
InitView();
}
}
public void SetTextString1()
{
var remove_need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.remove_ad));
var pack_need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.pack_reward));
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
ui.tips1.SetVar("num", pack_need.ToString()).FlushVars();
ui.tips2.SetVar("num", remove_need.ToString()).FlushVars();
}
}
using System.Collections.Generic;
using FairyGUI;
using DG.Tweening;
using FGUI.ZM_Common_01;
using System;
using IgnoreOPS;
using SGModule.NetKit;
using UnityEngine;
using FGUI.ZM_Pass_14;
namespace BallKingdomCrush
{
public class LuckyPackUI : BaseUI
{
private LuckyPackUICtrl ctrl;
private LuckyPackModel model;
private FGUI.LG_LuckyGift.com_lucky ui;
private List<Paidgift> list;
public LuckyPackUI(LuckyPackUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.LuckyPackUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "LG_LuckyGift";
uiInfo.assetName = "com_lucky";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.PackrewardModel) as LuckyPackModel;
}
private List<GLoader> loader_list = new List<GLoader>();
protected override void OnClose()
{
AdExchangeManager.Instance.Destroy();
GameHelper.showGameUI = true;
HallManager.Instance.UpdateSecondEvent -= RemoveAdCountDown;
GameDispatcher.Instance.Dispatch(GameMsg.pack_close);
int three_gift_got_index = SaveData.GetSaveObject().three_gift_got_index;
if (GameHelper.isAutoPop && (three_gift_got_index <= (int)rewardState.day3))
{
uiCtrlDispatcher.Dispatch(UICtrlMsg.ThreeDaysGiftUI_Open);
GameHelper.isAutoPop = false;
}
GameHelper.CallShowTurn();
foreach (var t in loader_list)
{
if (t != null && !t.isDisposed && t.texture != null)
{
t.texture = null;
}
}
loader_list.Clear();
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_LuckyGift.com_lucky;
}
protected override void OnOpenBefore(object args)
{
if (GameHelper.IsGiftSwitch())
{
ui.state.selectedIndex = 1;
}
else
{
ui.state.selectedIndex = 0;
}
ui.gold.GetChild("text_gold").text = GameHelper.Get101Str(GameHelper.GetGoldNumber());
var needScroll = false;
if (args != null) needScroll = (bool)args;
ui.type.selectedIndex = needScroll ? 1 : 0;
Debug.Log($"needScroll============={needScroll}= {ui.type.selectedIndex}");
TrackKit.SendEvent(GameHelper.getTrackEvenName(), needScroll ? ADEventTrack.Property.remove_ad_show : ADEventTrack.Property.lucky_gift_show);
list = ConfigSystem.GetConfig<Paidgift>();
if (GameHelper.IsAdModelOfPay())
{
AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_FIRST_GIFT, ui.btn_buypack as btn_watchAd, SetTextString1);
AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_REMOVE_ADS, ui.btn_buyremovead as btn_watchAd, SetTextString1);
}
ui.btn_go_ad.SetClick(() =>
{
ui.type.selectedIndex = 1;
});
ui.btn_go_lucky.SetClick(() =>
{
ui.type.selectedIndex = 0;
});
if (!loader_list.Contains(ui.lucky_pic.picture))
{
loader_list.Add(ui.lucky_pic.picture);
}
if (!loader_list.Contains(ui.no_ad_pic.picture))
{
loader_list.Add(ui.no_ad_pic.picture);
}
InitView();
var fileName = GameHelper.GetBackgroundName(des_key.remove_ad_gift.ToString());
var task = new List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)>();
task.Add((ui.no_ad_pic.picture, fileName, null, "Background/", FolderNames.BackgroundName));
var fileName1 = GameHelper.GetBackgroundName(des_key.pack_gift.ToString());
task.Add((ui.lucky_pic.picture, fileName1, null, "Background/", FolderNames.BackgroundName));
TextureHelper.SetImgLoaders(task);
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
Debug.Log($"pay_success type================{type}");
if (type == IAPPayManager.PRODUCT_REMOVE_ADS)
{
var gold = list[1].coins_quantity;
var start = GameHelper.GetUICenterPosition(ui.text_goldnum2);
var end = GameHelper.GetUICenterPosition((ui.gold as com_gold).img);
var rewardData = new RewardData();
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
{
startPosition = start,
endPosition = end,
};
rewardData.AddReward(rewardSingleData);
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
rewardData.AddCompleted((isScu) =>
{
DOVirtual.DelayedCall(0.5f, () =>
{
var startNum = DataMgr.Coin.Value - gold;
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f,
value => { ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); }).OnComplete(() =>
{
// 动画完成时确保最终值被正确设置
ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)DataMgr.Coin.Value);
});
});
});
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.AdcomingUI_Close);
SaveData.GetSaveObject().is_get_removead = true;
SaveData.SaveDataFunc();
InitView();
}
else if (type == IAPPayManager.PRODUCT_FIRST_GIFT)
{
var start = GameHelper.GetUICenterPosition(ui.text_goldnum);
var end = GameHelper.GetUICenterPosition((ui.gold as com_gold).img);
var gold = list[0].coins_quantity;
var rewardData = new RewardData();
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
{
startPosition = start,
endPosition = end,
};
rewardData.AddReward(rewardSingleData);
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
rewardData.AddCompleted((isScu) =>
{
DOVirtual.DelayedCall(0.5f, () =>
{
var startNum = DataMgr.Coin.Value - gold;
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 1f,
value => { ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); }).OnComplete(() =>
{
// 动画完成时确保最终值被正确设置
ui.gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)DataMgr.Coin.Value);
});
});
});
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
SaveData.GetSaveObject().is_get_packreward = true;
SaveData.SaveDataFunc();
InitView();
}
}
//初始化页面逻辑
private int gold_num = 300;
private int back_num = 1;
private int out_num = 1;
private int refresh_num = 1;
private void InitView()
{
gold_num = list[0].coins_quantity;
back_num = list[0].props_quantity[1];
out_num = list[0].props_quantity[0];
refresh_num = list[0].props_quantity[2];
ui.text_time.SetVar("time", ConfigSystem.GetCommonConf().RemoveADsPackDuration.ToString()).FlushVars();
ui.btn_close.SetClick(CtrlCloseUI);
ui.text_goldnum.text = "x" + GameHelper.Get101Str(gold_num);
ui.text_backnum1.text = "x" + back_num;
ui.text_outnum.text = "x" + out_num;
ui.text_refreshnum.text = "x" + refresh_num;
var buy_text = ui.btn_buypack.GetChild("title") as GTextField;
buy_text.SetVar("price", list[0].Paid_price.ToString()).FlushVars();
ui.text_goldnum2.text = "x" + GameHelper.Get101Str(list[1].coins_quantity);
var buy_text1 = ui.btn_buyremovead.GetChild("title") as GTextField;
buy_text1.SetVar("price", list[1].Paid_price.ToString()).FlushVars();
if (!GameHelper.IsAdModelOfPay())
{
ui.pay_type.selectedIndex = 1;
decimal price_pack = (decimal)list[0].Paid_price2;
ui.btn_max_pack.title = GameHelper.Get102Str(price_pack);
bool is_get = SaveData.GetSaveObject().is_get_packreward;
Debug.Log($"is_get================{is_get}");
if (is_get)
{
ui.btn_max_pack.enabled = false;
ui.btn_max_pack.title = Language.GetContent("Received");
ui.btn_max_pack.SetClick(() => { });
}
else
{
ui.btn_max_pack.enabled = true;
ui.btn_max_pack.SetClick(() =>
{
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price_pack * 100),
sku = IAPPayManager.PRODUCT_FIRST_GIFT,
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
decimal price_remove = (decimal)list[1].Paid_price2;
ui.btn_max_remove.title = GameHelper.Get102Str(price_remove);
bool is_get1 = SaveData.GetSaveObject().is_get_removead;
Debug.Log($"is_get1================{is_get1}");
if (is_get1)
{
HallManager.Instance.UpdateSecondEvent += RemoveAdCountDown;
ui.btn_max_remove.enabled = false;
ui.btn_max_remove.SetClick(() => { });
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
if (cd > 24 * 3600)
{
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
}
else
{
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
}
}
else
{
(ui.btn_max_remove as FGUI.ZM_Common_01.btn_max_buy).state.selectedIndex = 0;
ui.btn_max_remove.enabled = true;
ui.btn_max_remove.SetClick(() =>
{
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price_remove * 100),
sku = IAPPayManager.PRODUCT_REMOVE_ADS,
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
}
else
{
AdExchangeManager.Instance.Start();
SetTextString1();
bool is_get = SaveData.GetSaveObject().is_get_packreward;
Debug.Log($"is_get================{is_get}");
if (is_get)
{
(ui.btn_buypack as btn_watchAd).buy_state.selectedIndex = 1;
(ui.btn_buypack as btn_watchAd).can_buy.selectedIndex = 1;
ui.btn_buypack.title = Language.GetContent("Received");
}
ui.pay_type.selectedIndex = 0;
ui.btn_buyremovead.title = Language.GetContent("Receive_");
decimal price_remove = (decimal)list[1].Paid_price2;
bool is_get1 = SaveData.GetSaveObject().is_get_removead;
if (is_get1)
{
HallManager.Instance.UpdateSecondEvent += RemoveAdCountDown;
ui.btn_buyremovead.enabled = false;
ui.btn_buyremovead.SetClick(() => { });
var lastTimes = SaveData.GetSaveObject()._watch_ad_cd;
if (GameHelper.GetNowTime() < lastTimes)
{
}
(ui.btn_buyremovead as btn_watchAd).buy_state.selectedIndex = 1;
(ui.btn_buyremovead as btn_watchAd).can_buy.selectedIndex = 1;
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
if (cd > 24 * 3600)
{
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
}
else
{
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
}
}
}
}
private void RemoveAdCountDown()
{
int cd = SaveData.GetSaveObject().remove_ad_time - Convert.ToInt32(GameHelper.GetNowTime());
if (cd > 0)
{
if (cd > 24 * 3600)
{
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Day, "D");
}
else
{
ui.btn_max_remove.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
ui.btn_buyremovead.title = CommonHelper.TimeFormat(cd, CountDownType.Hour);
}
}
else
{
HallManager.Instance.UpdateSecondEvent -= RemoveAdCountDown;
SaveData.GetSaveObject().is_get_removead = false;
SaveData.GetSaveObject().remove_ad_time = 0;
InitView();
}
}
public void SetTextString1()
{
var remove_need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_REMOVE_ADS);
var pack_need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_FIRST_GIFT);
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
ui.tips1.SetVar("num", pack_need.ToString()).FlushVars();
ui.tips2.SetVar("num", remove_need.ToString()).FlushVars();
}
}
}
File diff suppressed because it is too large Load Diff
+164 -164
View File
@@ -1,165 +1,165 @@
using System;
using System.Collections.Generic;
using FairyGUI;
using FGUI.ZM_Common_01;
using IgnoreOPS;
using SGModule.NetKit;
namespace BallKingdomCrush
{
public class PassunlockUI : BaseUI
{
private PassunlockUICtrl ctrl;
private PassunlockModel model;
private FGUI.ZM_Pass_14.com_passunlock ui;
public btn_watchAd btn_WatchAd;
public PassunlockUI(PassunlockUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.PassunlockUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_Pass_14";
uiInfo.assetName = "com_passunlock";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.PassunlockModel) as PassunlockModel;
}
protected override void OnClose()
{
AdExchangeManager.Instance.Destroy();
GameHelper.CallShowTurn();
if (_loader != null && !_loader.isDisposed && _loader.texture != null)
{
_loader.texture = null;
}
_loader = null;
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_Pass_14.com_passunlock;
}
private GLoader _loader = new GLoader();
protected override void OnOpenBefore(object args)
{
_loader = ui.loader.picture;
if (GameHelper.IsAdModelOfPay()) {
ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.SetWatchAd(PurchasingManager.GetPaySku(PayType.battle_pass), ui.btn_buypass as btn_watchAd,SetTextString);
AdExchangeManager.Instance.Start();
SetTextString();
} else {
ui.pay_type.selectedIndex = 1;
decimal price = (decimal)GameHelper.GetCommonModel().Passportgift2;
ui.btn_max_pay.title = GameHelper.Get102Str(price);
ui.btn_max_pay.SetClick(() => {
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price * 100),
sku = PurchasingManager.GetPaySku(PayType.battle_pass),
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
InitView();
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.master_pass_show);
if (GameHelper.IsGiftSwitch())
{
ui.state.selectedIndex = 1;
var fileName = GameHelper.GetBackgroundName(des_key.pass_gift.ToString());
TextureHelper.SetImgLoader(ui.loader.picture, fileName, null, "Background/", FolderNames.BackgroundName);
}
else
{
ui.state.selectedIndex = 0;
}
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
string purch_number = "";
if (type == PurchasingManager.GetPaySku(PayType.battle_pass))
{
CtrlCloseUI();
}
// if (purch_number != "")
// {
// GameHelper.SendRevenueToAF(purch_number);
// }
}
//初始化页面逻辑
private void InitView()
{
ui.btn_close.SetClick(CtrlCloseUI);
int gold = 0;
List<Passportrewards> Passportrewards_list = ConfigSystem.GetConfig<Passportrewards>();
for (int i = 0; i < Passportrewards_list.Count; i++)
{
if (Passportrewards_list[i].Paid_rewards_type == 0) gold += Passportrewards_list[i].Paid_rewards_num;
}
ui.text_allgold.text = GameHelper.Get101Str(gold);
}
public void SetTextString()
{
var need = AdExchangeManager.Instance.GetCeilingNeedAds(PurchasingManager.GetPaySku(PayType.battle_pass));
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.tips.SetVar("num", need.ToString()).FlushVars();
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
}
}
using System;
using System.Collections.Generic;
using FairyGUI;
using FGUI.ZM_Common_01;
using IgnoreOPS;
using SGModule.NetKit;
namespace BallKingdomCrush
{
public class PassunlockUI : BaseUI
{
private PassunlockUICtrl ctrl;
private PassunlockModel model;
private FGUI.ZM_Pass_14.com_passunlock ui;
public btn_watchAd btn_WatchAd;
public PassunlockUI(PassunlockUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.PassunlockUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_Pass_14";
uiInfo.assetName = "com_passunlock";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.PassunlockModel) as PassunlockModel;
}
protected override void OnClose()
{
AdExchangeManager.Instance.Destroy();
GameHelper.CallShowTurn();
if (_loader != null && !_loader.isDisposed && _loader.texture != null)
{
_loader.texture = null;
}
_loader = null;
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_Pass_14.com_passunlock;
}
private GLoader _loader = new GLoader();
protected override void OnOpenBefore(object args)
{
_loader = ui.loader.picture;
if (GameHelper.IsAdModelOfPay()) {
ui.pay_type.selectedIndex = 0;
AdExchangeManager.Instance.SetWatchAd(IAPPayManager.PRODUCT_PASS_BONUS, ui.btn_buypass as btn_watchAd,SetTextString);
AdExchangeManager.Instance.Start();
SetTextString();
} else {
ui.pay_type.selectedIndex = 1;
decimal price = (decimal)GameHelper.GetCommonModel().Passportgift2;
ui.btn_max_pay.title = GameHelper.Get102Str(price);
ui.btn_max_pay.SetClick(() => {
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(price * 100),
sku = IAPPayManager.PRODUCT_PASS_BONUS,
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
InitView();
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.master_pass_show);
if (GameHelper.IsGiftSwitch())
{
ui.state.selectedIndex = 1;
var fileName = GameHelper.GetBackgroundName(des_key.pass_gift.ToString());
TextureHelper.SetImgLoader(ui.loader.picture, fileName, null, "Background/", FolderNames.BackgroundName);
}
else
{
ui.state.selectedIndex = 0;
}
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
string purch_number = "";
if (type == IAPPayManager.PRODUCT_PASS_BONUS)
{
CtrlCloseUI();
}
// if (purch_number != "")
// {
// GameHelper.SendRevenueToAF(purch_number);
// }
}
//初始化页面逻辑
private void InitView()
{
ui.btn_close.SetClick(CtrlCloseUI);
int gold = 0;
List<Passportrewards> Passportrewards_list = ConfigSystem.GetConfig<Passportrewards>();
for (int i = 0; i < Passportrewards_list.Count; i++)
{
if (Passportrewards_list[i].Paid_rewards_type == 0) gold += Passportrewards_list[i].Paid_rewards_num;
}
ui.text_allgold.text = GameHelper.Get101Str(gold);
}
public void SetTextString()
{
var need = AdExchangeManager.Instance.GetCeilingNeedAds(IAPPayManager.PRODUCT_PASS_BONUS);
var myAd = AdExchangeManager.Instance.GetLookRewardADNum();
ui.tips.SetVar("num", need.ToString()).FlushVars();
ui.ads.SetVar("num", myAd.ToString()).FlushVars();
}
}
}
+327 -341
View File
@@ -1,342 +1,328 @@
using System.Collections.Generic;
using System.Globalization;
using AppsFlyerSDK;
using FairyGUI;
using IgnoreOPS;
using SGModule.Common.Extensions;
using SGModule.Net;
using SGModule.NetKit;
using UnityEngine;
namespace BallKingdomCrush
{
public class RainPlayUICtrl : BaseUICtrl
{
private RainPlayUI ui;
private RainPlayModel model;
private uint openUIMsg = UICtrlMsg.RainPlayUI_Open;
private uint closeUIMsg = UICtrlMsg.RainPlayUI_Close;
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.RainPlayModel) as RainPlayModel;
}
protected override void OnDispose()
{
}
public override void OpenUI(object args = null)
{
if (ui == null)
{
ui = new RainPlayUI(this);
ui.Open(args);
}
}
public override void CloseUI(object args = null)
{
if (ui != null && !ui.isClose)
{
ui.Close();
}
ui = null;
}
#endregion
#region
public override uint GetOpenUIMsg(string uiName)
{
return openUIMsg;
}
public override uint GetCloseUIMsg(string uiName)
{
return closeUIMsg;
}
protected override void AddListener()
{
uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
}
protected override void RemoveListener()
{
uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI);
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
}
protected override void AddServerListener()
{
}
protected override void RemoveServerListener()
{
}
private bool CheckIsOpen(string name)
{
var isOpen = UIManager.Instance.IsExistUI(name);
return isOpen;
}
private void GetPayReward(decimal goldNum)
{
if (goldNum == 0) return;
if (ui == null)
{
DataMgr.Coin.Value += goldNum.As<int>();
return;
}
GImage endObj = ui.getCoinPosition();
var start = new Vector2(540, 960);
var end = GameHelper.GetUICenterPosition(endObj);
var rewardData = new RewardData();
var rewardSingleData = new RewardSingleData(101, goldNum, RewardOrigin.AdTask)
{
startPosition = start,
endPosition = end,
};
rewardData.AddReward(rewardSingleData);
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
}
void pay_success(object str)
{
string type = (string)str;
bool is_secret_albnums = false;
string purch_number = "";
if (type.Contains("buy_gold"))
{
if (type.StartsWith("buy_gold"))
{
int startIndex = "buy_gold".Length;
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffix_num = int.Parse(suffix);
purch_number = ConfigSystem.GetConfig<Paidcoins>()[suffix_num].Payment_amount2.ToString();
if (!UIManager.Instance.IsExistUI(UIConst.BuygoldUI))
{
List<Paidcoins> list = ConfigSystem.GetConfig<Paidcoins>();
// GameHelper.AddGoldNumber(list[suffix_num].Actual_coins);
int gold_num = list[suffix_num].Actual_coins;
GetPayReward(gold_num);
SaveData.GetSaveObject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
SaveData.SaveDataFunc();
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
}
}
}
else if (type == PurchasingManager.GetPaySku(PayType.battle_pass))
{
SaveData.GetSaveObject().is_get_battlepass = true;
int gold = 0;
int out_ = 0;
int back_ = 0;
int refresh_ = 0;
List<Passportrewards> Passportrewards_list = ConfigSystem.GetConfig<Passportrewards>();
for (int i = 0; i < Passportrewards_list.Count; i++)
{
if (GameHelper.GetBattleLv() > i|| (GameHelper.GetGameExp() >= Passportrewards_list[Passportrewards_list.Count-1].Eliminating_quantity))
{
if (Passportrewards_list[i].Paid_rewards_type == 0) gold += Passportrewards_list[i].Paid_rewards_num;
else if (Passportrewards_list[i].Paid_rewards_type == 1) out_ += Passportrewards_list[i].Paid_rewards_num;
else if (Passportrewards_list[i].Paid_rewards_type == 2) back_ += Passportrewards_list[i].Paid_rewards_num;
else if (Passportrewards_list[i].Paid_rewards_type == 3) refresh_ += Passportrewards_list[i].Paid_rewards_num;
SaveData.GetSaveObject().battle_pass_paylist.Add(i + 1);
}
else break;
}
GameHelper.AddItemNumber(0, out_);
GameHelper.AddItemNumber(1, back_);
GameHelper.AddItemNumber(2, refresh_);
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
SaveData.SaveDataFunc();
purch_number = ConfigSystem.GetCommonConf().Passportgift2.ToString();
if (!CheckIsOpen(UIConst.PassViewUI))
{
// DataMgr.Coin.Value += gold;
GetPayReward(gold);
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
}
}
else if (type == PurchasingManager.GetPaySku(PayType.buy_one))
{
SaveData.GetSaveObject().have_slot = true;
SaveData.SaveDataFunc();
GameDispatcher.Instance.Dispatch(GameMsg.Slot_refresh);
GameHelper.ShowTips("purchase_succ", true);
purch_number = GameHelper.GetCommonModel().addspace2.ToString();
}
else if (type == PurchasingManager.GetPaySku(PayType.remove_ad))
{
SaveData.GetSaveObject().remove_ad_time = (int)GameHelper.GetNowTime() + ConfigSystem.GetCommonConf().RemoveADsPackDuration * 3600;
SaveData.GetSaveObject().is_get_removead = true;
SaveData.SaveDataFunc();
// GameHelper.AddGoldNumber(ConfigSystem.GetConfig<Paidgift>()[1].coins_quantity);
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
ui?.setBtnAds();
GameDispatcher.Instance.Dispatch(GameMsg.UpdateNoads);
GameHelper.ShowTips("purchase_succ", true);
purch_number = ConfigSystem.GetConfig<Paidgift>()[1].Paid_price2.ToString();
if (!CheckIsOpen(UIConst.LuckyPackUI))
{
// DataMgr.Coin.Value += ConfigSystem.GetConfig<Paidgift>()[1].coins_quantity;
int gold_num = ConfigSystem.GetConfig<Paidgift>()[1].coins_quantity;
GetPayReward(gold_num);
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
}
}
else if (type == PurchasingManager.GetPaySku(PayType.pack_reward))
{
List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
int gold_num = list[0].coins_quantity;
int back_num = list[0].props_quantity[1];
int out_num = list[0].props_quantity[0];
int refresh_num = list[0].props_quantity[2];
Debug.Log($"[PayType.pack_reward 1] gold_num==={gold_num}==={out_num}==={back_num}==={refresh_num}");
GameHelper.AddItemNumber(0, out_num);
GameHelper.AddItemNumber(1, back_num);
GameHelper.AddItemNumber(2, refresh_num);
SaveData.GetSaveObject().is_get_packreward = true;
SaveData.SaveDataFunc();
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
ui?.setBtnAds();
GameDispatcher.Instance.Dispatch(GameMsg.UpdateNoads);
GameHelper.ShowTips("purchase_succ", true);
purch_number = ConfigSystem.GetConfig<Paidgift>()[0].Paid_price2.ToString();
if (!CheckIsOpen(UIConst.LuckyPackUI))
{
// DataMgr.Coin.Value += gold_num;
Debug.Log($"[PayType.pack_reward 2] gold_num==={gold_num}==={out_num}==={back_num}==={refresh_num}");
GetPayReward(gold_num);
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
}
}
else if (type == PurchasingManager.GetPaySku(PayType.fail_pack))
{
List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
purch_number = ConfigSystem.GetConfig<Paidgift>()[2].Paid_price2.ToString();
//ui?.setBtnAds();
GameDispatcher.Instance.Dispatch(GameMsg.resurgence);
// DataMgr.Coin.Value += ConfigSystem.GetConfig<Paidgift>()[1].coins_quantity;
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
int back_num = list[2].props_quantity[1];
int out_num = list[2].props_quantity[0];
int refresh_num = list[2].props_quantity[2];
//GameHelper.addGoldNumber(gold_num);
int gold_num = list[2].coins_quantity;
if (!UIManager.Instance.IsExistUI(UIConst.ResurgenceUI)) DataMgr.Coin.Value += gold_num;
GameHelper.AddItemNumber(0, out_num);
GameHelper.AddItemNumber(1, back_num);
GameHelper.AddItemNumber(2, refresh_num);
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
SaveData.SaveDataFunc();
}
else if (type == PurchasingManager.GetPaySku(PayType.three_days_gift))
{
SaveData.GetSaveObject().is_get_ThreeDaysGift = true;
SaveData.SaveDataFunc();
purch_number = ConfigSystem.GetConfig<Multigift>()[0].Paid_price2.ToString();
}
else if (type.StartsWith("vip_club"))
{
int startIndex = "vip_club".Length;
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffixNum = int.Parse(suffix);
if (!MaxPayManager.isOfficialPay)
{
var days = 0;
switch (suffixNum)
{
case 0:
days = (int)VipDay.Week;
break;
case 1:
days = (int)VipDay.Month;
break;
case 2:
days = (int)VipDay.Year;
break;
}
if (days > 0)
{
// 设置 VIP 到期时间(当前时间戳 + VIP 天数对应的秒数)
DataMgr.VipExpirationTime.Value =
ServerClock.GetCurrentServerTime() + days * 24 * 60 * 60;
}
DataMgr.VipLevel.Value = suffixNum + 1;
}
GameDispatcher.Instance.Dispatch(GameMsg.BuyVip);
purch_number = ConfigSystem.GetConfig<VipClub>()[suffixNum].DiscountPrice.ToString();
}
else if (type.StartsWith("secret_albnums"))
{
is_secret_albnums = true;
int startIndex = "secret_albnums".Length;
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffix_num = int.Parse(suffix);
var model = ConfigSystem.GetConfig<SecretAlbums>()[suffix_num];
if (model.PayType == (int)UnlockPayType.Pay)
{
purch_number = ConfigSystem.GetConfig<SecretAlbums>()[suffix_num].DiscountPrice.ToString();
}
}
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
if ((!GameHelper.IsAdModelOfPay() || is_secret_albnums) && !string.IsNullOrEmpty(purch_number) && decimal.TryParse(purch_number, out decimal revenue))
{
var payType = MaxPayManager.isOfficialPay ? 0 : 1;
// 付费上报BI
BIManager.Instance.TrackPurchase(purch_number.As<double>(), "USD", payType.ToString(), type, "paid");
Debug.Log("付费收益上报AF----------- " + revenue);
adCallbackInfo.Clear();
adCallbackInfo.Add("appsflyer_id", AppsFlyer.getAppsFlyerId());
adCallbackInfo.Add("customer_user_id", GameHelper.GetLoginModel().Uid.ToString());
adCallbackInfo.Add("af_currency", "USD");
adCallbackInfo.Add("af_revenue", revenue.ToString(CultureInfo.InvariantCulture));
AppsFlyer.sendEvent("af_purchase", adCallbackInfo);
FireBaseManger.OnPayRevenueEvent(purch_number.As<double>());
TrackKit.SendEvent(AfPurchaseTrack.Event, AfPurchaseTrack.Property.af_revenue,(int)(purch_number.As<decimal>() * 10000));
}
}
#endregion
public static Dictionary<string, string> adCallbackInfo = new Dictionary<string, string>();
}
using System.Collections.Generic;
using System.Globalization;
using AppsFlyerSDK;
using FairyGUI;
using IgnoreOPS;
using SGModule.Common.Extensions;
using SGModule.Net;
using SGModule.NetKit;
using UnityEngine;
namespace BallKingdomCrush
{
public class RainPlayUICtrl : BaseUICtrl
{
private RainPlayUI ui;
private RainPlayModel model;
private uint openUIMsg = UICtrlMsg.RainPlayUI_Open;
private uint closeUIMsg = UICtrlMsg.RainPlayUI_Close;
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.RainPlayModel) as RainPlayModel;
}
protected override void OnDispose()
{
}
public override void OpenUI(object args = null)
{
if (ui == null)
{
ui = new RainPlayUI(this);
ui.Open(args);
}
}
public override void CloseUI(object args = null)
{
if (ui != null && !ui.isClose)
{
ui.Close();
}
ui = null;
}
#endregion
#region
public override uint GetOpenUIMsg(string uiName)
{
return openUIMsg;
}
public override uint GetCloseUIMsg(string uiName)
{
return closeUIMsg;
}
protected override void AddListener()
{
uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
protected override void RemoveListener()
{
uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI);
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
protected override void AddServerListener()
{
}
protected override void RemoveServerListener()
{
}
private bool CheckIsOpen(string name)
{
var isOpen = UIManager.Instance.IsExistUI(name);
return isOpen;
}
private void GetPayReward(decimal goldNum)
{
if (goldNum == 0) return;
if (ui == null)
{
DataMgr.Coin.Value += goldNum.As<int>();
return;
}
GImage endObj = ui.getCoinPosition();
var start = new Vector2(540, 960);
var end = GameHelper.GetUICenterPosition(endObj);
var rewardData = new RewardData();
var rewardSingleData = new RewardSingleData(101, goldNum, RewardOrigin.AdTask)
{
startPosition = start,
endPosition = end,
};
rewardData.AddReward(rewardSingleData);
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
}
void pay_success(object str)
{
string type = (string)str;
bool is_secret_albnums = false;
string purch_number = "";
if (PurchasingManager._shopProductMap.TryGetValue(type, out var shopId))
{
int suffix_num = int.Parse(shopId);
purch_number = ConfigSystem.GetConfig<Paidcoins>()[suffix_num].Payment_amount2.ToString();
if (!UIManager.Instance.IsExistUI(UIConst.BuygoldUI))
{
List<Paidcoins> list = ConfigSystem.GetConfig<Paidcoins>();
// GameHelper.AddGoldNumber(list[suffix_num].Actual_coins);
int gold_num = list[suffix_num].Actual_coins;
GetPayReward(gold_num);
SaveData.GetSaveObject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
SaveData.SaveDataFunc();
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
}
}
else if (type == IAPPayManager.PRODUCT_PASS_BONUS)
{
SaveData.GetSaveObject().is_get_battlepass = true;
int gold = 0;
int out_ = 0;
int back_ = 0;
int refresh_ = 0;
List<Passportrewards> Passportrewards_list = ConfigSystem.GetConfig<Passportrewards>();
for (int i = 0; i < Passportrewards_list.Count; i++)
{
if (GameHelper.GetBattleLv() > i|| (GameHelper.GetGameExp() >= Passportrewards_list[Passportrewards_list.Count-1].Eliminating_quantity))
{
if (Passportrewards_list[i].Paid_rewards_type == 0) gold += Passportrewards_list[i].Paid_rewards_num;
else if (Passportrewards_list[i].Paid_rewards_type == 1) out_ += Passportrewards_list[i].Paid_rewards_num;
else if (Passportrewards_list[i].Paid_rewards_type == 2) back_ += Passportrewards_list[i].Paid_rewards_num;
else if (Passportrewards_list[i].Paid_rewards_type == 3) refresh_ += Passportrewards_list[i].Paid_rewards_num;
SaveData.GetSaveObject().battle_pass_paylist.Add(i + 1);
}
else break;
}
GameHelper.AddItemNumber(0, out_);
GameHelper.AddItemNumber(1, back_);
GameHelper.AddItemNumber(2, refresh_);
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
SaveData.SaveDataFunc();
purch_number = ConfigSystem.GetCommonConf().Passportgift2.ToString();
if (!CheckIsOpen(UIConst.PassViewUI))
{
// DataMgr.Coin.Value += gold;
GetPayReward(gold);
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
}
}
else if (type == IAPPayManager.PRODUCT_SPACE_BONUS)
{
SaveData.GetSaveObject().have_slot = true;
SaveData.SaveDataFunc();
GameDispatcher.Instance.Dispatch(GameMsg.Slot_refresh);
GameHelper.ShowTips("purchase_succ", true);
purch_number = GameHelper.GetCommonModel().addspace2.ToString();
}
else if (type == IAPPayManager.PRODUCT_REMOVE_ADS)
{
SaveData.GetSaveObject().remove_ad_time = (int)GameHelper.GetNowTime() + ConfigSystem.GetCommonConf().RemoveADsPackDuration * 3600;
SaveData.GetSaveObject().is_get_removead = true;
SaveData.SaveDataFunc();
// GameHelper.AddGoldNumber(ConfigSystem.GetConfig<Paidgift>()[1].coins_quantity);
// GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
ui?.setBtnAds();
GameDispatcher.Instance.Dispatch(GameMsg.UpdateNoads);
GameHelper.ShowTips("purchase_succ", true);
purch_number = ConfigSystem.GetConfig<Paidgift>()[1].Paid_price2.ToString();
if (!CheckIsOpen(UIConst.LuckyPackUI))
{
// DataMgr.Coin.Value += ConfigSystem.GetConfig<Paidgift>()[1].coins_quantity;
int gold_num = ConfigSystem.GetConfig<Paidgift>()[1].coins_quantity;
GetPayReward(gold_num);
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
}
}
else if (type == IAPPayManager.PRODUCT_FIRST_GIFT)
{
List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
int gold_num = list[0].coins_quantity;
int back_num = list[0].props_quantity[1];
int out_num = list[0].props_quantity[0];
int refresh_num = list[0].props_quantity[2];
Debug.Log($"[PayType.pack_reward 1] gold_num==={gold_num}==={out_num}==={back_num}==={refresh_num}");
GameHelper.AddItemNumber(0, out_num);
GameHelper.AddItemNumber(1, back_num);
GameHelper.AddItemNumber(2, refresh_num);
SaveData.GetSaveObject().is_get_packreward = true;
SaveData.SaveDataFunc();
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
ui?.setBtnAds();
GameDispatcher.Instance.Dispatch(GameMsg.UpdateNoads);
GameHelper.ShowTips("purchase_succ", true);
purch_number = ConfigSystem.GetConfig<Paidgift>()[0].Paid_price2.ToString();
if (!CheckIsOpen(UIConst.LuckyPackUI))
{
// DataMgr.Coin.Value += gold_num;
Debug.Log($"[PayType.pack_reward 2] gold_num==={gold_num}==={out_num}==={back_num}==={refresh_num}");
GetPayReward(gold_num);
GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
}
}
// else if (type == PurchasingManager.GetPaySku(PayType.fail_pack))
// {
// List<Paidgift> list = ConfigSystem.GetConfig<Paidgift>();
// purch_number = ConfigSystem.GetConfig<Paidgift>()[2].Paid_price2.ToString();
// //ui?.setBtnAds();
// GameDispatcher.Instance.Dispatch(GameMsg.resurgence);
//
// // DataMgr.Coin.Value += ConfigSystem.GetConfig<Paidgift>()[1].coins_quantity;
// // GameDispatcher.Instance.Dispatch(GameMsg.Gold_refresh);
// int back_num = list[2].props_quantity[1];
// int out_num = list[2].props_quantity[0];
// int refresh_num = list[2].props_quantity[2];
// //GameHelper.addGoldNumber(gold_num);
// int gold_num = list[2].coins_quantity;
// if (!UIManager.Instance.IsExistUI(UIConst.ResurgenceUI)) DataMgr.Coin.Value += gold_num;
// GameHelper.AddItemNumber(0, out_num);
// GameHelper.AddItemNumber(1, back_num);
// GameHelper.AddItemNumber(2, refresh_num);
// GameDispatcher.Instance.Dispatch(GameMsg.Sheep_item_refresh);
// SaveData.SaveDataFunc();
//
// }
else if (type == IAPPayManager.PRODUCT_THREE_DAY)
{
SaveData.GetSaveObject().is_get_ThreeDaysGift = true;
SaveData.SaveDataFunc();
purch_number = ConfigSystem.GetConfig<Multigift>()[0].Paid_price2.ToString();
}
else if (PurchasingManager._vipProductMap.TryGetValue(type, out var vipIdx))
{
var suffixNum = int.Parse(vipIdx);
if (!MaxPayManager.isOfficialPay)
{
var days = suffixNum switch
{
0 => (int)VipDay.Week,
1 => (int)VipDay.Month,
2 => (int)VipDay.Year,
_ => 0
};
if (days > 0)
{
// 设置 VIP 到期时间(当前时间戳 + VIP 天数对应的秒数)
DataMgr.VipExpirationTime.Value =
ServerClock.GetCurrentServerTime() + days * 24 * 60 * 60;
}
DataMgr.VipLevel.Value = suffixNum + 1;
}
GameDispatcher.Instance.Dispatch(GameMsg.BuyVip);
purch_number = ConfigSystem.GetConfig<VipClub>()[suffixNum].DiscountPrice.ToString();
}
else if (type.StartsWith("secret_albnums"))
{
is_secret_albnums = true;
int startIndex = "secret_albnums".Length;
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffix_num = int.Parse(suffix);
var model = ConfigSystem.GetConfig<SecretAlbums>()[suffix_num];
if (model.PayType == (int)UnlockPayType.Pay)
{
purch_number = ConfigSystem.GetConfig<SecretAlbums>()[suffix_num].DiscountPrice.ToString();
}
}
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
if ((!GameHelper.IsAdModelOfPay() || is_secret_albnums) && !string.IsNullOrEmpty(purch_number) && decimal.TryParse(purch_number, out decimal revenue))
{
var payType = MaxPayManager.isOfficialPay ? 0 : 1;
// 付费上报BI
BIManager.Instance.TrackPurchase(purch_number.As<double>(), "USD", payType.ToString(), type, "paid");
Debug.Log("付费收益上报AF----------- " + revenue);
adCallbackInfo.Clear();
adCallbackInfo.Add("appsflyer_id", AppsFlyer.getAppsFlyerId());
adCallbackInfo.Add("customer_user_id", GameHelper.GetLoginModel().Uid.ToString());
adCallbackInfo.Add("af_currency", "USD");
adCallbackInfo.Add("af_revenue", revenue.ToString(CultureInfo.InvariantCulture));
AppsFlyer.sendEvent("af_purchase", adCallbackInfo);
FireBaseManger.OnPayRevenueEvent(purch_number.As<double>());
TrackKit.SendEvent(AfPurchaseTrack.Event, AfPurchaseTrack.Property.af_revenue,(int)(purch_number.As<decimal>() * 10000));
}
}
#endregion
public static Dictionary<string, string> adCallbackInfo = new Dictionary<string, string>();
}
}
@@ -1,430 +1,430 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DG.Tweening;
using FairyGUI;
using FGUI.LG_secretAlbums;
using SGModule.Common.Helper;
using SGModule.NetKit;
using UnityEngine;
namespace BallKingdomCrush
{
public class SecretAlbumsNextUI : BaseUI
{
private SecretAlbumsNextUICtrl ctrl;
private SecretAlbumsNextModel model;
private FGUI.LG_secretAlbums.com_scAlbumPreview ui;
public SecretAlbumsNextUI(SecretAlbumsNextUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.SecretAlbumsNextUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "LG_secretAlbums";
uiInfo.assetName = "com_scAlbumPreview";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.SecretAlbumsModel) as SecretAlbumsModel;
}
protected override void OnClose()
{
HallManager.Instance.UpdateSecondEvent -= UpWatchAdsBtn;
// 清理 Loader 的材质和贴图
foreach (var loader in loader_list)
{
if (loader == null || loader.isDisposed) continue;
// 释放材质到材质池
if (loader.material != null)
{
TextureHelper.CancelImageBlur(loader); // 自动返回材质池
loader.material = null;
}
// 清理 NTexture
if (loader.texture != null)
{
if (loader.texture.destroyMethod == DestroyMethod.Destroy)
loader.texture.Dispose(); // 销毁 NTexture 对象
loader.texture = null;
}
}
loader_list.Clear();
// 强制卸载未使用的资源
Resources.UnloadUnusedAssets();
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_secretAlbums.com_scAlbumPreview;
}
private AlbumPreviewData _albumPreviewData;
protected override void OnOpenBefore(object args)
{
if (args == null) return;
_albumPreviewData = (AlbumPreviewData)args;
InitView();
var event_names = ADEventTrack.Property.secret_albums_show + (_albumPreviewData.Index + 1);
var event_type = _albumPreviewData.PayType == (int)UnlockPayType.Ad ? ADEventTrack.AD_Event : ADEventTrack.MaxPayEvent;
TrackKit.SendEvent(event_type, event_names);
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, InitView);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, InitView);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
string purch_number = "";
if (type.StartsWith("secret_albnums"))
{
int startIndex = "secret_albnums".Length;
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffix_num = int.Parse(suffix);
Log.Info("Secret_pay_success", $"index================:{suffix_num}");
// 判断是否已存在,避免重复添加
if (!DataMgr.SecretUnlockList.Value.Contains(suffix_num))
{
DataMgr.SecretUnlockList.Value.Add(suffix_num);
DataMgr.SecretUnlockList.Save();
GameDispatcher.Instance.Dispatch(GameMsg.UnlockSecretSuccess);
}
GameHelper.ShowTips("purchase_succ", true);
InitView();
}
}
private List<string> _secretData;
private bool is_unlock = false; //当前专辑是否解锁
private List<GLoader> loader_list = new List<GLoader>();
//初始化页面逻辑
private void InitView(object a = null)
{
// 先清理上一次的 loader 和任务
foreach (var l in loader_list)
{
if (l != null && !l.isDisposed)
{
TextureHelper.CancelImageBlur(l); // 放回材质池
if (l.texture != null)
{
l.texture.Dispose();
l.texture = null;
}
if (l.material != null) l.material = null;
}
}
loader_list.Clear();
_tasks.Clear();
//专辑解锁状态
is_unlock = DataMgr.SecretUnlockList.Value.Contains(_albumPreviewData.Index);
UpWatchAdsBtn();
// if (_albumPreviewData.PayType == (int)UnlockPayType.Ad &&
// DataMgr.SecretUnlockCd.Value.TryGetValue(_albumPreviewData.Index, out var unlockCdValue) &&
// unlockCdValue > 0)
// {
// }
HallManager.Instance.UpdateSecondEvent += UpWatchAdsBtn;
ui.btn_close.SetClick(CtrlCloseUI);
// ui.text_original_price.text = _albumPreviewData.Price.ToString();
ui.old_price.text = GameHelper.getPrice((decimal)_albumPreviewData.Price);
ui.btn_pay.title = GameHelper.getPrice((decimal)_albumPreviewData.DiscountPrice);
_secretData = SplitStringToList(_albumPreviewData.Name2);
ui.list.itemRenderer = ItemRender;
ui.list.numItems = _secretData.Count;
ui.pay_type.selectedIndex = !is_unlock ? _albumPreviewData.PayType : (int)UnlockPayType.None;
if (is_unlock)
{
ui.pay_type.selectedIndex = (int)UnlockPayType.None;
}
else
{
if (_albumPreviewData.SubscribeUnlock == 1)
{
ui.vip.selectedIndex = 1;
if (GameHelper.GetVipLevel() >= 1)
{
ui.has_vip.selectedIndex = 1;
}
else
{
ui.has_vip.selectedIndex = 0;
}
}
else
{
ui.vip.selectedIndex = 0;
}
ui.pay_type.selectedIndex = _albumPreviewData.PayType;
}
var _type = "secret_albnums" + _albumPreviewData.Index;
ui.btn_pay.SetClick(() =>
{
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(_albumPreviewData.DiscountPrice * 100),
sku = _type,
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
ui.btn_gold.title = _albumPreviewData.GoldCoins.ToString();
ui.btn_gold.SetClick(() =>
{
if (GameHelper.Get101() >= _albumPreviewData.GoldCoins)
{
GameHelper.AddGold(-_albumPreviewData.GoldCoins);
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _type);
string eventName = ADEventTrack.Property.secret_albums_success_ + (_albumPreviewData.Index + 1);
TrackKit.SendEvent(ADEventTrack.SecretAlbums, eventName);
GameDispatcher.Instance.Dispatch(GameMsg.Update101);
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.unlock_secretAlbums_resources);
}
else
{
GameHelper.ShowTips("no_enough_gold", true);
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
}
});
var AdCount = DataMgr.SecretUnlockADs.Value.GetValueOrDefault(_albumPreviewData.Index, 0);
ui.btn_watch.ads.SetVar("ads", AdCount + "/" + _albumPreviewData.AD).FlushVars();
ui.btn_watch.SetClick(() =>
{
if (AdCount >= _albumPreviewData.AD)
{
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _type);
}
else
{
GameHelper.ShowVideoAd("UnlockSecretAlbums", (isSuccess) =>
{
if (isSuccess)
{
var adTimes = Convert.ToInt32(GameHelper.GetNowTime());
DataMgr.SecretUnlockCd.Value[_albumPreviewData.Index] = adTimes + _albumPreviewData.CD;
DataMgr.SecretUnlockCd.Save();
var currentAdCount = DataMgr.SecretUnlockADs.Value.GetValueOrDefault(_albumPreviewData.Index, 0);
DataMgr.SecretUnlockADs.Value[_albumPreviewData.Index] = currentAdCount + 1;
DataMgr.SecretUnlockADs.Save();
string eventName = ADEventTrack.Property.secret_albums_success_ + (_albumPreviewData.Index + 1);
TrackKit.SendEvent(ADEventTrack.AD_Event, eventName);
InitView();
}
});
}
});
ui.btn_vip.SetClick(() =>
{
TrackKit.SendEvent(ADEventTrack.SecretAlbums, ADEventTrack.Property.secret_albums_click_ + (_albumPreviewData.Index + 1));
if (GameHelper.GetVipLevel() >= 1)
{
GameHelper.isVipUnlock = true;
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _type);
string eventName = ADEventTrack.Property.vip_secret_albums_unclock_ + (_albumPreviewData.Index + 1);
TrackKit.SendEvent(ADEventTrack.VipSecretAlbums, eventName);
}
else
{
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open, 2);
TrackKit.SendEvent(ADEventTrack.VipSecretAlbums, ADEventTrack.Property.vip_secret_albums_unclock);
}
});
}
private List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)> _tasks = new();
private void ItemRender(int index, GObject obj)
{
var item = (item_scAlbumPreview)obj;
var picture = (GLoader)item.com_pic_in.GetChild("picture");
if (!loader_list.Contains(picture))
loader_list.Add(picture);
var state = GetSafe(_albumPreviewData.State, index);
item.state.selectedIndex = is_unlock ? 0 : state;
var task = (picture, _secretData[index], (Action<NTexture>)(s =>
{
if (picture != null && !picture.isDisposed)
{
if (!is_unlock && state == 1)
TextureHelper.SetImageBlur(picture);
else
TextureHelper.CancelImageBlur(picture);
}
}), $"SecretAlbums/{_albumPreviewData.Name}/", FolderNames.SecretName);
_tasks.Add(task);
item.btn_detail.SetClick(() =>
{
if (is_unlock)
{
var data = new DetailData
{
Name = _secretData[index],
Name1 = $"SecretAlbums/{_albumPreviewData.Name}/"
};
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretDetailUI_Open, data);
}
else
{
GameHelper.ShowTips("not_unlocked", true);
}
});
if (index == _secretData.Count - 1)
{
TextureHelper.SetImgLoaders(_tasks);
}
}
private void UpWatchAdsBtn()
{
DataMgr.SecretUnlockCd.Value.TryGetValue(_albumPreviewData.Index, out var lastTimes);
if (DataMgr.SecretUnlockADs.Value.TryGetValue(_albumPreviewData.Index, out var unlockAdValue) &&
unlockAdValue >= _albumPreviewData.AD)
{
ui.btn_watch.can_buy.selectedIndex = 1;
}
else
{
ui.btn_watch.can_buy.selectedIndex = 0;
if (GameHelper.GetNowTime() < lastTimes)
{
ui.btn_watch.enabled = false;
ui.btn_watch.CD.selectedIndex = 1;
ui.btn_watch.watch_cd.text =
CommonHelper.TimeFormat(lastTimes - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
}
else
{
ui.btn_watch.enabled = true;
ui.btn_watch.CD.selectedIndex = 0;
}
}
}
// 拆分字符串为列表
public static List<string> SplitStringToList(string input)
{
if (string.IsNullOrWhiteSpace(input))
return new List<string>();
// 支持英文逗号, 中文逗号,空格
char[] separators = new char[] { ',', '', ' ' };
return input
.Split(separators, StringSplitOptions.RemoveEmptyEntries)
.Select(s => s.Trim()) // 去掉前后空白
.ToList();
}
/// <summary>
/// 安全获取列表或数组中的元素,如果越界则返回最后一个元素;如果为空则返回默认值。
/// </summary>
public static T GetSafe<T>(IList<T> list, int index, T defaultValue = default)
{
if (list == null || list.Count == 0)
return defaultValue;
if (index < 0)
return list[0];
if (index >= list.Count)
return list[list.Count - 1];
return list[index];
}
}
public class DetailData
{
public string Name;
public string Name1;
}
using System;
using System.Collections.Generic;
using System.Linq;
using DG.Tweening;
using FairyGUI;
using FGUI.LG_secretAlbums;
using SGModule.Common.Helper;
using SGModule.NetKit;
using UnityEngine;
namespace BallKingdomCrush
{
public class SecretAlbumsNextUI : BaseUI
{
private SecretAlbumsNextUICtrl ctrl;
private SecretAlbumsNextModel model;
private FGUI.LG_secretAlbums.com_scAlbumPreview ui;
public SecretAlbumsNextUI(SecretAlbumsNextUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.SecretAlbumsNextUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "LG_secretAlbums";
uiInfo.assetName = "com_scAlbumPreview";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.SecretAlbumsModel) as SecretAlbumsModel;
}
protected override void OnClose()
{
HallManager.Instance.UpdateSecondEvent -= UpWatchAdsBtn;
// 清理 Loader 的材质和贴图
foreach (var loader in loader_list)
{
if (loader == null || loader.isDisposed) continue;
// 释放材质到材质池
if (loader.material != null)
{
TextureHelper.CancelImageBlur(loader); // 自动返回材质池
loader.material = null;
}
// 清理 NTexture
if (loader.texture != null)
{
if (loader.texture.destroyMethod == DestroyMethod.Destroy)
loader.texture.Dispose(); // 销毁 NTexture 对象
loader.texture = null;
}
}
loader_list.Clear();
// 强制卸载未使用的资源
Resources.UnloadUnusedAssets();
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_secretAlbums.com_scAlbumPreview;
}
private AlbumPreviewData _albumPreviewData;
protected override void OnOpenBefore(object args)
{
if (args == null) return;
_albumPreviewData = (AlbumPreviewData)args;
InitView();
var event_names = ADEventTrack.Property.secret_albums_show + (_albumPreviewData.Index + 1);
var event_type = _albumPreviewData.PayType == (int)UnlockPayType.Ad ? ADEventTrack.AD_Event : ADEventTrack.MaxPayEvent;
TrackKit.SendEvent(event_type, event_names);
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, InitView);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, InitView);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
string purch_number = "";
if (type.StartsWith("secret_albnums"))
{
int startIndex = "secret_albnums".Length;
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffix_num = int.Parse(suffix);
Log.Info("Secret_pay_success", $"index================:{suffix_num}");
// 判断是否已存在,避免重复添加
if (!DataMgr.SecretUnlockList.Value.Contains(suffix_num))
{
DataMgr.SecretUnlockList.Value.Add(suffix_num);
DataMgr.SecretUnlockList.Save();
GameDispatcher.Instance.Dispatch(GameMsg.UnlockSecretSuccess);
}
GameHelper.ShowTips("purchase_succ", true);
InitView();
}
}
private List<string> _secretData;
private bool is_unlock = false; //当前专辑是否解锁
private List<GLoader> loader_list = new List<GLoader>();
//初始化页面逻辑
private void InitView(object a = null)
{
// 先清理上一次的 loader 和任务
foreach (var l in loader_list)
{
if (l != null && !l.isDisposed)
{
TextureHelper.CancelImageBlur(l); // 放回材质池
if (l.texture != null)
{
l.texture.Dispose();
l.texture = null;
}
if (l.material != null) l.material = null;
}
}
loader_list.Clear();
_tasks.Clear();
//专辑解锁状态
is_unlock = DataMgr.SecretUnlockList.Value.Contains(_albumPreviewData.Index);
UpWatchAdsBtn();
// if (_albumPreviewData.PayType == (int)UnlockPayType.Ad &&
// DataMgr.SecretUnlockCd.Value.TryGetValue(_albumPreviewData.Index, out var unlockCdValue) &&
// unlockCdValue > 0)
// {
// }
HallManager.Instance.UpdateSecondEvent += UpWatchAdsBtn;
ui.btn_close.SetClick(CtrlCloseUI);
// ui.text_original_price.text = _albumPreviewData.Price.ToString();
ui.old_price.text = GameHelper.getPrice((decimal)_albumPreviewData.Price);
ui.btn_pay.title = GameHelper.getPrice((decimal)_albumPreviewData.DiscountPrice);
_secretData = SplitStringToList(_albumPreviewData.Name2);
ui.list.itemRenderer = ItemRender;
ui.list.numItems = _secretData.Count;
ui.pay_type.selectedIndex = !is_unlock ? _albumPreviewData.PayType : (int)UnlockPayType.None;
if (is_unlock)
{
ui.pay_type.selectedIndex = (int)UnlockPayType.None;
}
else
{
if (_albumPreviewData.SubscribeUnlock == 1)
{
ui.vip.selectedIndex = 1;
if (GameHelper.GetVipLevel() >= 1)
{
ui.has_vip.selectedIndex = 1;
}
else
{
ui.has_vip.selectedIndex = 0;
}
}
else
{
ui.vip.selectedIndex = 0;
}
ui.pay_type.selectedIndex = _albumPreviewData.PayType;
}
var _type = "secret_albnums" + _albumPreviewData.Index;
ui.btn_pay.SetClick(() =>
{
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)Math.Round(_albumPreviewData.DiscountPrice * 100),
sku = _type,
currency = "USD"
};
MaxPayManager.Instance.Buy(maxPayData);
});
ui.btn_gold.title = _albumPreviewData.GoldCoins.ToString();
ui.btn_gold.SetClick(() =>
{
if (GameHelper.Get101() >= _albumPreviewData.GoldCoins)
{
GameHelper.AddGold(-_albumPreviewData.GoldCoins);
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, _type);
string eventName = ADEventTrack.Property.secret_albums_success_ + (_albumPreviewData.Index + 1);
TrackKit.SendEvent(ADEventTrack.SecretAlbums, eventName);
GameDispatcher.Instance.Dispatch(GameMsg.Update101);
TrackKit.SendEvent(ADEventTrack.Coinsbuy, ADEventTrack.Property.unlock_secretAlbums_resources);
}
else
{
GameHelper.ShowTips("no_enough_gold", true);
uiCtrlDispatcher.Dispatch(UICtrlMsg.BuygoldUI_Open);
}
});
var AdCount = DataMgr.SecretUnlockADs.Value.GetValueOrDefault(_albumPreviewData.Index, 0);
ui.btn_watch.ads.SetVar("ads", AdCount + "/" + _albumPreviewData.AD).FlushVars();
ui.btn_watch.SetClick(() =>
{
if (AdCount >= _albumPreviewData.AD)
{
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, _type);
}
else
{
GameHelper.ShowVideoAd("UnlockSecretAlbums", (isSuccess) =>
{
if (isSuccess)
{
var adTimes = Convert.ToInt32(GameHelper.GetNowTime());
DataMgr.SecretUnlockCd.Value[_albumPreviewData.Index] = adTimes + _albumPreviewData.CD;
DataMgr.SecretUnlockCd.Save();
var currentAdCount = DataMgr.SecretUnlockADs.Value.GetValueOrDefault(_albumPreviewData.Index, 0);
DataMgr.SecretUnlockADs.Value[_albumPreviewData.Index] = currentAdCount + 1;
DataMgr.SecretUnlockADs.Save();
string eventName = ADEventTrack.Property.secret_albums_success_ + (_albumPreviewData.Index + 1);
TrackKit.SendEvent(ADEventTrack.AD_Event, eventName);
InitView();
}
});
}
});
ui.btn_vip.SetClick(() =>
{
TrackKit.SendEvent(ADEventTrack.SecretAlbums, ADEventTrack.Property.secret_albums_click_ + (_albumPreviewData.Index + 1));
if (GameHelper.GetVipLevel() >= 1)
{
GameHelper.isVipUnlock = true;
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, _type);
string eventName = ADEventTrack.Property.vip_secret_albums_unclock_ + (_albumPreviewData.Index + 1);
TrackKit.SendEvent(ADEventTrack.VipSecretAlbums, eventName);
}
else
{
uiCtrlDispatcher.Dispatch(UICtrlMsg.VipClubViewUI_Open, 2);
TrackKit.SendEvent(ADEventTrack.VipSecretAlbums, ADEventTrack.Property.vip_secret_albums_unclock);
}
});
}
private List<(GLoader loader, string fileName, Action<NTexture> callback, string folder, string localFolder)> _tasks = new();
private void ItemRender(int index, GObject obj)
{
var item = (item_scAlbumPreview)obj;
var picture = (GLoader)item.com_pic_in.GetChild("picture");
if (!loader_list.Contains(picture))
loader_list.Add(picture);
var state = GetSafe(_albumPreviewData.State, index);
item.state.selectedIndex = is_unlock ? 0 : state;
var task = (picture, _secretData[index], (Action<NTexture>)(s =>
{
if (picture != null && !picture.isDisposed)
{
if (!is_unlock && state == 1)
TextureHelper.SetImageBlur(picture);
else
TextureHelper.CancelImageBlur(picture);
}
}), $"SecretAlbums/{_albumPreviewData.Name}/", FolderNames.SecretName);
_tasks.Add(task);
item.btn_detail.SetClick(() =>
{
if (is_unlock)
{
var data = new DetailData
{
Name = _secretData[index],
Name1 = $"SecretAlbums/{_albumPreviewData.Name}/"
};
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.SecretDetailUI_Open, data);
}
else
{
GameHelper.ShowTips("not_unlocked", true);
}
});
if (index == _secretData.Count - 1)
{
TextureHelper.SetImgLoaders(_tasks);
}
}
private void UpWatchAdsBtn()
{
DataMgr.SecretUnlockCd.Value.TryGetValue(_albumPreviewData.Index, out var lastTimes);
if (DataMgr.SecretUnlockADs.Value.TryGetValue(_albumPreviewData.Index, out var unlockAdValue) &&
unlockAdValue >= _albumPreviewData.AD)
{
ui.btn_watch.can_buy.selectedIndex = 1;
}
else
{
ui.btn_watch.can_buy.selectedIndex = 0;
if (GameHelper.GetNowTime() < lastTimes)
{
ui.btn_watch.enabled = false;
ui.btn_watch.CD.selectedIndex = 1;
ui.btn_watch.watch_cd.text =
CommonHelper.TimeFormat(lastTimes - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
}
else
{
ui.btn_watch.enabled = true;
ui.btn_watch.CD.selectedIndex = 0;
}
}
}
// 拆分字符串为列表
public static List<string> SplitStringToList(string input)
{
if (string.IsNullOrWhiteSpace(input))
return new List<string>();
// 支持英文逗号, 中文逗号,空格
char[] separators = new char[] { ',', '', ' ' };
return input
.Split(separators, StringSplitOptions.RemoveEmptyEntries)
.Select(s => s.Trim()) // 去掉前后空白
.ToList();
}
/// <summary>
/// 安全获取列表或数组中的元素,如果越界则返回最后一个元素;如果为空则返回默认值。
/// </summary>
public static T GetSafe<T>(IList<T> list, int index, T defaultValue = default)
{
if (list == null || list.Count == 0)
return defaultValue;
if (index < 0)
return list[0];
if (index >= list.Count)
return list[list.Count - 1];
return list[index];
}
}
public class DetailData
{
public string Name;
public string Name1;
}
}
+369 -369
View File
@@ -1,370 +1,370 @@
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
using System;
using DG.Tweening;
using SGModule.NetKit;
using FGUI.ZM_store_17;
using IgnoreOPS;
namespace BallKingdomCrush
{
public class BuygoldUI : BaseUI
{
private BuygoldUICtrl ctrl;
private BuygoldModel model;
private FGUI.ZM_store_17.com_buygold ui;
private bool Isbuysuccess = false;
public BuygoldUI(BuygoldUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.BuygoldUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_store_17";
uiInfo.assetName = "com_buygold";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.BuygoldModel) as BuygoldModel;
}
protected override void OnClose()
{
AdExchangeManager.Instance.Destroy();
GameHelper.showGameUI = true;
HallManager.Instance.UpdateSecondEvent -= initList;
GameDispatcher.Instance.Dispatch(GameMsg.showBroadCast);
GameDispatcher.Instance.Dispatch(GameMsg.pack_close);
if (Isbuysuccess)
{
GameHelper.ShowTurnOffReward();
}
else
{
GameHelper.ShowPaidPack();
}
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_store_17.com_buygold;
}
protected override void OnOpenBefore(object args)
{
if (Screen.safeArea.y != 0)
{//刘海屏
ui.top_gold.y += 68;
}
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.shop_show);
ui.top_gold.GetChild("text_gold").text = GameHelper.Get101Str(GameHelper.GetGoldNumber());
if (!GameHelper.IsAdModelOfPay())
{
ui.ads.visible = false;
}
InitView();
HallManager.Instance.UpdateSecondEvent += initList;
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
}
#endregion
void GetAward(decimal gold, int index)
{
var item = ui.gold_list.GetChildAt(index);
var start = GameHelper.GetUICenterPosition(item);
var end = GameHelper.GetUICenterPosition(ui.top_gold.GetChild("img"));
var rewardData = new RewardData();
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
{
startPosition = start,
endPosition = new Vector2(end.x, end.y)
};
rewardData.AddReward(rewardSingleData);
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
rewardData.AddCompleted((isScu) =>
{
DOVirtual.DelayedCall(0.5f, () =>
{
var startNum = DataMgr.Coin.Value - gold;
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 0.5f,
value => { ui.top_gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); }
).OnComplete(() => {
// 动画完成时确保最终值被正确设置
ui.top_gold.GetChild("text_gold").text = GameHelper.Get101Str(DataMgr.Coin.Value);
});
});
});
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
}
void pay_success(object str)
{
string type = (string)str;
if (type.StartsWith("buy_gold"))
{
int startIndex = "buy_gold".Length;
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffix_num = int.Parse(suffix);
SaveData.GetSaveObject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
SaveData.SaveDataFunc();
GetAward(list[suffix_num].Actual_coins, suffix_num);
Isbuysuccess = true;
}
SetTextString();
}
//初始化页面逻辑
private void InitView()
{
ui.top_gold.touchable = false;
ui.btn_close.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.BuygoldUI_Close); });
initList();
}
private List<Paidcoins> list = ConfigSystem.GetConfig<Paidcoins>();
void initList()
{
ui.gold_list.itemRenderer = setRemaintime;
ui.gold_list.numItems = list.Count;
SetTextString();
}
public void SetTextString()
{
var myAds = AdExchangeManager.Instance.GetLookRewardADNum();
ui.ads.SetVar("num", myAds.ToString()).FlushVars();
}
void setRemaintime(int index, GObject obj)
{
buygold_item item = obj as buygold_item;
bool is_paid = list[index].is_paid;
int time = 0;
time = SaveData.GetSaveObject()._goldtime[index];
item.coin_text.text = GameHelper.Get101Str(list[index].Actual_coins);
item.index.selectedIndex = 1;//index > 4 ? 4 : index;
item.off_text.text = list[index].Discount_rate + "%";
item.discount.visible = !GameHelper.IsAdModelOfPay() && list[index].Discount_rate > 0;
if (list[index].Discount_rate != 0) item.off_text.text = list[index].Discount_rate + "%";
if (time + list[index].receive_CD < GameHelper.GetNowTime())
{
item.btn_buy.can_buy.selectedIndex = 0;
if (!GameHelper.IsAdModelOfPay()){
item.btn_buy.pay_type.selectedIndex = 1;
item.text_ads.visible = false;
if (!is_paid)
{
item.btn_buy.btn_text.text = "Free";
item.discount.visible = false;
item.index.selectedIndex = 0;
}
else
{
decimal price = (decimal)list[index].Payment_amount2;
item.btn_buy.btn_text.text = GameHelper.getPrice(price);
}
item.btn_buy.SetClick(() =>
{
rd_Gold(index);
});
} else {
int myAds = AdExchangeManager.Instance.GetLookRewardADNum();
int count = (int)list[index].Payment_amount;
if (is_paid)
{
item.text_ads.SetVar("num", count.ToString()).FlushVars();
}
if (myAds >= count)
{
item.btn_buy.pay_type.selectedIndex = 1;
if (!is_paid)
{
item.btn_buy.btn_text.text = Language.GetContent("free");
item.discount.visible = false;
item.index.selectedIndex = 0;
}
else
{
item.btn_buy.btn_text.text = Language.GetContent("exchange");
}
item.btn_buy.SetClick(() =>
{
rd_Gold(index);
});
}
else if (SaveData.GetSaveObject()._watch_ad_cd > GameHelper.GetNowTime())
{
item.btn_buy.can_buy.selectedIndex = 1;
item.btn_buy.pay_type.selectedIndex = 1;
item.btn_buy.btn_text.text = CommonHelper.TimeFormat(SaveData.GetSaveObject()._watch_ad_cd - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
item.btn_buy.SetClick(() => { });
}
else
{
item.btn_buy.can_buy.selectedIndex = 0;
item.btn_buy.pay_type.selectedIndex = 0;
item.btn_buy.SetClick(() =>
{
GameHelper.ShowVideoAd("BuyGold", (issuccess) =>
{
if (issuccess)
{
SaveData.GetSaveObject()._watch_ad_cd = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().exchangeCD;
SaveData.SaveDataFunc();
initList();
}
});
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.shop_click_ + index);
});
}
}
} else {
if (!is_paid)
{
item.discount.visible = false;
item.index.selectedIndex = 0;
}
if (!GameHelper.IsAdModelOfPay())
{
item.text_ads.visible = false;
}
else
{
if (is_paid)
{
int count = (int)list[index].Payment_amount;
item.text_ads.SetVar("num", count.ToString()).FlushVars();
}
}
item.btn_buy.can_buy.selectedIndex = 1;
item.btn_buy.pay_type.selectedIndex = 1;
item.btn_buy.btn_text.text = CommonHelper.TimeFormat(time + list[index].receive_CD - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
item.btn_buy.SetClick(() =>{});
}
}
private void rd_Gold(int index)
{
// string _type = "buy_gold" + index.ToString();
bool is_paid = list[index].is_paid;
if (!is_paid)
{
SaveData.GetSaveObject()._goldtime[index] = (int)GameHelper.GetNowTime();
SaveData.SaveDataFunc();
GetAward(list[index].Actual_coins, index);
InitView();
return;
}
string _type = getShopName(index);
if (GameHelper.IsAdModelOfPay())
{
AdExchangeData test = new AdExchangeData()
{
ad_count = AdExchangeManager.Instance.GetCeilingNeedAds(_type),
type = _type,
shopName = $"buy_gold{index}"
};
AdExchangeManager.Instance.Exchange(test);
}
else
{
decimal price = (decimal)list[index].Payment_amount2;
ApplePayClass maxPayData = new ApplePayClass()
{
amount = (int)Math.Round(price * 100),
sku = _type,
currency = "USD",
shopName = $"buy_gold{index}"
};
MaxPayManager.Instance.Buy(maxPayData);
}
}
public string getShopName(int index)
{
string name;
// switch(index)
// {
// case 1:
// name = PurchasingManager.buy_gold_1;
// break;
// case 2:
// name = PurchasingManager.buy_gold_2;
// break;
// case 3:
// name = PurchasingManager.buy_gold_3;
// break;
// case 4:
// name = PurchasingManager.buy_gold_4;
// break;
// case 5:
// name = PurchasingManager.buy_gold_5;
// break;
// default:
// return "";
//
// }
name = list[index].SKU;
return name;
}
}
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
using System;
using DG.Tweening;
using SGModule.NetKit;
using FGUI.ZM_store_17;
using IgnoreOPS;
namespace BallKingdomCrush
{
public class BuygoldUI : BaseUI
{
private BuygoldUICtrl ctrl;
private BuygoldModel model;
private FGUI.ZM_store_17.com_buygold ui;
private bool Isbuysuccess = false;
public BuygoldUI(BuygoldUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.BuygoldUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "ZM_store_17";
uiInfo.assetName = "com_buygold";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.BuygoldModel) as BuygoldModel;
}
protected override void OnClose()
{
AdExchangeManager.Instance.Destroy();
GameHelper.showGameUI = true;
HallManager.Instance.UpdateSecondEvent -= initList;
GameDispatcher.Instance.Dispatch(GameMsg.showBroadCast);
GameDispatcher.Instance.Dispatch(GameMsg.pack_close);
if (Isbuysuccess)
{
GameHelper.ShowTurnOffReward();
}
else
{
GameHelper.ShowPaidPack();
}
}
protected override void OnBind()
{
ui = baseUI as FGUI.ZM_store_17.com_buygold;
}
protected override void OnOpenBefore(object args)
{
if (Screen.safeArea.y != 0)
{//刘海屏
ui.top_gold.y += 68;
}
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.shop_show);
ui.top_gold.GetChild("text_gold").text = GameHelper.Get101Str(GameHelper.GetGoldNumber());
if (!GameHelper.IsAdModelOfPay())
{
ui.ads.visible = false;
}
InitView();
HallManager.Instance.UpdateSecondEvent += initList;
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
#endregion
void GetAward(decimal gold, int index)
{
var item = ui.gold_list.GetChildAt(index);
var start = GameHelper.GetUICenterPosition(item);
var end = GameHelper.GetUICenterPosition(ui.top_gold.GetChild("img"));
var rewardData = new RewardData();
var rewardSingleData = new RewardSingleData(101, gold, RewardOrigin.AdTask)
{
startPosition = start,
endPosition = new Vector2(end.x, end.y)
};
rewardData.AddReward(rewardSingleData);
rewardData.displayType = RewardDisplayType.RewardFly | RewardDisplayType.ValueChange;
rewardData.AddCompleted((isScu) =>
{
DOVirtual.DelayedCall(0.5f, () =>
{
var startNum = DataMgr.Coin.Value - gold;
DOVirtual.Float((float)startNum, (float)GameHelper.GetGoldNumber(), 0.5f,
value => { ui.top_gold.GetChild("text_gold").text = GameHelper.Get101Str((decimal)value); }
).OnComplete(() => {
// 动画完成时确保最终值被正确设置
ui.top_gold.GetChild("text_gold").text = GameHelper.Get101Str(DataMgr.Coin.Value);
});
});
});
GameDispatcher.Instance.Dispatch(GameMsg.GetReward, rewardData);
}
void pay_success(object str)
{
string type = (string)str;
if (type.StartsWith("buy_gold"))
{
int startIndex = "buy_gold".Length;
string suffix = type[startIndex..]; // 截取 "gold" 后的所有字符
int suffix_num = int.Parse(suffix);
SaveData.GetSaveObject()._goldtime[suffix_num] = (int)GameHelper.GetNowTime();
SaveData.SaveDataFunc();
GetAward(list[suffix_num].Actual_coins, suffix_num);
Isbuysuccess = true;
}
SetTextString();
}
//初始化页面逻辑
private void InitView()
{
ui.top_gold.touchable = false;
ui.btn_close.SetClick(() => { UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.BuygoldUI_Close); });
initList();
}
private List<Paidcoins> list = ConfigSystem.GetConfig<Paidcoins>();
void initList()
{
ui.gold_list.itemRenderer = setRemaintime;
ui.gold_list.numItems = list.Count;
SetTextString();
}
public void SetTextString()
{
var myAds = AdExchangeManager.Instance.GetLookRewardADNum();
ui.ads.SetVar("num", myAds.ToString()).FlushVars();
}
void setRemaintime(int index, GObject obj)
{
buygold_item item = obj as buygold_item;
bool is_paid = list[index].is_paid;
int time = 0;
time = SaveData.GetSaveObject()._goldtime[index];
item.coin_text.text = GameHelper.Get101Str(list[index].Actual_coins);
item.index.selectedIndex = 1;//index > 4 ? 4 : index;
item.off_text.text = list[index].Discount_rate + "%";
item.discount.visible = !GameHelper.IsAdModelOfPay() && list[index].Discount_rate > 0;
if (list[index].Discount_rate != 0) item.off_text.text = list[index].Discount_rate + "%";
if (time + list[index].receive_CD < GameHelper.GetNowTime())
{
item.btn_buy.can_buy.selectedIndex = 0;
if (!GameHelper.IsAdModelOfPay()){
item.btn_buy.pay_type.selectedIndex = 1;
item.text_ads.visible = false;
if (!is_paid)
{
item.btn_buy.btn_text.text = "Free";
item.discount.visible = false;
item.index.selectedIndex = 0;
}
else
{
decimal price = (decimal)list[index].Payment_amount2;
item.btn_buy.btn_text.text = GameHelper.getPrice(price);
}
item.btn_buy.SetClick(() =>
{
rd_Gold(index);
});
} else {
int myAds = AdExchangeManager.Instance.GetLookRewardADNum();
int count = (int)list[index].Payment_amount;
if (is_paid)
{
item.text_ads.SetVar("num", count.ToString()).FlushVars();
}
if (myAds >= count)
{
item.btn_buy.pay_type.selectedIndex = 1;
if (!is_paid)
{
item.btn_buy.btn_text.text = Language.GetContent("free");
item.discount.visible = false;
item.index.selectedIndex = 0;
}
else
{
item.btn_buy.btn_text.text = Language.GetContent("exchange");
}
item.btn_buy.SetClick(() =>
{
rd_Gold(index);
});
}
else if (SaveData.GetSaveObject()._watch_ad_cd > GameHelper.GetNowTime())
{
item.btn_buy.can_buy.selectedIndex = 1;
item.btn_buy.pay_type.selectedIndex = 1;
item.btn_buy.btn_text.text = CommonHelper.TimeFormat(SaveData.GetSaveObject()._watch_ad_cd - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
item.btn_buy.SetClick(() => { });
}
else
{
item.btn_buy.can_buy.selectedIndex = 0;
item.btn_buy.pay_type.selectedIndex = 0;
item.btn_buy.SetClick(() =>
{
GameHelper.ShowVideoAd("BuyGold", (issuccess) =>
{
if (issuccess)
{
SaveData.GetSaveObject()._watch_ad_cd = (int)GameHelper.GetNowTime() + GameHelper.GetCommonModel().exchangeCD;
SaveData.SaveDataFunc();
initList();
}
});
TrackKit.SendEvent(GameHelper.getTrackEvenName(), ADEventTrack.Property.shop_click_ + index);
});
}
}
} else {
if (!is_paid)
{
item.discount.visible = false;
item.index.selectedIndex = 0;
}
if (!GameHelper.IsAdModelOfPay())
{
item.text_ads.visible = false;
}
else
{
if (is_paid)
{
int count = (int)list[index].Payment_amount;
item.text_ads.SetVar("num", count.ToString()).FlushVars();
}
}
item.btn_buy.can_buy.selectedIndex = 1;
item.btn_buy.pay_type.selectedIndex = 1;
item.btn_buy.btn_text.text = CommonHelper.TimeFormat(time + list[index].receive_CD - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
item.btn_buy.SetClick(() =>{});
}
}
private void rd_Gold(int index)
{
// string _type = "buy_gold" + index.ToString();
bool is_paid = list[index].is_paid;
if (!is_paid)
{
SaveData.GetSaveObject()._goldtime[index] = (int)GameHelper.GetNowTime();
SaveData.SaveDataFunc();
GetAward(list[index].Actual_coins, index);
InitView();
return;
}
string _type = getShopName(index);
if (GameHelper.IsAdModelOfPay())
{
AdExchangeData test = new AdExchangeData()
{
ad_count = AdExchangeManager.Instance.GetCeilingNeedAds(_type),
type = _type,
shopName = $"buy_gold{index}"
};
AdExchangeManager.Instance.Exchange(test);
}
else
{
decimal price = (decimal)list[index].Payment_amount2;
ApplePayClass maxPayData = new ApplePayClass()
{
amount = (int)Math.Round(price * 100),
sku = _type,
currency = "USD",
shopName = $"buy_gold{index}"
};
MaxPayManager.Instance.Buy(maxPayData);
}
}
public string getShopName(int index)
{
string name;
// switch(index)
// {
// case 1:
// name = PurchasingManager.buy_gold_1;
// break;
// case 2:
// name = PurchasingManager.buy_gold_2;
// break;
// case 3:
// name = PurchasingManager.buy_gold_3;
// break;
// case 4:
// name = PurchasingManager.buy_gold_4;
// break;
// case 5:
// name = PurchasingManager.buy_gold_5;
// break;
// default:
// return "";
//
// }
name = list[index].SKU;
return name;
}
}
}
+144 -144
View File
@@ -1,145 +1,145 @@
using FGUI.ZM_Common_01;
using UnityEngine;
using FairyGUI;
using SGModule.NetKit;
using Spine.Unity;
using System;
namespace BallKingdomCrush
{
public class SubUnlockUI : BaseUI
{
private SubUnlockUICtrl ctrl;
private SubUnlockModel model;
private FGUI.LG_Unlock.com_SubUnlock ui;
public SubUnlockUI(SubUnlockUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.SubUnlockUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "LG_Unlock";
uiInfo.assetName = "com_SubUnlock";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.SubUnlockModel) as SubUnlockModel;
}
protected override void OnClose()
{
closeCallback?.Invoke();
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_Unlock.com_SubUnlock;
}
protected override void OnOpenBefore(object args)
{
InitView();
TrackKit.SendEvent(ADEventTrack.Subscription, ADEventTrack.Property.vip_show_sell);
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, refrsh);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, refrsh);
}
#endregion
private void refrsh(object a = null)
{
GameHelper.ShowTips("unlock_vip", true);
CtrlCloseUI();
}
private Action closeCallback;
//初始化页面逻辑
private void InitView()
{
ui.btn_close.SetClick(() =>
{
CtrlCloseUI();
});
SkeletonAnimation ske_pot = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_parent, Fx_Type.fx_chatphone, ref closeCallback);
ske_pot.state.SetAnimation(0, "animation", true);
var vip_list = ConfigSystem.GetConfig<VipClub>();
ui.text_unlockLive.SetVar("num", GameHelper.GetCommonModel().UnlockLive[1].ToString()).FlushVars();
ui.text_unlockAlbum.SetVar("num", GameHelper.GetCommonModel().UnlockSecret[1].ToString()).FlushVars();
ui.btn_vip0.text_price.text = GameHelper.getPrice((decimal)vip_list[0].DiscountPrice);
ui.btn_vip1.text_price.text = GameHelper.getPrice((decimal)vip_list[1].DiscountPrice);
ui.btn_vip2.text_price.text = GameHelper.getPrice((decimal)vip_list[2].DiscountPrice);
ui.btn_vip0.SetClick(() =>
{
string _type = "vip_club" + 0;
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)System.Math.Round(vip_list[0].DiscountPrice * 100),
sku = PurchasingManager.GetPaySku(PayType.weekly_subscription),
currency = "USD",
shopName = _type
};
MaxPayManager.Instance.Buy(maxPayData);
});
ui.btn_vip1.SetClick(() =>
{
string _type = "vip_club" + 1;
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)System.Math.Round(vip_list[1].DiscountPrice * 100),
sku = PurchasingManager.GetPaySku(PayType.monthly_subscription),
currency = "USD",
shopName = _type
};
MaxPayManager.Instance.Buy(maxPayData);
});
ui.btn_vip2.SetClick(() =>
{
string _type = "vip_club" + 2;
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)System.Math.Round(vip_list[2].DiscountPrice * 100),
sku = PurchasingManager.GetPaySku(PayType.yearly_subscription),
currency = "USD",
shopName = _type
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
}
using FGUI.ZM_Common_01;
using UnityEngine;
using FairyGUI;
using SGModule.NetKit;
using Spine.Unity;
using System;
namespace BallKingdomCrush
{
public class SubUnlockUI : BaseUI
{
private SubUnlockUICtrl ctrl;
private SubUnlockModel model;
private FGUI.LG_Unlock.com_SubUnlock ui;
public SubUnlockUI(SubUnlockUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.SubUnlockUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "LG_Unlock";
uiInfo.assetName = "com_SubUnlock";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.SubUnlockModel) as SubUnlockModel;
}
protected override void OnClose()
{
closeCallback?.Invoke();
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_Unlock.com_SubUnlock;
}
protected override void OnOpenBefore(object args)
{
InitView();
TrackKit.SendEvent(ADEventTrack.Subscription, ADEventTrack.Property.vip_show_sell);
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.BuyVip, refrsh);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.BuyVip, refrsh);
}
#endregion
private void refrsh(object a = null)
{
GameHelper.ShowTips("unlock_vip", true);
CtrlCloseUI();
}
private Action closeCallback;
//初始化页面逻辑
private void InitView()
{
ui.btn_close.SetClick(() =>
{
CtrlCloseUI();
});
SkeletonAnimation ske_pot = FXManager.Instance.SetFx<SkeletonAnimation>(ui.ani_parent, Fx_Type.fx_chatphone, ref closeCallback);
ske_pot.state.SetAnimation(0, "animation", true);
var vip_list = ConfigSystem.GetConfig<VipClub>();
ui.text_unlockLive.SetVar("num", GameHelper.GetCommonModel().UnlockLive[1].ToString()).FlushVars();
ui.text_unlockAlbum.SetVar("num", GameHelper.GetCommonModel().UnlockSecret[1].ToString()).FlushVars();
ui.btn_vip0.text_price.text = GameHelper.getPrice((decimal)vip_list[0].DiscountPrice);
ui.btn_vip1.text_price.text = GameHelper.getPrice((decimal)vip_list[1].DiscountPrice);
ui.btn_vip2.text_price.text = GameHelper.getPrice((decimal)vip_list[2].DiscountPrice);
ui.btn_vip0.SetClick(() =>
{
string _type = "vip_club" + 0;
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)System.Math.Round(vip_list[0].DiscountPrice * 100),
sku = IAPPayManager.PRODUCT_VIP_WEEK,
currency = "USD",
shopName = _type
};
MaxPayManager.Instance.Buy(maxPayData);
});
ui.btn_vip1.SetClick(() =>
{
string _type = "vip_club" + 1;
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)System.Math.Round(vip_list[1].DiscountPrice * 100),
sku = IAPPayManager.PRODUCT_VIP_MONTH,
currency = "USD",
shopName = _type
};
MaxPayManager.Instance.Buy(maxPayData);
});
ui.btn_vip2.SetClick(() =>
{
string _type = "vip_club" + 2;
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)System.Math.Round(vip_list[2].DiscountPrice * 100),
sku = IAPPayManager.PRODUCT_VIP_YEAR,
currency = "USD",
shopName = _type
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
}
}
File diff suppressed because it is too large Load Diff
@@ -1,500 +1,500 @@
using System.Collections.Generic;
using FGUI.ZM_Common_01;
using UnityEngine;
using FairyGUI;
using FGUI.LG_Vip;
using SGModule.Common.Helper;
using SGModule.NetKit;
using SGModule.MarkdownKit;
using Newtonsoft.Json;
using SGModule.Net;
public enum VipDay
{
Week = 7,
Month = 30,
Year = 365
}
namespace BallKingdomCrush
{
public class VipClubViewUI : BaseUI
{
private VipClubViewUICtrl ctrl;
private VipClubViewModel model;
private FGUI.LG_Vip.com_vip ui;
public VipClubViewUI(VipClubViewUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.VipClubViewUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "LG_Vip";
uiInfo.assetName = "com_vip";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.VipClubViewModel) as VipClubViewModel;
}
protected override void OnClose()
{
if (_loader != null && !_loader.isDisposed && _loader.texture != null)
{
_loader.texture = null;
}
_loader = null;
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_Vip.com_vip;
}
private List<VipClub> vip_list = new List<VipClub>();
//这个要做下标,或者控制器的索引,所以从0开始(Vip是1,2,3)
private int _level = 2;
private GLoader _loader = new GLoader();
protected override void OnOpenBefore(object args)
{
_loader = ui.bg_loader;
setList();
if (GameHelper.IsGiftSwitch())
{
var fileName = GameHelper.GetBackgroundName(des_key.VIP.ToString());
TextureHelper.SetImgLoader(ui.bg_loader, fileName, null, "Background/", FolderNames.BackgroundName);
}
TrackKit.SendEvent(ADEventTrack.Subscription, ADEventTrack.Property.vip_show_page);
// 检查VIP是否过期
GameHelper.CheckVipExpiration();
_level = GameHelper.GetVipLevel() > 0 ? GameHelper.GetVipLevel() - 1 : 2;
if (args != null) _level = (int)args;
vip_list = ConfigSystem.GetConfig<VipClub>();
InitView();
// ui.text_terms.text=
// Debug.Log(MarkdownDataMgr.TryGetValue("user", out MarkdownData data));
// Debug.Log(JsonConvert.SerializeObject(data));
ui.btn_terns.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 1);
});
ui.btn_pri.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 0);
});
if (GameHelper.IsGiftSwitch())
{
int random_ = Random.Range(0, 100);
bool need_open = false;
if (random_ < GameHelper.GetCommonModel().VIPGuideRate)
{
if (GameHelper.GetVipLevel() > 0 && GameHelper.GetLevel() >= GameHelper.GetCommonModel().VIPGuide)
{
// List<int> unlocklist = new List<int>();
if ((GameHelper.GetCommonModel().Live == 1) &&
(GameHelper.GetLevel() >= GameHelper.GetCommonModel().LivePreview) &&
(GameHelper.GetLevel() < GameHelper.GetCommonModel().UnlockLive[1]))
{
// if (DataMgr.IsUnlockLive.Value < 0) //未解锁。
// {
// unlocklist.Add(0);
need_open = true;
// }
}
if ((GameHelper.GetCommonModel().Secret == 1) &&
(GameHelper.GetLevel() >= GameHelper.GetCommonModel().SecretPreview) &&
(GameHelper.GetLevel() < GameHelper.GetCommonModel().UnlockSecret[1]))
{
// if (DataMgr.IsUnlockSecret.Value < 0) //未解锁。
// {
// unlocklist.Add(1);
need_open = true;
// }
}
// if ((GameHelper.GetCommonModel().Assitant == 1) &&
// (GameHelper.GetLevel() >= GameHelper.GetCommonModel().AssitantPreview))
// {
// // if (DataMgr.IsUnlockSecret.Value < 0) //未解锁。
// // {
// // unlocklist.Add(1);
// need_open = true;
// // }
// }
}
if (need_open) uiCtrlDispatcher.Dispatch(UICtrlMsg.SubUnlockUI_Open);
else if (GameHelper.GetVipLevel() < 0 && GameHelper.GetLevel() >= GameHelper.GetCommonModel().VIPGuide)
{
uiCtrlDispatcher.Dispatch(UICtrlMsg.SubUnlockUI_Open);
}
}
}
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.apple_pay_success, pay_success);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.apple_pay_success, pay_success);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
string purch_number = "";
if (type.StartsWith("vip_club"))
{
InitView();
}
}
//初始化页面逻辑
private void InitView()
{
ui.btn_week.text_price.text = GameHelper.getPrice((decimal)vip_list[0].DiscountPrice);
ui.btn_month.text_price.text = GameHelper.getPrice((decimal)vip_list[1].DiscountPrice);
ui.btn_year.text_price.text = GameHelper.getPrice((decimal)vip_list[2].DiscountPrice);
ui.btn_week.text_price_old.text = GameHelper.getPrice((decimal)vip_list[0].Price);
ui.btn_month.text_price_old.text = GameHelper.getPrice((decimal)vip_list[1].Price);
ui.btn_year.text_price_old.text = GameHelper.getPrice((decimal)vip_list[2].Price);
ui.btn_close.SetClick(CtrlCloseUI);
// ui.btn_restore.visible = !GameHelper.IsGiftSwitch();
// ui.btn_restore.SetClick(() =>
// {
// ApplePayManager.Instance.AppleRestore((success, message) =>
// {
// Debug.Log($"[barry] restore success message: {message}---- {JsonConvert.SerializeObject(message)}");
// if (success)
// {
// Debug.Log("[barry] restore success: " + success);
// GameHelper.ShowTips("Restore Purchases Success!");
// SaveData.GetSaveObject().have_slot = success;
// DataMgr.VipLevel.Value = 3;
// DataMgr.VipExpirationTime.Value = ServerClock.GetCurrentServerTime() + 7 * 24 * 60 * 60;
//
// InitView();
// }
// else
// {
// GameHelper.ShowTips("There are no recoverable transactions");
// }
// });
// });
SetSubBtnState(_level, (int)VipDay.Year);
ui.btn_week.SetClick(() => { SetSubBtnState(0, (int)VipDay.Week); });
ui.btn_month.SetClick(() => { SetSubBtnState(1, (int)VipDay.Month); });
ui.btn_year.SetClick(() => { SetSubBtnState(2, (int)VipDay.Year); });
ui.btn_sub.SetClick(() =>
{
if (ui.btn_sub.is_buy.selectedIndex == 1) return;
string _type = "vip_club" + _level;
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)System.Math.Round(vip_list[_level].DiscountPrice * 100),
sku = PurchasingManager.GetPaySku(GetTypeByIndex(_level)),
currency = "USD",
shopName = _type
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
private PayType GetTypeByIndex(int index)
{
return index switch
{
0 => PayType.weekly_subscription,
1 => PayType.monthly_subscription,
2 => PayType.yearly_subscription,
_ => PayType.weekly_subscription
};
}
private void SetSubBtnState(int index, int day)
{
Debug.Log($"lvele============{index}");
_level = index;
ui.btn_sub.title = Language.GetContentParams("vip_buy", new[] {GameHelper.getPrice((decimal)vip_list[index].DiscountPrice), day.ToString()});
ui.btn_week.img_select.visible = index == 0;
ui.btn_month.img_select.visible = index == 1;
ui.btn_year.img_select.visible = index == 2;
ui.list.itemRenderer = ItemRenderer;
if (GameHelper.IsGiftSwitch())
{
ui.list.numItems = _vipEquity.Count;
}
else
{
ui.list.numItems = _vipEquity1.Count;
}
//vip等级(1:7天 2:30天 3:365天)
var selectIndex = 0;
if (_level <= GameHelper.GetVipLevel() - 1) //比如:如果订阅了30天,则30天和7天的订阅按钮隐藏,显示已订阅
{
selectIndex = 1;
}
ui.btn_sub.is_buy.selectedIndex = selectIndex;
}
private void ItemRenderer(int index, GObject obj)
{
var item = (item_viplist)obj;
if (GameHelper.IsGiftSwitch())
{
item.title.text = _vipEquity[index];
var state = 0;
if (_level == 0)
{
state = index > 1 ? 0 : 1;
}
else if (_level == 1)
{
state = index > 0 ? 0 : 1;
}
item.have.selectedIndex = state;
}
else
{
item.title.text = _vipEquity1[index];
}
}
private void setList()
{
var lang = PlayerPrefsKit.ReadString("LangIdKey");
if (lang.IsNullOrWhiteSpace())
{
lang = "en";
}
if (lang == "en")
{
_vipEquity = new List<string>{
"Free access to VIP levels",
"Free access to Special levels",
"Double Chest Coins Reward",
"Image downloads ad-Free",
"Double level rewards",
"Remove the interstitial ads",
"Unlock the Secret Album and Enjoy some resources",
"Unlock the live and Enjoy some resources"
};
_vipEquity1 = new List<string>
{
"Double chest rewards",
"Double level rewards",
"Remove interstitial ads",
"Remove banner ads",
};
}
else if (lang == "fr")
{
_vipEquity = new List<string>{
"Accès gratuit aux niveaux VIP",
"Accès gratuit aux niveaux Spéciaux",
"Récompenses double de pièces du coffre",
"Téléchargements d'images sans publicité",
"Récompenses double des niveaux",
"Supprimer les publicités interstitielles",
"Déverrouiller l'album secret et profiter de ressources exclusives",
"Déverrouiller le direct et profiter de ressources exclusives",
};
_vipEquity1 = new List<string>
{
"Récompenses double du coffre",
"Récompenses double des niveaux",
"Supprimer les publicités interstitielles",
"Supprimer les bannières publicitaires",
};
}
else if (lang == "de")
{
_vipEquity = new List<string>{
"Kostenlosen Zugang zu VIP-Leveln",
"Kostenlosen Zugang zu Spezial-Leveln",
"Doppelte Schatzkisten-Münzenbelohnungen",
"Werbefreie Bilddownloads",
"Doppelte Levelbelohnungen",
"Zwischenanzeigen entfernen",
"Das geheime Album freischalten und exklusive Ressourcen genießen",
"Den Livestream freischalten und exklusive Ressourcen genießen",
};
_vipEquity1 = new List<string>
{
"Doppelte Schatzkistenbelohnungen",
"Doppelte Levelbelohnungen",
"Zwischenanzeigen entfernen",
"Banneranzeigen entfernen",
};
}
else if (lang == "es")
{
_vipEquity = new List<string>{
"Acceso gratuito a los niveles VIP",
"Acceso gratuito a los niveles Especiales",
"Recompensas dobles de monedas del cofre",
"Descargas de imágenes sin anuncios",
"Recompensas dobles de niveles",
"Eliminar los anuncios intersticiales",
"Desbloquear el álbum secreto y disfrutar de recursos exclusivos",
"Desbloquear la transmisión en directo y disfrutar de recursos exclusivos",
};
_vipEquity1 = new List<string>
{
"Recompensas dobles del cofre",
"Recompensas dobles de niveles",
"Eliminar los anuncios intersticiales",
"Eliminar los banners publicitarios",
};
}
else if (lang == "pt")
{
_vipEquity = new List<string>{
"Acesso gratuito aos níveis VIP",
"Acesso gratuito aos níveis Especiais",
"Recompensas em moedas do baú em dobro",
"Baixar imagens sem anúncios",
"Recompensas de nível em dobro",
"Remover anúncios intersticiais",
"Desbloquear o álbum secreto e aproveitar recursos exclusivos",
"Desbloquear a transmissão ao vivo e aproveitar recursos exclusivos",
};
_vipEquity1 = new List<string>
{
"Recompensas do baú em dobro",
"Recompensas de nível em dobro",
"Remover anúncios intersticiais",
"Remover banners publicitários",
};
}
else if (lang == "ja")
{
_vipEquity = new List<string>{
"VIP レベルへの無料アクセス",
"スペシャルレベルへの無料アクセス",
"チェストコインのダブル報酬",
"広告なしの画像ダウンロード",
"レベル報酬のダブル",
"インタースティシャル広告を削除",
"シークレットアルバムをアンロックし、専用リソースを享受",
"ライブ配信をアンロックし、専用リ소스を享受",
};
_vipEquity1 = new List<string>
{
"チェスト報酬のダブル",
"レベル報酬のダブル",
"インタースティシャル広告を削除",
"バナー広告を削除",
};
}
else if (lang == "ko")
{
_vipEquity = new List<string>{
"VIP 레벨 무료 접근",
"스페셜 레벨 무료 접근",
"상자 동전 더블 보상",
"광고 없는 이미지 다운로드",
"레벨 보상 더블",
"인터스티셜 광고 제거",
"비밀 앨범을 잠금 해제하고 전용 리소스 즐기기",
"라이브 스트림을 잠금 해제하고 전용 리소스 즐기기",
};
_vipEquity1 = new List<string>
{
"상자 보상 더블",
"레벨 보상 더블",
"인터스티셜 광고 제거",
"배너 광고 제거",
};
}
else if (lang == "ru")
{
_vipEquity = new List<string>{
"Бесплатный доступ к VIP-уровням",
"Бесплатный доступ к специальным уровням",
"Двойные награды монет из сундука",
"Скачивание изображений без рекламы",
"Двойные награды уровней",
"Удалить межстраничную рекламу",
"Разблокировать секретный альбом и наслаждаться эксклюзивными ресурсами",
"Разблокировать прямой эфир и наслаждаться эксклюзивными ресурсами",
};
_vipEquity1 = new List<string>
{
"Двойные награды из сундука",
"Двойные награды уровней",
"Удалить межстраничную рекламу",
"Удалить баннерную рекламу",
};
}
}
//Vip权益内容列表
private List<string> _vipEquity;
private List<string> _vipEquity1;
}
using System.Collections.Generic;
using FGUI.ZM_Common_01;
using UnityEngine;
using FairyGUI;
using FGUI.LG_Vip;
using SGModule.Common.Helper;
using SGModule.NetKit;
using SGModule.MarkdownKit;
using Newtonsoft.Json;
using SGModule.Net;
public enum VipDay
{
Week = 7,
Month = 30,
Year = 365
}
namespace BallKingdomCrush
{
public class VipClubViewUI : BaseUI
{
private VipClubViewUICtrl ctrl;
private VipClubViewModel model;
private FGUI.LG_Vip.com_vip ui;
public VipClubViewUI(VipClubViewUICtrl ctrl) : base(ctrl)
{
uiName = UIConst.VipClubViewUI;
this.ctrl = ctrl;
}
protected override void SetUIInfo(UIInfo uiInfo)
{
uiInfo.packageName = "LG_Vip";
uiInfo.assetName = "com_vip";
uiInfo.layerType = UILayerType.Popup;
uiInfo.isNeedOpenAnim = false;
uiInfo.isNeedCloseAnim = false;
uiInfo.isNeedUIMask = true;
}
#region
protected override void OnInit()
{
//model = ModuleManager.Instance.GetModel(ModelConst.VipClubViewModel) as VipClubViewModel;
}
protected override void OnClose()
{
if (_loader != null && !_loader.isDisposed && _loader.texture != null)
{
_loader.texture = null;
}
_loader = null;
}
protected override void OnBind()
{
ui = baseUI as FGUI.LG_Vip.com_vip;
}
private List<VipClub> vip_list = new List<VipClub>();
//这个要做下标,或者控制器的索引,所以从0开始(Vip是1,2,3)
private int _level = 2;
private GLoader _loader = new GLoader();
protected override void OnOpenBefore(object args)
{
_loader = ui.bg_loader;
setList();
if (GameHelper.IsGiftSwitch())
{
var fileName = GameHelper.GetBackgroundName(des_key.VIP.ToString());
TextureHelper.SetImgLoader(ui.bg_loader, fileName, null, "Background/", FolderNames.BackgroundName);
}
TrackKit.SendEvent(ADEventTrack.Subscription, ADEventTrack.Property.vip_show_page);
// 检查VIP是否过期
GameHelper.CheckVipExpiration();
_level = GameHelper.GetVipLevel() > 0 ? GameHelper.GetVipLevel() - 1 : 2;
if (args != null) _level = (int)args;
vip_list = ConfigSystem.GetConfig<VipClub>();
InitView();
// ui.text_terms.text=
// Debug.Log(MarkdownDataMgr.TryGetValue("user", out MarkdownData data));
// Debug.Log(JsonConvert.SerializeObject(data));
ui.btn_terns.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 1);
});
ui.btn_pri.SetClick(() =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 0);
});
if (GameHelper.IsGiftSwitch())
{
int random_ = Random.Range(0, 100);
bool need_open = false;
if (random_ < GameHelper.GetCommonModel().VIPGuideRate)
{
if (GameHelper.GetVipLevel() > 0 && GameHelper.GetLevel() >= GameHelper.GetCommonModel().VIPGuide)
{
// List<int> unlocklist = new List<int>();
if ((GameHelper.GetCommonModel().Live == 1) &&
(GameHelper.GetLevel() >= GameHelper.GetCommonModel().LivePreview) &&
(GameHelper.GetLevel() < GameHelper.GetCommonModel().UnlockLive[1]))
{
// if (DataMgr.IsUnlockLive.Value < 0) //未解锁。
// {
// unlocklist.Add(0);
need_open = true;
// }
}
if ((GameHelper.GetCommonModel().Secret == 1) &&
(GameHelper.GetLevel() >= GameHelper.GetCommonModel().SecretPreview) &&
(GameHelper.GetLevel() < GameHelper.GetCommonModel().UnlockSecret[1]))
{
// if (DataMgr.IsUnlockSecret.Value < 0) //未解锁。
// {
// unlocklist.Add(1);
need_open = true;
// }
}
// if ((GameHelper.GetCommonModel().Assitant == 1) &&
// (GameHelper.GetLevel() >= GameHelper.GetCommonModel().AssitantPreview))
// {
// // if (DataMgr.IsUnlockSecret.Value < 0) //未解锁。
// // {
// // unlocklist.Add(1);
// need_open = true;
// // }
// }
}
if (need_open) uiCtrlDispatcher.Dispatch(UICtrlMsg.SubUnlockUI_Open);
else if (GameHelper.GetVipLevel() < 0 && GameHelper.GetLevel() >= GameHelper.GetCommonModel().VIPGuide)
{
uiCtrlDispatcher.Dispatch(UICtrlMsg.SubUnlockUI_Open);
}
}
}
}
protected override void OnOpen(object args)
{
}
protected override void OnHide()
{
}
protected override void OnDisplay(object args)
{
}
#endregion
#region
protected override void AddListener()
{
GameDispatcher.Instance.AddListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
protected override void RemoveListener()
{
GameDispatcher.Instance.RemoveListener(GameMsg.IAP_PAY_SUCCESS, pay_success);
}
#endregion
void pay_success(object str)
{
string type = (string)str;
string purch_number = "";
if (PurchasingManager._vipProductMap.ContainsKey(type))
{
InitView();
}
}
//初始化页面逻辑
private void InitView()
{
ui.btn_week.text_price.text = GameHelper.getPrice((decimal)vip_list[0].DiscountPrice);
ui.btn_month.text_price.text = GameHelper.getPrice((decimal)vip_list[1].DiscountPrice);
ui.btn_year.text_price.text = GameHelper.getPrice((decimal)vip_list[2].DiscountPrice);
ui.btn_week.text_price_old.text = GameHelper.getPrice((decimal)vip_list[0].Price);
ui.btn_month.text_price_old.text = GameHelper.getPrice((decimal)vip_list[1].Price);
ui.btn_year.text_price_old.text = GameHelper.getPrice((decimal)vip_list[2].Price);
ui.btn_close.SetClick(CtrlCloseUI);
// ui.btn_restore.visible = !GameHelper.IsGiftSwitch();
// ui.btn_restore.SetClick(() =>
// {
// ApplePayManager.Instance.AppleRestore((success, message) =>
// {
// Debug.Log($"[barry] restore success message: {message}---- {JsonConvert.SerializeObject(message)}");
// if (success)
// {
// Debug.Log("[barry] restore success: " + success);
// GameHelper.ShowTips("Restore Purchases Success!");
// SaveData.GetSaveObject().have_slot = success;
// DataMgr.VipLevel.Value = 3;
// DataMgr.VipExpirationTime.Value = ServerClock.GetCurrentServerTime() + 7 * 24 * 60 * 60;
//
// InitView();
// }
// else
// {
// GameHelper.ShowTips("There are no recoverable transactions");
// }
// });
// });
SetSubBtnState(_level, (int)VipDay.Year);
ui.btn_week.SetClick(() => { SetSubBtnState(0, (int)VipDay.Week); });
ui.btn_month.SetClick(() => { SetSubBtnState(1, (int)VipDay.Month); });
ui.btn_year.SetClick(() => { SetSubBtnState(2, (int)VipDay.Year); });
ui.btn_sub.SetClick(() =>
{
if (ui.btn_sub.is_buy.selectedIndex == 1) return;
string _type = "vip_club" + _level;
ApplePayClass maxPayData = new ApplePayClass
{
amount = (int)System.Math.Round(vip_list[_level].DiscountPrice * 100),
sku = GetTypeByIndex(_level),
currency = "USD",
shopName = _type
};
MaxPayManager.Instance.Buy(maxPayData);
});
}
private string GetTypeByIndex(int index)
{
return index switch
{
0 => IAPPayManager.PRODUCT_VIP_WEEK,
1 => IAPPayManager.PRODUCT_VIP_MONTH,
2 => IAPPayManager.PRODUCT_VIP_YEAR,
_ => IAPPayManager.PRODUCT_VIP_WEEK
};
}
private void SetSubBtnState(int index, int day)
{
Debug.Log($"lvele============{index}");
_level = index;
ui.btn_sub.title = Language.GetContentParams("vip_buy", new[] {GameHelper.getPrice((decimal)vip_list[index].DiscountPrice), day.ToString()});
ui.btn_week.img_select.visible = index == 0;
ui.btn_month.img_select.visible = index == 1;
ui.btn_year.img_select.visible = index == 2;
ui.list.itemRenderer = ItemRenderer;
if (GameHelper.IsGiftSwitch())
{
ui.list.numItems = _vipEquity.Count;
}
else
{
ui.list.numItems = _vipEquity1.Count;
}
//vip等级(1:7天 2:30天 3:365天)
var selectIndex = 0;
if (_level <= GameHelper.GetVipLevel() - 1) //比如:如果订阅了30天,则30天和7天的订阅按钮隐藏,显示已订阅
{
selectIndex = 1;
}
ui.btn_sub.is_buy.selectedIndex = selectIndex;
}
private void ItemRenderer(int index, GObject obj)
{
var item = (item_viplist)obj;
if (GameHelper.IsGiftSwitch())
{
item.title.text = _vipEquity[index];
var state = 0;
if (_level == 0)
{
state = index > 1 ? 0 : 1;
}
else if (_level == 1)
{
state = index > 0 ? 0 : 1;
}
item.have.selectedIndex = state;
}
else
{
item.title.text = _vipEquity1[index];
}
}
private void setList()
{
var lang = PlayerPrefsKit.ReadString("LangIdKey");
if (lang.IsNullOrWhiteSpace())
{
lang = "en";
}
if (lang == "en")
{
_vipEquity = new List<string>{
"Free access to VIP levels",
"Free access to Special levels",
"Double Chest Coins Reward",
"Image downloads ad-Free",
"Double level rewards",
"Remove the interstitial ads",
"Unlock the Secret Album and Enjoy some resources",
"Unlock the live and Enjoy some resources"
};
_vipEquity1 = new List<string>
{
"Double chest rewards",
"Double level rewards",
"Remove interstitial ads",
"Remove banner ads",
};
}
else if (lang == "fr")
{
_vipEquity = new List<string>{
"Accès gratuit aux niveaux VIP",
"Accès gratuit aux niveaux Spéciaux",
"Récompenses double de pièces du coffre",
"Téléchargements d'images sans publicité",
"Récompenses double des niveaux",
"Supprimer les publicités interstitielles",
"Déverrouiller l'album secret et profiter de ressources exclusives",
"Déverrouiller le direct et profiter de ressources exclusives",
};
_vipEquity1 = new List<string>
{
"Récompenses double du coffre",
"Récompenses double des niveaux",
"Supprimer les publicités interstitielles",
"Supprimer les bannières publicitaires",
};
}
else if (lang == "de")
{
_vipEquity = new List<string>{
"Kostenlosen Zugang zu VIP-Leveln",
"Kostenlosen Zugang zu Spezial-Leveln",
"Doppelte Schatzkisten-Münzenbelohnungen",
"Werbefreie Bilddownloads",
"Doppelte Levelbelohnungen",
"Zwischenanzeigen entfernen",
"Das geheime Album freischalten und exklusive Ressourcen genießen",
"Den Livestream freischalten und exklusive Ressourcen genießen",
};
_vipEquity1 = new List<string>
{
"Doppelte Schatzkistenbelohnungen",
"Doppelte Levelbelohnungen",
"Zwischenanzeigen entfernen",
"Banneranzeigen entfernen",
};
}
else if (lang == "es")
{
_vipEquity = new List<string>{
"Acceso gratuito a los niveles VIP",
"Acceso gratuito a los niveles Especiales",
"Recompensas dobles de monedas del cofre",
"Descargas de imágenes sin anuncios",
"Recompensas dobles de niveles",
"Eliminar los anuncios intersticiales",
"Desbloquear el álbum secreto y disfrutar de recursos exclusivos",
"Desbloquear la transmisión en directo y disfrutar de recursos exclusivos",
};
_vipEquity1 = new List<string>
{
"Recompensas dobles del cofre",
"Recompensas dobles de niveles",
"Eliminar los anuncios intersticiales",
"Eliminar los banners publicitarios",
};
}
else if (lang == "pt")
{
_vipEquity = new List<string>{
"Acesso gratuito aos níveis VIP",
"Acesso gratuito aos níveis Especiais",
"Recompensas em moedas do baú em dobro",
"Baixar imagens sem anúncios",
"Recompensas de nível em dobro",
"Remover anúncios intersticiais",
"Desbloquear o álbum secreto e aproveitar recursos exclusivos",
"Desbloquear a transmissão ao vivo e aproveitar recursos exclusivos",
};
_vipEquity1 = new List<string>
{
"Recompensas do baú em dobro",
"Recompensas de nível em dobro",
"Remover anúncios intersticiais",
"Remover banners publicitários",
};
}
else if (lang == "ja")
{
_vipEquity = new List<string>{
"VIP レベルへの無料アクセス",
"スペシャルレベルへの無料アクセス",
"チェストコインのダブル報酬",
"広告なしの画像ダウンロード",
"レベル報酬のダブル",
"インタースティシャル広告を削除",
"シークレットアルバムをアンロックし、専用リソースを享受",
"ライブ配信をアンロックし、専用リ소스を享受",
};
_vipEquity1 = new List<string>
{
"チェスト報酬のダブル",
"レベル報酬のダブル",
"インタースティシャル広告を削除",
"バナー広告を削除",
};
}
else if (lang == "ko")
{
_vipEquity = new List<string>{
"VIP 레벨 무료 접근",
"스페셜 레벨 무료 접근",
"상자 동전 더블 보상",
"광고 없는 이미지 다운로드",
"레벨 보상 더블",
"인터스티셜 광고 제거",
"비밀 앨범을 잠금 해제하고 전용 리소스 즐기기",
"라이브 스트림을 잠금 해제하고 전용 리소스 즐기기",
};
_vipEquity1 = new List<string>
{
"상자 보상 더블",
"레벨 보상 더블",
"인터스티셜 광고 제거",
"배너 광고 제거",
};
}
else if (lang == "ru")
{
_vipEquity = new List<string>{
"Бесплатный доступ к VIP-уровням",
"Бесплатный доступ к специальным уровням",
"Двойные награды монет из сундука",
"Скачивание изображений без рекламы",
"Двойные награды уровней",
"Удалить межстраничную рекламу",
"Разблокировать секретный альбом и наслаждаться эксклюзивными ресурсами",
"Разблокировать прямой эфир и наслаждаться эксклюзивными ресурсами",
};
_vipEquity1 = new List<string>
{
"Двойные награды из сундука",
"Двойные награды уровней",
"Удалить межстраничную рекламу",
"Удалить баннерную рекламу",
};
}
}
//Vip权益内容列表
private List<string> _vipEquity;
private List<string> _vipEquity1;
}
}
+460 -433
View File
@@ -1,434 +1,461 @@
using System;
using System.Collections.Generic;
using BallKingdomCrush;
using Newtonsoft.Json;
using SGModule.Common;
using SGModule.Common.Helper;
using SGModule.GooglePay;
using SGModule.NetKit;
using UnityEngine;
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
{
private static readonly List<ApplePay> PayConfig = ConfigSystem.GetConfig<ApplePay>();
public static string GetPaySku(PayType key)
{
var 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;
}
#if UNITY_IOS
public static void InitProduct()
{
var appleData = new ApplePayData
{
sku = "",
amount = 0,
currency = "USD",
shopName = "",
type = ""
};
//初始化商品
ApplePayManager.Instance.InitProduct(ConfigSystem.GetConfig<ApplePayModel2>(),
ConfigManager.GameConfig.packageName, PurchasingManager.ApplePaySuccessCallback(appleData));
}
public static void Purchase(ApplePayData payData)
{
//本地测试
// 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);
});
}
public static Action<ApplePayBackType, AppleResponseData> ApplePaySuccessCallback(ApplePayData payData)
{
return (backType, AppleResponseData) => {
Debug.Log($"[Apple Pay] unity Purchase--1-----: {backType.ToString()}");
switch (backType) {
case ApplePayBackType.Create:
Debug.Log("[Apple Pay] Create");
var sku0 = SetSku(payData);
Debug.Log($"[Apple Pay] Create---11: {sku0}");
SendEventClickByName(sku0, "click");
break;
case ApplePayBackType.Check:
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
if (AppleResponseData != null && AppleResponseData.sku.Contains(".sub"))
{
DataMgr.VipExpirationTime.Value =
Math.Max(DataMgr.VipExpirationTime.Value, AppleResponseData.expires_time);
var level = GetVipLvFormConfig(AppleResponseData.sku);
DataMgr.VipLevel.Value = level;
payData.sku = AppleResponseData.sku;
payData.shopName = "vip_club" + (level - 1);
}
var sku = SetSku(payData);
Debug.Log($"[Apple Pay] Check sku===2===== {sku}");
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, sku);
Debug.Log($"[Apple Pay] Check sku===3===== {sku}");
SendEventClickByName(sku, "open");
SendEventClickByName(sku, "success");
break;
case ApplePayBackType.Cancel:
Debug.Log("[Apple Pay] Cancel");
var sku1 = SetSku(payData);
SendEventClickByName(sku1, "open");
break;
}
};
}
private static void TestIOSPay(ApplePayData payData)
{
var tranId = "";
var types = ProductType.Consumable;
if (GetPaySku(PayType.battle_pass) == payData.sku)
{
tranId = "2000000983625783";
} else if (GetPaySku(PayType.weekly_subscription) == payData.sku)
{
tranId = "2000000984643029";
types = ProductType.Subscription;
}
if (tranId == "") return ;
ApplePayManager.Instance.ApplePayTest(types, payData.sku, tranId, ApplePaySuccessCallback(payData));
}
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;
}
#elif UNITY_ANDROID
public static void InitProduct()
{
var googleData = new GooglePayData
{
sku = "",
amount = 0,
currency = "USD",
shopName = "",
type = ""
};
//初始化商品
GooglePayManager.Instance.InitProduct(ConfigSystem.GetConfig<SGModule.GooglePay.PayProductConfig>(),
ConfigManager.GameConfig.packageName, ApplePaySuccessCallback(googleData));
// IAPManagerV5.Instance.InitIAPSystem(ConfigSystem.GetConfig<PayProductConfig>(),ApplePaySuccessCallback(googleData), ConfigManager.GameConfig.packageName);
}
private static bool _isChecking = false;
private static bool isFlag = false;
public static void CheckSubExpiration(bool isLogin = false)
{
Debug.Log($"[PurchasingManager] 检查订阅开始 CheckSubExpiration isLogin: {isLogin}");
if (_isChecking || DataMgr.VipRequestNum.Value > 5)
{
Debug.Log($"[PurchasingManager] 检查订阅中,忽略本次调用 _isChecking== {_isChecking} VipRequestNum: {DataMgr.VipRequestNum.Value}");
return;
}
if (!isFlag && isLogin)
{
isFlag = true;
DataMgr.VipRequestNum.Value++; //登录后的调用的次数
}
_isChecking = true;
GooglePayManager.Instance.CheckSubscription(OnCheckFinished);
}
private static void OnCheckFinished(bool success)
{
Debug.Log($"[PurchasingManager] 订阅检查完成 success={success}");
_isChecking = false; // ✅ 解锁
//只要订阅成功后,解除5次限制
if (success)
{
DataMgr.VipRequestNum.Value = 0;
}
else
{
DataMgr.VipLevel.Value = -1;
}
}
public static void Purchase(GooglePayData payData)
{
//本地测试
// TestIOSPay(payData);
// return;
Debug.Log($"[Google Pay] unity Purchase--0-----: {payData.sku}");
GooglePayManager.Instance.Purchase(payData.sku, ApplePaySuccessCallback(payData),
message => { Debug.Log("purchase fail------- reason: " + message); });
}
public static Action<GooglePayBackType, GoogleResponseData> ApplePaySuccessCallback(GooglePayData payData)
{
return (backType, GoogleResponseData) =>
{
Debug.Log($"[Google Pay] unity Purchase--1-----: {backType.ToString()}");
if (GoogleResponseData != null)
Debug.Log($"[Google Pay] GoogleResponseData sku===: {GoogleResponseData.sku}");
MaxPayManager.isOfficialPay = true;
switch (backType)
{
case GooglePayBackType.Create:
Debug.Log("[Google Pay] Create");
var sku0 = SetSku(payData);
Debug.Log($"[Google Pay] Create---11: {sku0}");
SendEventClickByName(sku0, "click");
break;
case GooglePayBackType.Check:
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
if (GoogleResponseData != null && GoogleResponseData.sku.Contains(".sub"))
{
if (GoogleResponseData.expires_time > 0)
{
DataMgr.VipExpirationTime.Value = Math.Max(DataMgr.VipExpirationTime.Value,
GoogleResponseData.expires_time);
Debug.Log(
$"[Google Pay] Pay GoogleResponseData.expires_time == {GoogleResponseData.expires_time} {DataMgr.VipExpirationTime.Value}");
}
var level = GetVipLvFormConfig(GoogleResponseData.sku);
DataMgr.VipLevel.Value = level;
payData.sku = GoogleResponseData.sku;
payData.shopName = "vip_club" + (level - 1);
Debug.Log($"[Google Pay] Pay Success check sku==sub=== {GoogleResponseData.sku}");
GameHelper.CheckVipExpiration();
}
else if (GoogleResponseData != null && GoogleResponseData.sku.Contains("shop"))
{
payData.sku = GoogleResponseData.sku;
var index = GetGoldIndex(GoogleResponseData.sku);
Debug.Log($"[Google Pay] check sku===== {GoogleResponseData.sku}");
Debug.Log($"[Google Pay] check index===== {index}");
payData.shopName = $"buy_gold{index}";
}
else if (GoogleResponseData != null)
{
payData.sku = GoogleResponseData.sku;
}
var sku = SetSku(payData);
Debug.Log($"[Google Pay] Check sku===-1===== {JsonConvert.SerializeObject(payData)}");
Debug.Log($"[Google Pay] Check sku===2===== {sku}");
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, sku);
Debug.Log($"[Google Pay] Check sku===3===== {sku}");
SendEventClickByName(sku, "open");
SendEventClickByName(sku, "success");
break;
case GooglePayBackType.Cancel:
Debug.Log("[Google Pay] Cancel");
var sku1 = SetSku(payData);
SendEventClickByName(sku1, "open");
BIManager.Instance.TrackPurchase(payData.amount, payData.currency, "0", payData.sku, "paid_err");
break;
case GooglePayBackType.TimeOut:
Debug.Log("[Google Pay] timeout");
GameHelper.ShowTips("no_connect", true);
break;
}
};
}
private static string SetSku(GooglePayData data)
{
var 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;
}
private static int GetGoldIndex(string sku)
{
var idx = 0;
var list = ConfigSystem.GetConfig<Paidcoins>();
for (var i = 0; i < list.Count; i++)
if (list[i].SKU == sku)
{
idx = i;
break;
}
return idx;
}
#endif
private static void SendEventClickByName(string name, string type)
{
if (name == null) return;
string clickTrackKey = null;
string successTrackKey = null;
string openTrackKey = null;
if (name == GetPaySku(PayType.pack_reward))
{
clickTrackKey = ADEventTrack.Property.lucky_gift_click;
successTrackKey = ADEventTrack.Property.lucky_gift_receive;
openTrackKey = ADEventTrack.Property.lucky_gift_show;
}
else if (name == GetPaySku(PayType.remove_ad))
{
clickTrackKey = ADEventTrack.Property.remove_ad_click;
successTrackKey = ADEventTrack.Property.remove_ad_receive;
openTrackKey = ADEventTrack.Property.remove_ad_show;
}
else if (name == GetPaySku(PayType.battle_pass))
{
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))
{
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;
}
if (name.StartsWith("buy_gold"))
{
var startIndex = "buy_gold".Length;
var suffix = name[startIndex..]; // 截取 "gold" 后的所有字符
clickTrackKey = ADEventTrack.Property.shop_click_ + suffix;
successTrackKey = ADEventTrack.Property.shop_receive_ + suffix;
openTrackKey = ADEventTrack.Property.shop_show;
}
if (name.StartsWith("vip_club"))
{
Debug.Log("SendEventClickByName:" + name + " type:" + type);
var startIndex = "vip_club".Length;
var suffix = name[startIndex..]; // 截取 "gold" 后的所有字符
clickTrackKey = ADEventTrack.Property.vip_click_ + suffix;
successTrackKey = ADEventTrack.Property.vip_success_ + suffix;
openTrackKey = ADEventTrack.Property.vip_show_page;
}
if (type == "success" && successTrackKey != null)
TrackKit.SendEvent(ADEventTrack.Google_Pay_Event, successTrackKey);
else if (type == "click" && clickTrackKey != null)
TrackKit.SendEvent(ADEventTrack.Google_Pay_Event, clickTrackKey);
else if (type == "open" && openTrackKey != null)
TrackKit.SendEvent(ADEventTrack.Google_Pay_Event, openTrackKey);
}
using System;
using System.Collections.Generic;
using BallKingdomCrush;
using Newtonsoft.Json;
using SGModule.Common;
using SGModule.Common.Helper;
using SGModule.GooglePay;
using SGModule.NetKit;
using UnityEngine;
// 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
{
private static readonly List<ApplePay> PayConfig = ConfigSystem.GetConfig<ApplePay>();
// public static string GetPaySku(PayType key)
// {
// var 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;
// }
#if UNITY_IOS
public static void InitProduct()
{
var appleData = new ApplePayData
{
sku = "",
amount = 0,
currency = "USD",
shopName = "",
type = ""
};
//初始化商品
ApplePayManager.Instance.InitProduct(ConfigSystem.GetConfig<ApplePayModel2>(),
ConfigManager.GameConfig.packageName, PurchasingManager.ApplePaySuccessCallback(appleData));
}
public static void Purchase(ApplePayData payData)
{
//本地测试
// 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);
});
}
public static Action<ApplePayBackType, AppleResponseData> ApplePaySuccessCallback(ApplePayData payData)
{
return (backType, AppleResponseData) => {
Debug.Log($"[Apple Pay] unity Purchase--1-----: {backType.ToString()}");
switch (backType) {
case ApplePayBackType.Create:
Debug.Log("[Apple Pay] Create");
var sku0 = SetSku(payData);
Debug.Log($"[Apple Pay] Create---11: {sku0}");
SendEventClickByName(sku0, "click");
break;
case ApplePayBackType.Check:
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
if (AppleResponseData != null && AppleResponseData.sku.Contains(".sub"))
{
DataMgr.VipExpirationTime.Value =
Math.Max(DataMgr.VipExpirationTime.Value, AppleResponseData.expires_time);
var level = GetVipLvFormConfig(AppleResponseData.sku);
DataMgr.VipLevel.Value = level;
payData.sku = AppleResponseData.sku;
payData.shopName = "vip_club" + (level - 1);
}
var sku = SetSku(payData);
Debug.Log($"[Apple Pay] Check sku===2===== {sku}");
GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, sku);
Debug.Log($"[Apple Pay] Check sku===3===== {sku}");
SendEventClickByName(sku, "open");
SendEventClickByName(sku, "success");
break;
case ApplePayBackType.Cancel:
Debug.Log("[Apple Pay] Cancel");
var sku1 = SetSku(payData);
SendEventClickByName(sku1, "open");
break;
}
};
}
private static void TestIOSPay(ApplePayData payData)
{
var tranId = "";
var types = ProductType.Consumable;
if (GetPaySku(PayType.battle_pass) == payData.sku)
{
tranId = "2000000983625783";
} else if (GetPaySku(PayType.weekly_subscription) == payData.sku)
{
tranId = "2000000984643029";
types = ProductType.Subscription;
}
if (tranId == "") return ;
ApplePayManager.Instance.ApplePayTest(types, payData.sku, tranId, ApplePaySuccessCallback(payData));
}
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;
}
#elif UNITY_ANDROID
public static void InitProduct()
{
var googleData = new GooglePayData
{
sku = "",
amount = 0,
currency = "USD",
shopName = "",
type = ""
};
//初始化商品
// GooglePayManager.Instance.InitProduct(ConfigSystem.GetConfig<SGModule.GooglePay.PayProductConfig>(),
// ConfigManager.GameConfig.packageName, ApplePaySuccessCallback(googleData));
// IAPManagerV5.Instance.InitIAPSystem(ConfigSystem.GetConfig<PayProductConfig>(),ApplePaySuccessCallback(googleData), ConfigManager.GameConfig.packageName);
}
private static bool _isChecking = false;
private static bool isFlag = false;
public static void CheckSubExpiration(bool isLogin = false)
{
Debug.Log($"[PurchasingManager] 检查订阅开始 CheckSubExpiration isLogin: {isLogin}");
if (_isChecking || DataMgr.VipRequestNum.Value > 5)
{
Debug.Log($"[PurchasingManager] 检查订阅中,忽略本次调用 _isChecking== {_isChecking} VipRequestNum: {DataMgr.VipRequestNum.Value}");
return;
}
if (!isFlag && isLogin)
{
isFlag = true;
DataMgr.VipRequestNum.Value++; //登录后的调用的次数
}
_isChecking = true;
GooglePayManager.Instance.CheckSubscription(OnCheckFinished);
}
private static void OnCheckFinished(bool success)
{
Debug.Log($"[PurchasingManager] 订阅检查完成 success={success}");
_isChecking = false; // ✅ 解锁
//只要订阅成功后,解除5次限制
if (success)
{
DataMgr.VipRequestNum.Value = 0;
}
else
{
DataMgr.VipLevel.Value = -1;
}
}
public static void Purchase(GooglePayData payData)
{
//本地测试
// TestIOSPay(payData);
// return;
// Debug.Log($"[Google Pay] unity Purchase--0-----: {payData.sku}");
// GooglePayManager.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<GooglePayBackType, GoogleResponseData> ApplePaySuccessCallback(GooglePayData payData)
// {
// return (backType, GoogleResponseData) =>
// {
// Debug.Log($"[Google Pay] unity Purchase--1-----: {backType.ToString()}");
// if (GoogleResponseData != null)
// Debug.Log($"[Google Pay] GoogleResponseData sku===: {GoogleResponseData.sku}");
//
// MaxPayManager.isOfficialPay = true;
//
// switch (backType)
// {
// case GooglePayBackType.Create:
// Debug.Log("[Google Pay] Create");
// var sku0 = SetSku(payData);
// Debug.Log($"[Google Pay] Create---11: {sku0}");
// SendEventClickByName(sku0, "click");
// break;
// case GooglePayBackType.Check:
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
//
// if (GoogleResponseData != null && GoogleResponseData.sku.Contains(".sub"))
// {
// if (GoogleResponseData.expires_time > 0)
// {
// DataMgr.VipExpirationTime.Value = Math.Max(DataMgr.VipExpirationTime.Value,
// GoogleResponseData.expires_time);
//
// Debug.Log(
// $"[Google Pay] Pay GoogleResponseData.expires_time == {GoogleResponseData.expires_time} {DataMgr.VipExpirationTime.Value}");
// }
//
// var level = GetVipLvFormConfig(GoogleResponseData.sku);
// DataMgr.VipLevel.Value = level;
// payData.sku = GoogleResponseData.sku;
// payData.shopName = "vip_club" + (level - 1);
// Debug.Log($"[Google Pay] Pay Success check sku==sub=== {GoogleResponseData.sku}");
//
// GameHelper.CheckVipExpiration();
// }
//
//
// else if (GoogleResponseData != null && GoogleResponseData.sku.Contains("shop"))
// {
// payData.sku = GoogleResponseData.sku;
// var index = GetGoldIndex(GoogleResponseData.sku);
// Debug.Log($"[Google Pay] check sku===== {GoogleResponseData.sku}");
// Debug.Log($"[Google Pay] check index===== {index}");
//
// payData.shopName = $"buy_gold{index}";
// }
// else if (GoogleResponseData != null)
// {
// payData.sku = GoogleResponseData.sku;
// }
//
// var sku = SetSku(payData);
// Debug.Log($"[Google Pay] Check sku===-1===== {JsonConvert.SerializeObject(payData)}");
// Debug.Log($"[Google Pay] Check sku===2===== {sku}");
// GameDispatcher.Instance.Dispatch(GameMsg.IAP_PAY_SUCCESS, sku);
// Debug.Log($"[Google Pay] Check sku===3===== {sku}");
//
// SendEventClickByName(sku, "open");
//
// SendEventClickByName(sku, "success");
// break;
// case GooglePayBackType.Cancel:
// Debug.Log("[Google Pay] Cancel");
// var sku1 = SetSku(payData);
// SendEventClickByName(sku1, "open");
//
// BIManager.Instance.TrackPurchase(payData.amount, payData.currency, "0", payData.sku, "paid_err");
// break;
//
// case GooglePayBackType.TimeOut:
// Debug.Log("[Google Pay] timeout");
// GameHelper.ShowTips("no_connect", true);
// break;
// }
// };
// }
//
// private static string SetSku(GooglePayData data)
// {
// var 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;
// }
private static int GetGoldIndex(string sku)
{
var idx = 0;
var list = ConfigSystem.GetConfig<Paidcoins>();
for (var i = 0; i < list.Count; i++)
if (list[i].SKU == sku)
{
idx = i;
break;
}
return idx;
}
#endif
// 商店商品映射表
public static readonly Dictionary<string, string> _shopProductMap = new Dictionary<string, string>
{
{ 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" },
};
public static void SendEventClickByName(string name, string type)
{
if (name == null) return;
string clickTrackKey = null;
string successTrackKey = null;
string openTrackKey = null;
if (name == IAPPayManager.PRODUCT_FIRST_GIFT)
{
clickTrackKey = ADEventTrack.Property.lucky_gift_click;
successTrackKey = ADEventTrack.Property.lucky_gift_receive;
openTrackKey = ADEventTrack.Property.lucky_gift_show;
}
else if (name == IAPPayManager.PRODUCT_REMOVE_ADS)
{
clickTrackKey = ADEventTrack.Property.remove_ad_click;
successTrackKey = ADEventTrack.Property.remove_ad_receive;
openTrackKey = ADEventTrack.Property.remove_ad_show;
}
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 == 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 == IAPPayManager.PRODUCT_THREE_DAY)
{
clickTrackKey = ADEventTrack.Property.three_days_gift_click;
successTrackKey = ADEventTrack.Property.three_days_gift_buy_success;
openTrackKey = ADEventTrack.Property.three_days_gift_show;
}
else if (_shopProductMap.TryGetValue(name, out var idx))
{
clickTrackKey = ADEventTrack.Property.shop_click_ + idx;
successTrackKey = ADEventTrack.Property.shop_receive_ + idx;
openTrackKey = ADEventTrack.Property.shop_show;
}
else if (_vipProductMap.TryGetValue(name, out var vipIdx))
{
clickTrackKey = ADEventTrack.Property.vip_click_ + vipIdx;
successTrackKey = ADEventTrack.Property.vip_success_ + vipIdx;
openTrackKey = ADEventTrack.Property.vip_show_page;
}
if (type == "success" && successTrackKey != null)
TrackKit.SendEvent(ADEventTrack.Google_Pay_Event, successTrackKey);
else if (type == "click" && clickTrackKey != null)
TrackKit.SendEvent(ADEventTrack.Google_Pay_Event, clickTrackKey);
else if (type == "open" && openTrackKey != null)
TrackKit.SendEvent(ADEventTrack.Google_Pay_Event, openTrackKey);
}
}
@@ -55,6 +55,7 @@ namespace BallKingdomCrush {
TrackKit.TrackLoginFunnel(LoginFunnelEventType.LoginRecv, isSuccess ? "success" : "fail");
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NetworkErrorTipsUI_Close);
Debug.Log($"loginData.uid======={loginData.Uid}");
if (isSuccess)
{
+91 -91
View File
@@ -1,92 +1,92 @@
using System.Collections.Generic;
using SGModule.NetKit;
using UnityEngine;
namespace BallKingdomCrush
{
public class PlayDataSystem : BaseSystem
{
public PlayDataSystem(bool isAutoInit = true)
{
if (isAutoInit)
{
Init();
}
}
public sealed override void Init()
{
base.Init();
AddListener();
}
private void AddListener()
{
NetworkDispatcher.Instance.AddListener(NetworkMsg.GetPlayData, OnRequestPlayData);
NetworkDispatcher.Instance.AddListener(NetworkMsg.SavePlayData, OnRequestSavePlayData);
}
private void RemoveListener()
{
NetworkDispatcher.Instance.RemoveListener(NetworkMsg.GetPlayData, OnRequestPlayData);
NetworkDispatcher.Instance.RemoveListener(NetworkMsg.SavePlayData, OnRequestSavePlayData);
}
private void OnRequestPlayData(object args)
{
NetApi.RequestPlayerData((isSuccess, json) => {
// Debug.Log($"barry UserData : {json}");
if (isSuccess) {
var loginModel = LoginKit.Instance.LoginModel;
if (loginModel.NewPlayer || loginModel.Uid != DataMgr.UserID.Value)
{
GameHelper.clearJsonData();
}
DataMgr.InitPreferences(json);
NetworkDispatcher.Instance.Dispatch(NetworkMsg.GetConfig);
}
else {
Debug.LogError($"OnRequestPlayData isError {json}");
}
});
}
private void OnRequestSavePlayData(object obj)
{
if (obj != null)
{
var msg = obj as Dictionary<string, object>;
if (msg == null)
{
return;
}
var version = 1L;
if (msg.TryGetValue("data_ver", out var ver))
{
if (version != default)
{
version = (long)ver;
}
}
var data = SerializeUtil.ToJson<Dictionary<string, object>>(msg);
var requestData = new RequestSavePlayData
{
version = version,
data = data
};
// NetworkKit.PostWithHeader("user/updateData", requestData);
}
}
public override void Dispose()
{
base.Dispose();
RemoveListener();
}
}
using System.Collections.Generic;
using SGModule.NetKit;
using UnityEngine;
namespace BallKingdomCrush
{
public class PlayDataSystem : BaseSystem
{
public PlayDataSystem(bool isAutoInit = true)
{
if (isAutoInit)
{
Init();
}
}
public sealed override void Init()
{
base.Init();
AddListener();
}
private void AddListener()
{
NetworkDispatcher.Instance.AddListener(NetworkMsg.GetPlayData, OnRequestPlayData);
NetworkDispatcher.Instance.AddListener(NetworkMsg.SavePlayData, OnRequestSavePlayData);
}
private void RemoveListener()
{
NetworkDispatcher.Instance.RemoveListener(NetworkMsg.GetPlayData, OnRequestPlayData);
NetworkDispatcher.Instance.RemoveListener(NetworkMsg.SavePlayData, OnRequestSavePlayData);
}
private void OnRequestPlayData(object args)
{
NetApi.RequestPlayerData((isSuccess, json) => {
Debug.Log($"barry UserData : {isSuccess}{json}");
if (isSuccess) {
var loginModel = LoginKit.Instance.LoginModel;
if (loginModel.NewPlayer || loginModel.Uid != DataMgr.UserID.Value)
{
GameHelper.clearJsonData();
}
DataMgr.InitPreferences(json);
NetworkDispatcher.Instance.Dispatch(NetworkMsg.GetConfig);
}
else {
Debug.LogError($"OnRequestPlayData isError {json}");
}
});
}
private void OnRequestSavePlayData(object obj)
{
if (obj != null)
{
var msg = obj as Dictionary<string, object>;
if (msg == null)
{
return;
}
var version = 1L;
if (msg.TryGetValue("data_ver", out var ver))
{
if (version != default)
{
version = (long)ver;
}
}
var data = SerializeUtil.ToJson<Dictionary<string, object>>(msg);
var requestData = new RequestSavePlayData
{
version = version,
data = data
};
// NetworkKit.PostWithHeader("user/updateData", requestData);
}
}
public override void Dispose()
{
base.Dispose();
RemoveListener();
}
}
}
+461 -405
View File
@@ -1,406 +1,462 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using AppsFlyerSDK;
using DG.Tweening;
using IgnoreOPS;
using Newtonsoft.Json;
using SGModule.NetKit;
// using AppsFlyerSDK;
// using AppsFlyerSDK;
using UnityEngine;
using UnityEngine.Events;
namespace BallKingdomCrush
{
public class MaxADKit
{
public static string SDKKey =
"oXM0CzVDi7P1HstOpKvFMInPMOzpQ9uA6t3x75q5f5wQvsEy9vuiiiM94ZJCJSV7PcZGroSSInQCTGsu04QEiE";
public static string interstitialADUnitID = "450445216a84fb16";
public static string rewardedADUnitID = "b979e20045011cb6";
private const float RevenueThreshold = 0;
public static void Init()
{
MaxSdkCallbacks.OnSdkInitializedEvent += sdkConfiguration =>
{
InitializeRewardedAds();
InitializeInterstitialAds();
};
MaxSdk.SetSdkKey(SDKKey);
// var loginModel = GameHelper.GetLoginModel();
// user_id = loginModel.uid.ToString();
// MaxSdk.SetUserId(loginModel.uid.ToString());
// MaxSdk.SetIsAgeRestrictedUser(false);
MaxSdk.SetHasUserConsent(true);
MaxSdk.SetDoNotSell(false);
MaxSdk.InitializeSdk();
// MaxSdk.ShowMediationDebugger();
// #if !UNITY_EDITOR
// MBridgeSDKManager.initialize("368295", "fc0155e8f6e8bda23b06d22414379609");
// #endif
}
public static void SetUserID(string userID)
{
user_id = userID;
MaxSdk.SetUserId(user_id);
}
#region 广
public static UnityAction<bool> onInterstitialAdCompleted = null;
public static void ShowInterstitial(string placement = "DefaultInterstitial",
UnityAction<bool> onCompleted = null)
{
if (MaxSdk.IsInterstitialReady(interstitialADUnitID))
{
// Debug.Log($"广告已经准备好,播放");
MaxSdk.ShowInterstitial(interstitialADUnitID, placement);
onInterstitialAdCompleted = onCompleted;
}
else
{
// Debug.Log($"广告未准备好,不播放");
onCompleted?.Invoke(false);
}
}
static int retryAttemptInterstitial;
public static void InitializeInterstitialAds()
{
MaxSdkCallbacks.Interstitial.OnAdLoadedEvent += OnInterstitialLoadedEvent;
MaxSdkCallbacks.Interstitial.OnAdLoadFailedEvent += OnInterstitialLoadFailedEvent;
MaxSdkCallbacks.Interstitial.OnAdDisplayedEvent += OnInterstitialDisplayedEvent;
MaxSdkCallbacks.Interstitial.OnAdClickedEvent += OnInterstitialClickedEvent;
MaxSdkCallbacks.Interstitial.OnAdHiddenEvent += OnInterstitialHiddenEvent;
MaxSdkCallbacks.Interstitial.OnAdDisplayFailedEvent += OnInterstitialAdFailedToDisplayEvent;
MaxSdkCallbacks.Interstitial.OnAdRevenuePaidEvent += OnInterstitialAdRevenueEvent;
LoadInterstitial();
}
private static void LoadInterstitial()
{
MaxSdk.LoadInterstitial(interstitialADUnitID);
BIManager.Instance.TrackAdEvent(BIEvent.AD_REQUEST, "Interstitial");
}
private static void OnInterstitialLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
retryAttemptInterstitial = 0;
BIManager.Instance.TrackAdEvent(BIEvent.AD_INVENTORY, "Interstitial", adInfo.Placement, adInfo.NetworkName);
}
private static void OnInterstitialLoadFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
{
retryAttemptInterstitial++;
double retryDelay = Math.Pow(2, Math.Min(6, retryAttemptInterstitial));
CrazyAsyKit.StartAction("LoadInterstitial", LoadInterstitial, (float)retryDelay);
}
private static void OnInterstitialDisplayedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
BIManager.Instance.TrackAdEvent(BIEvent.AD_IMP, "Interstitial", adInfo.Placement, adInfo.NetworkName,
adInfo.Revenue, _placement);
}
private static void OnInterstitialAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo,
MaxSdkBase.AdInfo adInfo)
{
LoadInterstitial();
}
private static void OnInterstitialClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
BIManager.Instance.TrackAdEvent(BIEvent.AD_CLICK, "Interstitial", adInfo.Placement, adInfo.NetworkName);
}
private static void OnInterstitialHiddenEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
LoadInterstitial();
onInterstitialAdCompleted?.Invoke(true);
onInterstitialAdCompleted = null;
}
#endregion
#region 广
public static UnityAction<bool> onVideoAdCompleted = null;
private static string _placement = "";
private static Coroutine _waitForVideoAd = null;
public static void ShowVideo(string placement = "DefaultVideo", UnityAction<bool> onCompleted = null)
{
onVideoAdCompleted = onCompleted;
_placement = placement;
#if UNITY_EDITOR
onVideoAdCompleted?.Invoke(true);
#else
TrackKit.SendEvent(VideoBehaviorTrack.Event, VideoBehaviorTrack.Property.watch_ad_people);
TrackKit.SendEvent(VideoBehaviorTrack.Event, VideoBehaviorTrack.Property.Rewarded_videos_trigger_number);
if (MaxSdk.IsRewardedAdReady(rewardedADUnitID))
{
MaxSdk.ShowRewardedAd(rewardedADUnitID, _placement);
}
else
{
if (_waitForVideoAd != null)
{
CrazyAsyKit.StopCoroutine(_waitForVideoAd);
}
_waitForVideoAd = CrazyAsyKit.StartCoroutine(WaitForVideoAd());
}
#endif
}
private static IEnumerator WaitForVideoAd()
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Open);
var count = 0;
var result = false;
while (count < 6)
{
if (MaxSdk.IsRewardedAdReady(rewardedADUnitID))
{
result = true;
MaxSdk.ShowRewardedAd(rewardedADUnitID, _placement);
break;
}
count++;
yield return new WaitForSeconds(0.5f);
}
if (!result)
{
onVideoAdCompleted?.Invoke(result);
}
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
_waitForVideoAd = null;
}
static int retryAttempt;
public static void InitializeRewardedAds()
{
MaxSdkCallbacks.Rewarded.OnAdLoadedEvent += OnRewardedAdLoadedEvent;
MaxSdkCallbacks.Rewarded.OnAdLoadFailedEvent += OnRewardedAdLoadFailedEvent;
MaxSdkCallbacks.Rewarded.OnAdDisplayedEvent += OnRewardedAdDisplayedEvent;
MaxSdkCallbacks.Rewarded.OnAdClickedEvent += OnRewardedAdClickedEvent;
MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnRewardedAdRevenuePaidEvent;
MaxSdkCallbacks.Rewarded.OnAdHiddenEvent += OnRewardedAdHiddenEvent;
MaxSdkCallbacks.Rewarded.OnAdDisplayFailedEvent += OnRewardedAdFailedToDisplayEvent;
MaxSdkCallbacks.Rewarded.OnAdReceivedRewardEvent += OnRewardedAdReceivedRewardEvent;
MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnRewardedAdRevenueEvent;
LoadRewardedAd();
}
private static void LoadRewardedAd()
{
MaxSdk.LoadRewardedAd(rewardedADUnitID);
BIManager.Instance.TrackAdEvent(BIEvent.AD_REQUEST, "RewardedVideo");
}
private static void OnInterstitialAdRevenueEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
DOVirtual.DelayedCall(0.01f, () =>
{
OnAdRevenuePaidEvent(adUnitId, adInfo, 2);
});
}
private static void OnRewardedAdRevenueEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
DOVirtual.DelayedCall(0.01f, () =>
{
OnAdRevenuePaidEvent(adUnitId, adInfo, 1);
});
}
public static string user_id = "";
private static void OnAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo, int adType)
{
//string countryCode = MaxSdk.GetSdkConfiguration().CountryCode; // "US" for the United States, etc - Note: Do not confuse this with currency code which is "USD"
// //string networkName = adInfo.NetworkName; // Display name of the network that showed the ad
// // string adUnitIdentifier = adInfo.AdUnitIdentifier; // The MAX Ad Unit ID
// //string placement = adInfo.Placement; // The placement this ad's postbacks are tied to
//广告收益上传(用户收益,每次上传)
double revenue = adInfo.Revenue;
if (revenue > 0)
{
GameHelper.AdOverRevenueEvent(adType,(float)revenue);
}
Debug.Log($"[OnAdRevenuePaidEvent] revenue: {revenue} \n adInfo.Revenue: {JsonConvert.SerializeObject(adInfo)}");
if (revenue >= RevenueThreshold)
{
var adCallbackInfo = new Dictionary<string, string>
{
{ "af_revenue", revenue.ToString(CultureInfo.InvariantCulture) }
};
AppsFlyer.sendEvent("af_ad_revenue", adCallbackInfo);
PlayerPrefs.SetString($"adInfoRevenue_{user_id}", "0");
FireBaseManger.OnAdRevenuePaid(adUnitId, adInfo);
}
int highSend;
if (!PlayerPrefs.HasKey($"sendHighRevenue_{user_id}"))
{
highSend = 0; // 如果不存在,则初始化为 0
}
else
{
highSend = PlayerPrefs.GetInt($"sendHighRevenue_{user_id}", 0); // 从 PlayerPrefs 中获取
}
// 判断是否需要发送高收入事件
// Debug.Log($"highSend=====: {highSend}");
if (highSend == 0)
{
float limitNum = GameHelper.GetCommonModel().afSendLimit;
var totalNum = Convert.ToDouble(PlayerPrefs.GetString($"adRevenueTotal_{user_id}", "0"));
totalNum += adInfo.Revenue;
// Debug.Log($"totalNum=====: {totalNum} {limitNum}");
if (totalNum >= limitNum)
{
GameHelper.sendHighRevenueToAF(); // 发送高收入事件
PlayerPrefs.SetInt($"sendHighRevenue_{user_id}", 1); // 标记已发送
}
else
{
PlayerPrefs.SetString($"adRevenueTotal_{user_id}", totalNum.ToString());
}
}
/*
ATTRIBUTION_PLATFORM_APPSFLYER = "AppsFlyer";
ATTRIBUTION_PLATFORM_ADJUST = "Adjust";
ATTRIBUTION_PLATFORM_TENJIN = "Tenjin";
ATTRIBUTION_PLATFORM_SINGULAR = "Singular";
ATTRIBUTION_PLATFORM_KOCHAVA = "Kochava";
ATTRIBUTION_PLATFORM_BRANCH = "Branch";
ATTRIBUTION_PLATFORM_REYUN = "Reyun";
ATTRIBUTION_PLATFORM_SOLAR_ENGINE = "SolarEngine";
...
...
*/
//这里需要改成自己的归因平台名称,这里以Adjust为例,"userid"替换为归因平台UID
// MBridgeRevenueParamsEntity mBridgeRevenueParamsEntity = new MBridgeRevenueParamsEntity(MBridgeRevenueParamsEntity.ATTRIBUTION_PLATFORM_ADJUST, PlayerPrefs.GetString("adjust_adid", "default"));
///MaxSdkBase.AdInfo类型的adInfo
// mBridgeRevenueParamsEntity.SetMaxAdInfo(adInfo);
// MBridgeRevenueManager.Track(mBridgeRevenueParamsEntity);
}
private static void OnRewardedAdLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
retryAttempt = 0;
TrackKit.SendEvent(ADEventTrack.AD_Event, $"{ADEventTrack.Property.ad_load_code}Succeed");
BIManager.Instance.TrackAdEvent(BIEvent.AD_INVENTORY, "RewardedVideo", adInfo.Placement,
adInfo.NetworkName);
}
private static void OnRewardedAdLoadFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
{
retryAttempt++;
double retryDelay = Math.Pow(2, Math.Min(3, retryAttempt));
TrackKit.SendEvent(ADEventTrack.AD_Event, $"{ADEventTrack.Property.ad_load_code}{errorInfo.Code}");
CrazyAsyKit.StartAction("LoadRewardedAd", LoadRewardedAd, (float)retryDelay);
}
private static void OnRewardedAdDisplayedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
TrackKit.SendEvent(ADEventTrack.AD_Event, $"{ADEventTrack.Property.ad_show_code}Succeed");
BIManager.Instance.TrackAdEvent(BIEvent.AD_IMP, "RewardedVideo", adInfo.Placement, adInfo.NetworkName,
adInfo.Revenue, _placement);
}
private static void OnRewardedAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo,
MaxSdkBase.AdInfo adInfo)
{
TrackKit.SendEvent(ADEventTrack.AD_Event, $"{ADEventTrack.Property.ad_show_code}{errorInfo.Code}");
LoadRewardedAd();
}
private static void OnRewardedAdClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
BIManager.Instance.TrackAdEvent(BIEvent.AD_CLICK, "RewardedVideo", adInfo.Placement, adInfo.NetworkName);
}
private static void OnRewardedAdHiddenEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
LoadRewardedAd();
if (_hasReceivedReward && onVideoAdCompleted != null)
{
onVideoAdCompleted(true);
}
onVideoAdCompleted = null;
_hasReceivedReward = false;
if (GameHelper.IsGiftSwitch() && !SaveData.GetSaveObject().is_get_removead && (UnityEngine.Random.Range(0, 100) < GameHelper.GetCommonModel().rewardinsertion))
{
TrackKit.SendEvent(ADEventTrack.AD_Event, ADEventTrack.Property.afterRewardAdShow);
GameHelper.ShowInterstitial("AfterReward");
}
}
private static bool _hasReceivedReward = false;
private static void OnRewardedAdReceivedRewardEvent(string adUnitId, MaxSdk.Reward reward,
MaxSdkBase.AdInfo adInfo)
{
_hasReceivedReward = true;
#if !GAME_RELEASE
GameHelper.AdOverRevenueEvent(1,0.1f);
#endif
}
private static void OnRewardedAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
}
#endregion
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using AppsFlyerSDK;
using DG.Tweening;
using IgnoreOPS;
using Newtonsoft.Json;
using SGModule.NetKit;
// using AppsFlyerSDK;
// using AppsFlyerSDK;
using UnityEngine;
using UnityEngine.Events;
using ZrZYFo6bYXYM71YyLSDK;
namespace BallKingdomCrush
{
public class MaxADKit
{
public static string SDKKey =
"oXM0CzVDi7P1HstOpKvFMInPMOzpQ9uA6t3x75q5f5wQvsEy9vuiiiM94ZJCJSV7PcZGroSSInQCTGsu04QEiE";
public static string interstitialADUnitID = "450445216a84fb16";
public static string rewardedADUnitID = "b979e20045011cb6";
private const float RevenueThreshold = 0;
public static void Init()
{
#if !UNITY_EDITOR
// 注册 ab事件,0或1,0为自然量版本,1为激励版本
ZrZYFo6bYXYM71YyLSDKCONTROLLER.Instance.RegistIosParam((i =>
{
SuperApplication.Instance.attribution = i == 0 ? "organic" : "non_organic";
Debug.Log($"ios ab param : {i} attribution=== {SuperApplication.Instance.attribution}");
NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
}));
void GameConfig(bool result, string config)
{
Debug.Log($"************* game config result : {result}, config : {config}");
}
// SDK初始化方法
ZrZYFo6bYXYM71YyLSDKCONTROLLER.Instance.Init(null, null, GameConfig);
#endif
// MaxSdkCallbacks.OnSdkInitializedEvent += sdkConfiguration =>
// {
// InitializeRewardedAds();
// InitializeInterstitialAds();
// };
//
//
// MaxSdk.SetSdkKey(SDKKey);
//
// // var loginModel = GameHelper.GetLoginModel();
// // user_id = loginModel.uid.ToString();
// // MaxSdk.SetUserId(loginModel.uid.ToString());
// // MaxSdk.SetIsAgeRestrictedUser(false);
// MaxSdk.SetHasUserConsent(true);
// MaxSdk.SetDoNotSell(false);
//
// MaxSdk.InitializeSdk();
// MaxSdk.ShowMediationDebugger();
// #if !UNITY_EDITOR
// MBridgeSDKManager.initialize("368295", "fc0155e8f6e8bda23b06d22414379609");
// #endif
}
public static void SetUserID(string userID)
{
user_id = userID;
MaxSdk.SetUserId(user_id);
}
#region 广
public static UnityAction<bool> onInterstitialAdCompleted = null;
public static bool CheckInterstitialReady()
{
return ZrZYFo6bYXYM71YyLSDKCONTROLLER.Instance.IsInterReady();
}
public static void ShowInterstitial(string placement = "DefaultInterstitial",
UnityAction<bool> onCompleted = null)
{
if (CheckInterstitialReady())
{
Debug.Log($"广告已经准备好,播放");
ZrZYFo6bYXYM71YyLSDKCONTROLLER.Instance.ShowInter(placement, () =>
{
onCompleted?.Invoke(true);
});
}
else
{
Debug.Log($"广告未准备好,不播放");
onCompleted?.Invoke(false);
}
// if (MaxSdk.IsInterstitialReady(interstitialADUnitID))
// {
// // Debug.Log($"广告已经准备好,播放");
// MaxSdk.ShowInterstitial(interstitialADUnitID, placement);
// onInterstitialAdCompleted = onCompleted;
//
// }
// else
// {
// // Debug.Log($"广告未准备好,不播放");
//
// onCompleted?.Invoke(false);
// }
}
static int retryAttemptInterstitial;
public static void InitializeInterstitialAds()
{
MaxSdkCallbacks.Interstitial.OnAdLoadedEvent += OnInterstitialLoadedEvent;
MaxSdkCallbacks.Interstitial.OnAdLoadFailedEvent += OnInterstitialLoadFailedEvent;
MaxSdkCallbacks.Interstitial.OnAdDisplayedEvent += OnInterstitialDisplayedEvent;
MaxSdkCallbacks.Interstitial.OnAdClickedEvent += OnInterstitialClickedEvent;
MaxSdkCallbacks.Interstitial.OnAdHiddenEvent += OnInterstitialHiddenEvent;
MaxSdkCallbacks.Interstitial.OnAdDisplayFailedEvent += OnInterstitialAdFailedToDisplayEvent;
MaxSdkCallbacks.Interstitial.OnAdRevenuePaidEvent += OnInterstitialAdRevenueEvent;
LoadInterstitial();
}
private static void LoadInterstitial()
{
MaxSdk.LoadInterstitial(interstitialADUnitID);
BIManager.Instance.TrackAdEvent(BIEvent.AD_REQUEST, "Interstitial");
}
private static void OnInterstitialLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
retryAttemptInterstitial = 0;
BIManager.Instance.TrackAdEvent(BIEvent.AD_INVENTORY, "Interstitial", adInfo.Placement, adInfo.NetworkName);
}
private static void OnInterstitialLoadFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
{
retryAttemptInterstitial++;
double retryDelay = Math.Pow(2, Math.Min(6, retryAttemptInterstitial));
CrazyAsyKit.StartAction("LoadInterstitial", LoadInterstitial, (float)retryDelay);
}
private static void OnInterstitialDisplayedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
BIManager.Instance.TrackAdEvent(BIEvent.AD_IMP, "Interstitial", adInfo.Placement, adInfo.NetworkName,
adInfo.Revenue, _placement);
}
private static void OnInterstitialAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo,
MaxSdkBase.AdInfo adInfo)
{
LoadInterstitial();
}
private static void OnInterstitialClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
BIManager.Instance.TrackAdEvent(BIEvent.AD_CLICK, "Interstitial", adInfo.Placement, adInfo.NetworkName);
}
private static void OnInterstitialHiddenEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
LoadInterstitial();
onInterstitialAdCompleted?.Invoke(true);
onInterstitialAdCompleted = null;
}
#endregion
#region 广
public static bool CheckRewardedReady()
{
return ZrZYFo6bYXYM71YyLSDKCONTROLLER.Instance.IsVideoReady();
}
public static UnityAction<bool> onVideoAdCompleted = null;
private static string _placement = "";
private static Coroutine _waitForVideoAd = null;
public static void ShowVideo(string placement = "DefaultVideo", UnityAction<bool> onCompleted = null)
{
onVideoAdCompleted = onCompleted;
_placement = placement;
#if UNITY_EDITOR
onVideoAdCompleted?.Invoke(true);
#else
TrackKit.SendEvent(VideoBehaviorTrack.Event, VideoBehaviorTrack.Property.watch_ad_people);
TrackKit.SendEvent(VideoBehaviorTrack.Event, VideoBehaviorTrack.Property.Rewarded_videos_trigger_number);
if (CheckRewardedReady())
{
ZrZYFo6bYXYM71YyLSDKCONTROLLER.Instance.ShowRewardVideo(_placement, b =>
{
onVideoAdCompleted?.Invoke(b);
}, ()=>
{
Debug.Log($"激励广告关闭");
});
}
else
{
onVideoAdCompleted?.Invoke(false);
}
// if (MaxSdk.IsRewardedAdReady(rewardedADUnitID))
// {
// MaxSdk.ShowRewardedAd(rewardedADUnitID, _placement);
// }
// else
// {
// if (_waitForVideoAd != null)
// {
// CrazyAsyKit.StopCoroutine(_waitForVideoAd);
// }
// _waitForVideoAd = CrazyAsyKit.StartCoroutine(WaitForVideoAd());
// }
#endif
}
private static IEnumerator WaitForVideoAd()
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Open);
var count = 0;
var result = false;
while (count < 6)
{
if (MaxSdk.IsRewardedAdReady(rewardedADUnitID))
{
result = true;
MaxSdk.ShowRewardedAd(rewardedADUnitID, _placement);
break;
}
count++;
yield return new WaitForSeconds(0.5f);
}
if (!result)
{
onVideoAdCompleted?.Invoke(result);
}
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PayloadingUI_Close);
_waitForVideoAd = null;
}
static int retryAttempt;
public static void InitializeRewardedAds()
{
MaxSdkCallbacks.Rewarded.OnAdLoadedEvent += OnRewardedAdLoadedEvent;
MaxSdkCallbacks.Rewarded.OnAdLoadFailedEvent += OnRewardedAdLoadFailedEvent;
MaxSdkCallbacks.Rewarded.OnAdDisplayedEvent += OnRewardedAdDisplayedEvent;
MaxSdkCallbacks.Rewarded.OnAdClickedEvent += OnRewardedAdClickedEvent;
MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnRewardedAdRevenuePaidEvent;
MaxSdkCallbacks.Rewarded.OnAdHiddenEvent += OnRewardedAdHiddenEvent;
MaxSdkCallbacks.Rewarded.OnAdDisplayFailedEvent += OnRewardedAdFailedToDisplayEvent;
MaxSdkCallbacks.Rewarded.OnAdReceivedRewardEvent += OnRewardedAdReceivedRewardEvent;
MaxSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnRewardedAdRevenueEvent;
LoadRewardedAd();
}
private static void LoadRewardedAd()
{
MaxSdk.LoadRewardedAd(rewardedADUnitID);
BIManager.Instance.TrackAdEvent(BIEvent.AD_REQUEST, "RewardedVideo");
}
private static void OnInterstitialAdRevenueEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
DOVirtual.DelayedCall(0.01f, () =>
{
OnAdRevenuePaidEvent(adUnitId, adInfo, 2);
});
}
private static void OnRewardedAdRevenueEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
DOVirtual.DelayedCall(0.01f, () =>
{
OnAdRevenuePaidEvent(adUnitId, adInfo, 1);
});
}
public static string user_id = "";
private static void OnAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo, int adType)
{
//string countryCode = MaxSdk.GetSdkConfiguration().CountryCode; // "US" for the United States, etc - Note: Do not confuse this with currency code which is "USD"
// //string networkName = adInfo.NetworkName; // Display name of the network that showed the ad
// // string adUnitIdentifier = adInfo.AdUnitIdentifier; // The MAX Ad Unit ID
// //string placement = adInfo.Placement; // The placement this ad's postbacks are tied to
//广告收益上传(用户收益,每次上传)
double revenue = adInfo.Revenue;
if (revenue > 0)
{
GameHelper.AdOverRevenueEvent(adType,(float)revenue);
}
Debug.Log($"[OnAdRevenuePaidEvent] revenue: {revenue} \n adInfo.Revenue: {JsonConvert.SerializeObject(adInfo)}");
if (revenue >= RevenueThreshold)
{
var adCallbackInfo = new Dictionary<string, string>
{
{ "af_revenue", revenue.ToString(CultureInfo.InvariantCulture) }
};
AppsFlyer.sendEvent("af_ad_revenue", adCallbackInfo);
PlayerPrefs.SetString($"adInfoRevenue_{user_id}", "0");
FireBaseManger.OnAdRevenuePaid(adUnitId, adInfo);
}
int highSend;
if (!PlayerPrefs.HasKey($"sendHighRevenue_{user_id}"))
{
highSend = 0; // 如果不存在,则初始化为 0
}
else
{
highSend = PlayerPrefs.GetInt($"sendHighRevenue_{user_id}", 0); // 从 PlayerPrefs 中获取
}
// 判断是否需要发送高收入事件
// Debug.Log($"highSend=====: {highSend}");
if (highSend == 0)
{
float limitNum = GameHelper.GetCommonModel().afSendLimit;
var totalNum = Convert.ToDouble(PlayerPrefs.GetString($"adRevenueTotal_{user_id}", "0"));
totalNum += adInfo.Revenue;
// Debug.Log($"totalNum=====: {totalNum} {limitNum}");
if (totalNum >= limitNum)
{
GameHelper.sendHighRevenueToAF(); // 发送高收入事件
PlayerPrefs.SetInt($"sendHighRevenue_{user_id}", 1); // 标记已发送
}
else
{
PlayerPrefs.SetString($"adRevenueTotal_{user_id}", totalNum.ToString());
}
}
/*
ATTRIBUTION_PLATFORM_APPSFLYER = "AppsFlyer";
ATTRIBUTION_PLATFORM_ADJUST = "Adjust";
ATTRIBUTION_PLATFORM_TENJIN = "Tenjin";
ATTRIBUTION_PLATFORM_SINGULAR = "Singular";
ATTRIBUTION_PLATFORM_KOCHAVA = "Kochava";
ATTRIBUTION_PLATFORM_BRANCH = "Branch";
ATTRIBUTION_PLATFORM_REYUN = "Reyun";
ATTRIBUTION_PLATFORM_SOLAR_ENGINE = "SolarEngine";
...
...
*/
//这里需要改成自己的归因平台名称,这里以Adjust为例,"userid"替换为归因平台UID
// MBridgeRevenueParamsEntity mBridgeRevenueParamsEntity = new MBridgeRevenueParamsEntity(MBridgeRevenueParamsEntity.ATTRIBUTION_PLATFORM_ADJUST, PlayerPrefs.GetString("adjust_adid", "default"));
///MaxSdkBase.AdInfo类型的adInfo
// mBridgeRevenueParamsEntity.SetMaxAdInfo(adInfo);
// MBridgeRevenueManager.Track(mBridgeRevenueParamsEntity);
}
private static void OnRewardedAdLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
retryAttempt = 0;
TrackKit.SendEvent(ADEventTrack.AD_Event, $"{ADEventTrack.Property.ad_load_code}Succeed");
BIManager.Instance.TrackAdEvent(BIEvent.AD_INVENTORY, "RewardedVideo", adInfo.Placement,
adInfo.NetworkName);
}
private static void OnRewardedAdLoadFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
{
retryAttempt++;
double retryDelay = Math.Pow(2, Math.Min(3, retryAttempt));
TrackKit.SendEvent(ADEventTrack.AD_Event, $"{ADEventTrack.Property.ad_load_code}{errorInfo.Code}");
CrazyAsyKit.StartAction("LoadRewardedAd", LoadRewardedAd, (float)retryDelay);
}
private static void OnRewardedAdDisplayedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
TrackKit.SendEvent(ADEventTrack.AD_Event, $"{ADEventTrack.Property.ad_show_code}Succeed");
BIManager.Instance.TrackAdEvent(BIEvent.AD_IMP, "RewardedVideo", adInfo.Placement, adInfo.NetworkName,
adInfo.Revenue, _placement);
}
private static void OnRewardedAdFailedToDisplayEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo,
MaxSdkBase.AdInfo adInfo)
{
TrackKit.SendEvent(ADEventTrack.AD_Event, $"{ADEventTrack.Property.ad_show_code}{errorInfo.Code}");
LoadRewardedAd();
}
private static void OnRewardedAdClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
BIManager.Instance.TrackAdEvent(BIEvent.AD_CLICK, "RewardedVideo", adInfo.Placement, adInfo.NetworkName);
}
private static void OnRewardedAdHiddenEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
LoadRewardedAd();
if (_hasReceivedReward && onVideoAdCompleted != null)
{
onVideoAdCompleted(true);
}
onVideoAdCompleted = null;
_hasReceivedReward = false;
if (GameHelper.IsGiftSwitch() && !SaveData.GetSaveObject().is_get_removead && (UnityEngine.Random.Range(0, 100) < GameHelper.GetCommonModel().rewardinsertion))
{
TrackKit.SendEvent(ADEventTrack.AD_Event, ADEventTrack.Property.afterRewardAdShow);
GameHelper.ShowInterstitial("AfterReward");
}
}
private static bool _hasReceivedReward = false;
private static void OnRewardedAdReceivedRewardEvent(string adUnitId, MaxSdk.Reward reward,
MaxSdkBase.AdInfo adInfo)
{
_hasReceivedReward = true;
#if !GAME_RELEASE
GameHelper.AdOverRevenueEvent(1,0.1f);
#endif
}
private static void OnRewardedAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
{
}
#endregion
}
}