fix:1、删除上一个sdk,更换新的。2、删除了max广告
This commit is contained in:
@@ -9,7 +9,7 @@ namespace BallKingdomCrush
|
||||
#region Field
|
||||
|
||||
#if GAME_RELEASE
|
||||
public static bool IsEnabledEngineLog = false;
|
||||
public static bool IsEnabledEngineLog = true;
|
||||
#else
|
||||
public static bool IsEnabledEngineLog = true;
|
||||
#endif
|
||||
|
||||
+100
-100
@@ -1,100 +1,100 @@
|
||||
// using Firebase;
|
||||
// using Firebase.Analytics;
|
||||
// using Firebase.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class FireBaseManger: MonoBehaviour
|
||||
{
|
||||
|
||||
public static bool IsReady { get; private set; } = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
// FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task =>
|
||||
// {
|
||||
// if (task.Result == DependencyStatus.Available)
|
||||
// {
|
||||
// Debug.Log("Firebase 初始化成功");
|
||||
//
|
||||
// // 启用 Analytics
|
||||
// FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
|
||||
//
|
||||
// IsReady = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.LogError("Firebase 依赖错误: " + task.Result);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Max 广告的收益上传Firebase
|
||||
/// </summary>
|
||||
/// <param name="adUnitId"></param>
|
||||
/// <param name="adInfo"></param>
|
||||
public static void OnAdRevenuePaid(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
{
|
||||
|
||||
if (!IsReady)
|
||||
{
|
||||
Debug.LogWarning("Firebase 未初始化完成,丢弃本次广告打点");
|
||||
return;
|
||||
}
|
||||
|
||||
double revenue = adInfo.Revenue; // 收入,单位是美元 (USD)
|
||||
string networkName = adInfo.NetworkName;
|
||||
string adFormat = adInfo.AdFormat;
|
||||
string adUnitIdentifier = adInfo.AdUnitIdentifier;
|
||||
|
||||
Debug.Log($"AppLovin 广告收入: {revenue} USD, 网络: {networkName}, 广告位: {adUnitId}");
|
||||
|
||||
// // 上报到 Firebase
|
||||
// var impressionParameters = new[] {
|
||||
// new Firebase.Analytics.Parameter("ad_platform", "AppLovin"),
|
||||
// new Firebase.Analytics.Parameter("ad_source", networkName),
|
||||
// new Firebase.Analytics.Parameter("ad_unit_name", adUnitIdentifier),
|
||||
// new Firebase.Analytics.Parameter("ad_format", adFormat),
|
||||
// new Firebase.Analytics.Parameter("value", revenue),
|
||||
// new Firebase.Analytics.Parameter("currency", "USD"), // All AppLovin revenue is sent in USD
|
||||
// };
|
||||
// Firebase.Analytics.FirebaseAnalytics.LogEvent("ad_impression", impressionParameters);
|
||||
|
||||
Debug.Log("已上报 ad_impression 事件到 Firebase");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 支付的收益上传Firebase
|
||||
/// </summary>
|
||||
public static void OnPayRevenueEvent(double value)
|
||||
{
|
||||
|
||||
if (!IsReady)
|
||||
{
|
||||
Debug.LogWarning("Firebase 未初始化完成,丢弃本次支付打点");
|
||||
return;
|
||||
}
|
||||
Debug.Log($"AppLovin 支付收入: {value} USD");
|
||||
|
||||
// var impressionParameters = new[] {
|
||||
// new Firebase.Analytics.Parameter("value", value),
|
||||
// new Firebase.Analytics.Parameter("currency", "USD"), // All AppLovin revenue is sent in USD
|
||||
// };
|
||||
//
|
||||
// Firebase.Analytics.FirebaseAnalytics.LogEvent("purchase", impressionParameters);
|
||||
|
||||
// 上报到 Firebase 保持标准格式
|
||||
// var parameters = new[] {
|
||||
// new Parameter(FirebaseAnalytics.ParameterValue, value),
|
||||
// new Parameter(FirebaseAnalytics.ParameterCurrency, "USD")
|
||||
// };
|
||||
// FirebaseAnalytics.LogEvent(FirebaseAnalytics.EventPurchase, parameters);
|
||||
|
||||
|
||||
Debug.Log("已上报 purchase 事件到 Firebase");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// // using Firebase;
|
||||
// // using Firebase.Analytics;
|
||||
// // using Firebase.Extensions;
|
||||
// using UnityEngine;
|
||||
//
|
||||
// namespace BallKingdomCrush
|
||||
// {
|
||||
// public class FireBaseManger: MonoBehaviour
|
||||
// {
|
||||
//
|
||||
// public static bool IsReady { get; private set; } = false;
|
||||
//
|
||||
// void Start()
|
||||
// {
|
||||
// // FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task =>
|
||||
// // {
|
||||
// // if (task.Result == DependencyStatus.Available)
|
||||
// // {
|
||||
// // Debug.Log("Firebase 初始化成功");
|
||||
// //
|
||||
// // // 启用 Analytics
|
||||
// // FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
|
||||
// //
|
||||
// // IsReady = true;
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // Debug.LogError("Firebase 依赖错误: " + task.Result);
|
||||
// // }
|
||||
// // });
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// Max 广告的收益上传Firebase
|
||||
// /// </summary>
|
||||
// /// <param name="adUnitId"></param>
|
||||
// /// <param name="adInfo"></param>
|
||||
// public static void OnAdRevenuePaid(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||
// {
|
||||
//
|
||||
// if (!IsReady)
|
||||
// {
|
||||
// Debug.LogWarning("Firebase 未初始化完成,丢弃本次广告打点");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// double revenue = adInfo.Revenue; // 收入,单位是美元 (USD)
|
||||
// string networkName = adInfo.NetworkName;
|
||||
// string adFormat = adInfo.AdFormat;
|
||||
// string adUnitIdentifier = adInfo.AdUnitIdentifier;
|
||||
//
|
||||
// Debug.Log($"AppLovin 广告收入: {revenue} USD, 网络: {networkName}, 广告位: {adUnitId}");
|
||||
//
|
||||
// // // 上报到 Firebase
|
||||
// // var impressionParameters = new[] {
|
||||
// // new Firebase.Analytics.Parameter("ad_platform", "AppLovin"),
|
||||
// // new Firebase.Analytics.Parameter("ad_source", networkName),
|
||||
// // new Firebase.Analytics.Parameter("ad_unit_name", adUnitIdentifier),
|
||||
// // new Firebase.Analytics.Parameter("ad_format", adFormat),
|
||||
// // new Firebase.Analytics.Parameter("value", revenue),
|
||||
// // new Firebase.Analytics.Parameter("currency", "USD"), // All AppLovin revenue is sent in USD
|
||||
// // };
|
||||
// // Firebase.Analytics.FirebaseAnalytics.LogEvent("ad_impression", impressionParameters);
|
||||
//
|
||||
// Debug.Log("已上报 ad_impression 事件到 Firebase");
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// 支付的收益上传Firebase
|
||||
// /// </summary>
|
||||
// public static void OnPayRevenueEvent(double value)
|
||||
// {
|
||||
//
|
||||
// if (!IsReady)
|
||||
// {
|
||||
// Debug.LogWarning("Firebase 未初始化完成,丢弃本次支付打点");
|
||||
// return;
|
||||
// }
|
||||
// Debug.Log($"AppLovin 支付收入: {value} USD");
|
||||
//
|
||||
// // var impressionParameters = new[] {
|
||||
// // new Firebase.Analytics.Parameter("value", value),
|
||||
// // new Firebase.Analytics.Parameter("currency", "USD"), // All AppLovin revenue is sent in USD
|
||||
// // };
|
||||
// //
|
||||
// // Firebase.Analytics.FirebaseAnalytics.LogEvent("purchase", impressionParameters);
|
||||
//
|
||||
// // 上报到 Firebase 保持标准格式
|
||||
// // var parameters = new[] {
|
||||
// // new Parameter(FirebaseAnalytics.ParameterValue, value),
|
||||
// // new Parameter(FirebaseAnalytics.ParameterCurrency, "USD")
|
||||
// // };
|
||||
// // FirebaseAnalytics.LogEvent(FirebaseAnalytics.EventPurchase, parameters);
|
||||
//
|
||||
//
|
||||
// Debug.Log("已上报 purchase 事件到 Firebase");
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@@ -79,7 +79,7 @@ namespace BallKingdomCrush
|
||||
}
|
||||
|
||||
//private IEnumerator Test()
|
||||
//{
|
||||
//{
|
||||
// int index = 0;
|
||||
// while (true)
|
||||
// {
|
||||
|
||||
@@ -108,7 +108,7 @@ public class LoveLegendRoot : MonoBehaviour
|
||||
() => "广告ID信息打印",
|
||||
s =>
|
||||
{
|
||||
adInfoLabel += $"Max token: {MaxADKit.SDKKey} \n 激励广告Id: {MaxADKit.rewardedADUnitID} \n 插屏广告Id: {MaxADKit.interstitialADUnitID} \n";
|
||||
// adInfoLabel += $"Max token: {MaxADKit.SDKKey} \n 激励广告Id: {MaxADKit.rewardedADUnitID} \n 插屏广告Id: {MaxADKit.interstitialADUnitID} \n";
|
||||
|
||||
}));
|
||||
|
||||
|
||||
@@ -1,164 +1,164 @@
|
||||
using System;
|
||||
using SGModule.NetKit;
|
||||
using Spine.Unity;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
using System.Collections;
|
||||
using DG.Tweening;
|
||||
using FGUI.ZM_Login_05;
|
||||
using FGUI.ZM_Game_04;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Video;
|
||||
using FairyGUI;
|
||||
// using FGUI.A000_common;
|
||||
|
||||
public class GameLoginUI : BaseUI
|
||||
{
|
||||
private GameLoginUICtrl ctrl;
|
||||
private GameLoginModel model;
|
||||
private FGUI.ZM_Login_05.com_login_page ui;
|
||||
|
||||
public GameLoginUI(GameLoginUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.GameLoginUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_Login_05";
|
||||
uiInfo.assetName = "com_login_page";
|
||||
uiInfo.layerType = UILayerType.Normal;
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
netFbloadBindLogin?.Kill();
|
||||
CommonHelper.FadeOut(ui);
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenBgUI_Close);
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.ZM_Login_05.com_login_page;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
InitView();
|
||||
|
||||
TrackKit.TrackLoginFunnel(LoginFunnelEventType.EnterButtonShow);
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
CommonHelper.FadeIn(ui);
|
||||
}
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
}
|
||||
|
||||
private Action closeCallback;
|
||||
|
||||
private void InitView()
|
||||
{
|
||||
|
||||
var sk = FXManager.Instance.SetFx<SkeletonAnimation>(ui.leaves_anim, Fx_Type.fx_login_leaves, ref closeCallback);
|
||||
sk.state.SetAnimation(0, "action", true);
|
||||
var sk1 = FXManager.Instance.SetFx<SkeletonAnimation>(ui.light_anim, Fx_Type.fx_login_light, ref closeCallback);
|
||||
sk1.state.SetAnimation(0, "animation", true);
|
||||
|
||||
ui.btn_login.SetClick(OnClickBtn, true);
|
||||
|
||||
App.HideLoadingUI();
|
||||
((com_login_privacy)ui.text_privacy_user).text_privacy_user.SetClick(OnClickPrivacy);
|
||||
((com_login_privacy)ui.text_privacy_user).text_privacy_user.onClickLink.Add((content) =>
|
||||
{
|
||||
switch (content.data)
|
||||
{
|
||||
case "link_href":
|
||||
OnClickTerms();
|
||||
break;
|
||||
case "link_href1":
|
||||
OnClickPrivacy();
|
||||
break;
|
||||
}
|
||||
});
|
||||
ui.btn_space.SetClick(OnclickSpace);
|
||||
// ui.btn_error.SetClick(OnClickError);
|
||||
#if GAME_RELEASE
|
||||
ui.btn_space.visible = false;
|
||||
ui.btn_error.visible = false;
|
||||
#endif
|
||||
|
||||
//zhushi
|
||||
// var temp = new SuccessData();
|
||||
// float[] ch_array = GameHelper.GetRewardValue(2);
|
||||
// temp.ch_number = ch_array[0];
|
||||
// temp.IsWin = true;
|
||||
// temp.IsLevelSuccess = true;
|
||||
// temp.IsH5Reward = false;
|
||||
// temp.rate = (int)ch_array[1];
|
||||
// temp.boost_array = GameHelper.GetRewardBoost(2);
|
||||
// temp.level = GameHelper.GetLevel();
|
||||
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NewEndUI_Open, temp);
|
||||
// / UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LiveUI_Open);
|
||||
|
||||
}
|
||||
private void OnclickSpace()
|
||||
{
|
||||
// Debug.Log("OnclickSpace");
|
||||
#if !UNITY_EDITOR
|
||||
MaxSdk.ShowMediationDebugger();
|
||||
#endif
|
||||
}
|
||||
|
||||
private void OnClickError()
|
||||
{
|
||||
int[] test = new int[5];
|
||||
try
|
||||
{
|
||||
Debug.Log("barry This is a runtime error for testing purposes.");
|
||||
test[10] = 1;
|
||||
// throw new System.Exception($"This is a runtime error for testing purposes. click num = {}");
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.LogError(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private Tween netFbloadBindLogin;
|
||||
|
||||
public void OnClickBtn()
|
||||
{
|
||||
|
||||
TrackKit.TrackLoginFunnel(LoginFunnelEventType.EnterButtonClick);
|
||||
|
||||
CtrlDispatcher.Instance.Dispatch(CtrlMsg.Game_Start);
|
||||
CtrlCloseUI();
|
||||
}
|
||||
|
||||
private void OnClickPrivacy()
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 0);
|
||||
}
|
||||
|
||||
private void OnClickTerms()
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 1);
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using SGModule.NetKit;
|
||||
using Spine.Unity;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
using System.Collections;
|
||||
using DG.Tweening;
|
||||
using FGUI.ZM_Login_05;
|
||||
using FGUI.ZM_Game_04;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Video;
|
||||
using FairyGUI;
|
||||
// using FGUI.A000_common;
|
||||
|
||||
public class GameLoginUI : BaseUI
|
||||
{
|
||||
private GameLoginUICtrl ctrl;
|
||||
private GameLoginModel model;
|
||||
private FGUI.ZM_Login_05.com_login_page ui;
|
||||
|
||||
public GameLoginUI(GameLoginUICtrl ctrl) : base(ctrl)
|
||||
{
|
||||
uiName = UIConst.GameLoginUI;
|
||||
this.ctrl = ctrl;
|
||||
}
|
||||
|
||||
protected override void SetUIInfo(UIInfo uiInfo)
|
||||
{
|
||||
uiInfo.packageName = "ZM_Login_05";
|
||||
uiInfo.assetName = "com_login_page";
|
||||
uiInfo.layerType = UILayerType.Normal;
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
netFbloadBindLogin?.Kill();
|
||||
CommonHelper.FadeOut(ui);
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.OpenBgUI_Close);
|
||||
}
|
||||
|
||||
protected override void OnBind()
|
||||
{
|
||||
ui = baseUI as FGUI.ZM_Login_05.com_login_page;
|
||||
}
|
||||
|
||||
protected override void OnOpenBefore(object args)
|
||||
{
|
||||
InitView();
|
||||
|
||||
TrackKit.TrackLoginFunnel(LoginFunnelEventType.EnterButtonShow);
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected override void OnOpen(object args)
|
||||
{
|
||||
CommonHelper.FadeIn(ui);
|
||||
}
|
||||
|
||||
protected override void AddListener()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void RemoveListener()
|
||||
{
|
||||
}
|
||||
|
||||
private Action closeCallback;
|
||||
|
||||
private void InitView()
|
||||
{
|
||||
|
||||
var sk = FXManager.Instance.SetFx<SkeletonAnimation>(ui.leaves_anim, Fx_Type.fx_login_leaves, ref closeCallback);
|
||||
sk.state.SetAnimation(0, "action", true);
|
||||
var sk1 = FXManager.Instance.SetFx<SkeletonAnimation>(ui.light_anim, Fx_Type.fx_login_light, ref closeCallback);
|
||||
sk1.state.SetAnimation(0, "animation", true);
|
||||
|
||||
ui.btn_login.SetClick(OnClickBtn, true);
|
||||
|
||||
App.HideLoadingUI();
|
||||
((com_login_privacy)ui.text_privacy_user).text_privacy_user.SetClick(OnClickPrivacy);
|
||||
((com_login_privacy)ui.text_privacy_user).text_privacy_user.onClickLink.Add((content) =>
|
||||
{
|
||||
switch (content.data)
|
||||
{
|
||||
case "link_href":
|
||||
OnClickTerms();
|
||||
break;
|
||||
case "link_href1":
|
||||
OnClickPrivacy();
|
||||
break;
|
||||
}
|
||||
});
|
||||
ui.btn_space.SetClick(OnclickSpace);
|
||||
// ui.btn_error.SetClick(OnClickError);
|
||||
#if GAME_RELEASE
|
||||
ui.btn_space.visible = false;
|
||||
ui.btn_error.visible = false;
|
||||
#endif
|
||||
|
||||
//zhushi
|
||||
// var temp = new SuccessData();
|
||||
// float[] ch_array = GameHelper.GetRewardValue(2);
|
||||
// temp.ch_number = ch_array[0];
|
||||
// temp.IsWin = true;
|
||||
// temp.IsLevelSuccess = true;
|
||||
// temp.IsH5Reward = false;
|
||||
// temp.rate = (int)ch_array[1];
|
||||
// temp.boost_array = GameHelper.GetRewardBoost(2);
|
||||
// temp.level = GameHelper.GetLevel();
|
||||
// UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NewEndUI_Open, temp);
|
||||
// / UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LiveUI_Open);
|
||||
|
||||
}
|
||||
private void OnclickSpace()
|
||||
{
|
||||
// Debug.Log("OnclickSpace");
|
||||
#if !UNITY_EDITOR
|
||||
// MaxSdk.ShowMediationDebugger();
|
||||
#endif
|
||||
}
|
||||
|
||||
private void OnClickError()
|
||||
{
|
||||
int[] test = new int[5];
|
||||
try
|
||||
{
|
||||
Debug.Log("barry This is a runtime error for testing purposes.");
|
||||
test[10] = 1;
|
||||
// throw new System.Exception($"This is a runtime error for testing purposes. click num = {}");
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.LogError(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private Tween netFbloadBindLogin;
|
||||
|
||||
public void OnClickBtn()
|
||||
{
|
||||
|
||||
TrackKit.TrackLoginFunnel(LoginFunnelEventType.EnterButtonClick);
|
||||
|
||||
CtrlDispatcher.Instance.Dispatch(CtrlMsg.Game_Start);
|
||||
CtrlCloseUI();
|
||||
}
|
||||
|
||||
private void OnClickPrivacy()
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 0);
|
||||
}
|
||||
|
||||
private void OnClickTerms()
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.PrivacyUI_Open, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ using SGModule.GooglePay;
|
||||
using SGModule.Net;
|
||||
using SGModule.NetKit;
|
||||
using UnityEngine;
|
||||
using ZrZYFo6bYXYM71YyLSDK;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
|
||||
@@ -209,7 +209,7 @@ public class PurchasingManager
|
||||
|
||||
_isChecking = true;
|
||||
|
||||
GooglePayManager.Instance.CheckSubscription(OnCheckFinished);
|
||||
// GooglePayManager.Instance.CheckSubscription(OnCheckFinished);
|
||||
}
|
||||
|
||||
private static void OnCheckFinished(bool success)
|
||||
|
||||
@@ -76,8 +76,8 @@ namespace BallKingdomCrush
|
||||
TrackKit.TrackLoginFunnel(LoginFunnelEventType.LoadFinish); //加载完成打点
|
||||
|
||||
ParseGameConfig();
|
||||
TextureHelper.imgUrl = CdnURL + "/" + ConfigSystem.GetCommonConf().ResVersion + "/";
|
||||
LiveVideoManager.videoBaseUrl = CdnURL + "/" + ConfigSystem.GetCommonConf().ResVersion + "/";
|
||||
TextureHelper.imgUrl = CdnURL + "/" + GetConfigResVersion() + "/";
|
||||
LiveVideoManager.videoBaseUrl = CdnURL + "/" + GetConfigResVersion() + "/";
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.NetLoadingUI_Close);
|
||||
AppDispatcher.Instance.Dispatch(AppMsg.LoginInit);
|
||||
CtrlDispatcher.Instance.Dispatch(CtrlMsg.Game_StartBefore);
|
||||
@@ -138,6 +138,28 @@ namespace BallKingdomCrush
|
||||
return ConfigLoader.Instance.GetConfig<CommonModel>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>true:非自然 false:自然</returns>
|
||||
public static bool IsOrganic()
|
||||
{
|
||||
bool b = false;
|
||||
|
||||
if (GameHelper.IsGiftSwitch() && SuperApplication.Instance.attribution == "organic")
|
||||
{
|
||||
b = GetCommonConf().IsOrganic == 1;
|
||||
}
|
||||
|
||||
Debug.Log($"下载---------开关:{b}");
|
||||
return b;
|
||||
}
|
||||
|
||||
public static string GetConfigResVersion()
|
||||
{
|
||||
return IsOrganic() ? GetCommonConf().ResVersion : GetCommonConf().ResVersion1;
|
||||
}
|
||||
|
||||
public static List<T> GetConfig<T>() where T : class
|
||||
{
|
||||
return ConfigLoader.Instance.GetConfig<List<T>>() ?? new List<T>();
|
||||
@@ -145,7 +167,7 @@ namespace BallKingdomCrush
|
||||
|
||||
private static List<T> GetConfigWithOrganicFallback<T, TOrganic>() where T : class
|
||||
{
|
||||
if (GameHelper.IsGiftSwitch() && SuperApplication.Instance.attribution == "organic")
|
||||
if (!IsOrganic())
|
||||
{
|
||||
var organicConfig = ConfigLoader.Instance.GetConfig<List<TOrganic>>();
|
||||
if (organicConfig != null)
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace BallKingdomCrush {
|
||||
|
||||
NetworkDispatcher.Instance.Dispatch(NetworkMsg.GetPlayData);
|
||||
|
||||
MaxADKit.SetUserID(loginData.Uid.As<string>());
|
||||
// MaxADKit.SetUserID(loginData.Uid.As<string>());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+101
-101
@@ -1,102 +1,102 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
|
||||
public class Rescrypt
|
||||
{
|
||||
// 魔法字节标记
|
||||
private static readonly byte[] Magic = Encoding.UTF8.GetBytes("SGENCRY");
|
||||
// 解密文件:从 src 读出,解密后写到 dst
|
||||
public static void DecryptFile(string src, string dst)
|
||||
{
|
||||
var key = ConfigSystem.GetCommonConf().ResVersion;
|
||||
var data = File.ReadAllBytes(src);
|
||||
// 检查魔法字节
|
||||
if (data.Length < Magic.Length || !data.Take(Magic.Length).SequenceEqual(Magic)) throw new InvalidDataException("文件未加密或格式错误");
|
||||
// 去掉魔法字节
|
||||
var raw = data.Skip(Magic.Length).ToArray();
|
||||
|
||||
// 使用 MD5.Create() 计算 MD5
|
||||
byte[] rawHash;
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
rawHash = md5.ComputeHash(Encoding.UTF8.GetBytes(key));
|
||||
}
|
||||
// 转成 32 字节十六进制 ASCII,与 Go 端 hex.EncodeToString 对应
|
||||
var keyBytes = Encoding.ASCII.GetBytes(BitConverter.ToString(rawHash).Replace("-", "").ToLower());
|
||||
// 解密
|
||||
var dec = KeyReverseDecryptData(raw, keyBytes);
|
||||
// 写出解密后的文件
|
||||
File.WriteAllBytes(dst, dec);
|
||||
// 删除临时源文件(加密的)
|
||||
File.Delete(src);
|
||||
}
|
||||
|
||||
public static byte[] DecryptFileToBytes(string src)
|
||||
{
|
||||
var data = File.ReadAllBytes(src);
|
||||
|
||||
var key = ConfigSystem.GetCommonConf().ResVersion;
|
||||
|
||||
// 检查魔法字节
|
||||
if (data.Length < Magic.Length || !data.Take(Magic.Length).SequenceEqual(Magic))
|
||||
throw new InvalidDataException("文件未加密或格式错误");
|
||||
|
||||
// 去掉魔法字节
|
||||
var raw = data.Skip(Magic.Length).ToArray();
|
||||
|
||||
// 使用 MD5.Create() 计算 MD5
|
||||
byte[] rawHash;
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
rawHash = md5.ComputeHash(Encoding.UTF8.GetBytes(key));
|
||||
}
|
||||
// 转成 32 字节十六进制 ASCII,与 Go 端 hex.EncodeToString 对应
|
||||
var keyBytes = Encoding.ASCII.GetBytes(BitConverter.ToString(rawHash).Replace("-", "").ToLower());
|
||||
|
||||
// 解密并返回
|
||||
return KeyReverseDecryptData(raw, keyBytes);
|
||||
}
|
||||
|
||||
public static byte[] DecryptVideoToBytes(string src)
|
||||
{
|
||||
var key = ConfigSystem.GetCommonConf().ResVersion;
|
||||
|
||||
var data = File.ReadAllBytes(src);
|
||||
if (data.Length < Magic.Length || !data.Take(Magic.Length).SequenceEqual(Magic))
|
||||
throw new InvalidDataException("视频未加密或格式错误");
|
||||
|
||||
var raw = data.Skip(Magic.Length).ToArray();
|
||||
|
||||
// 使用 MD5.Create() 计算 MD5
|
||||
byte[] rawHash;
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
rawHash = md5.ComputeHash(Encoding.UTF8.GetBytes(key));
|
||||
}
|
||||
// 转成 32 字节十六进制 ASCII,与 Go 端 hex.EncodeToString 对应
|
||||
var keyBytes = Encoding.ASCII.GetBytes(BitConverter.ToString(rawHash).Replace("-", "").ToLower());
|
||||
|
||||
return KeyReverseDecryptData(raw, keyBytes);
|
||||
}
|
||||
|
||||
|
||||
// 基础解密:XOR + 反序
|
||||
private static byte[] KeyReverseDecryptData(byte[] data, byte[] key)
|
||||
{
|
||||
var keyLen = key.Length;
|
||||
// XOR
|
||||
for (var i = 0; i < data.Length; i++)
|
||||
data[i] ^= key[i % keyLen];
|
||||
// 反序
|
||||
for (int i = 0, j = data.Length - 1; i < j; i++, j--)
|
||||
(data[i], data[j]) = (data[j], data[i]);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
|
||||
public class Rescrypt
|
||||
{
|
||||
// 魔法字节标记
|
||||
private static readonly byte[] Magic = Encoding.UTF8.GetBytes("SGENCRY");
|
||||
// 解密文件:从 src 读出,解密后写到 dst
|
||||
public static void DecryptFile(string src, string dst)
|
||||
{
|
||||
var key = ConfigSystem.GetConfigResVersion();
|
||||
var data = File.ReadAllBytes(src);
|
||||
// 检查魔法字节
|
||||
if (data.Length < Magic.Length || !data.Take(Magic.Length).SequenceEqual(Magic)) throw new InvalidDataException("文件未加密或格式错误");
|
||||
// 去掉魔法字节
|
||||
var raw = data.Skip(Magic.Length).ToArray();
|
||||
|
||||
// 使用 MD5.Create() 计算 MD5
|
||||
byte[] rawHash;
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
rawHash = md5.ComputeHash(Encoding.UTF8.GetBytes(key));
|
||||
}
|
||||
// 转成 32 字节十六进制 ASCII,与 Go 端 hex.EncodeToString 对应
|
||||
var keyBytes = Encoding.ASCII.GetBytes(BitConverter.ToString(rawHash).Replace("-", "").ToLower());
|
||||
// 解密
|
||||
var dec = KeyReverseDecryptData(raw, keyBytes);
|
||||
// 写出解密后的文件
|
||||
File.WriteAllBytes(dst, dec);
|
||||
// 删除临时源文件(加密的)
|
||||
File.Delete(src);
|
||||
}
|
||||
|
||||
public static byte[] DecryptFileToBytes(string src)
|
||||
{
|
||||
var data = File.ReadAllBytes(src);
|
||||
|
||||
var key = ConfigSystem.GetConfigResVersion();
|
||||
|
||||
// 检查魔法字节
|
||||
if (data.Length < Magic.Length || !data.Take(Magic.Length).SequenceEqual(Magic))
|
||||
throw new InvalidDataException("文件未加密或格式错误");
|
||||
|
||||
// 去掉魔法字节
|
||||
var raw = data.Skip(Magic.Length).ToArray();
|
||||
|
||||
// 使用 MD5.Create() 计算 MD5
|
||||
byte[] rawHash;
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
rawHash = md5.ComputeHash(Encoding.UTF8.GetBytes(key));
|
||||
}
|
||||
// 转成 32 字节十六进制 ASCII,与 Go 端 hex.EncodeToString 对应
|
||||
var keyBytes = Encoding.ASCII.GetBytes(BitConverter.ToString(rawHash).Replace("-", "").ToLower());
|
||||
|
||||
// 解密并返回
|
||||
return KeyReverseDecryptData(raw, keyBytes);
|
||||
}
|
||||
|
||||
public static byte[] DecryptVideoToBytes(string src)
|
||||
{
|
||||
var key = ConfigSystem.GetConfigResVersion();
|
||||
|
||||
var data = File.ReadAllBytes(src);
|
||||
if (data.Length < Magic.Length || !data.Take(Magic.Length).SequenceEqual(Magic))
|
||||
throw new InvalidDataException("视频未加密或格式错误");
|
||||
|
||||
var raw = data.Skip(Magic.Length).ToArray();
|
||||
|
||||
// 使用 MD5.Create() 计算 MD5
|
||||
byte[] rawHash;
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
rawHash = md5.ComputeHash(Encoding.UTF8.GetBytes(key));
|
||||
}
|
||||
// 转成 32 字节十六进制 ASCII,与 Go 端 hex.EncodeToString 对应
|
||||
var keyBytes = Encoding.ASCII.GetBytes(BitConverter.ToString(rawHash).Replace("-", "").ToLower());
|
||||
|
||||
return KeyReverseDecryptData(raw, keyBytes);
|
||||
}
|
||||
|
||||
|
||||
// 基础解密:XOR + 反序
|
||||
private static byte[] KeyReverseDecryptData(byte[] data, byte[] key)
|
||||
{
|
||||
var keyLen = key.Length;
|
||||
// XOR
|
||||
for (var i = 0; i < data.Length; i++)
|
||||
data[i] ^= key[i % keyLen];
|
||||
// 反序
|
||||
for (int i = 0, j = data.Length - 1; i < j; i++, j--)
|
||||
(data[i], data[j]) = (data[j], data[i]);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using AppsFlyerSDK;
|
||||
using ASMhQ45fSDK;
|
||||
using DG.Tweening;
|
||||
using IgnoreOPS;
|
||||
using Newtonsoft.Json;
|
||||
@@ -13,31 +14,18 @@ using SGModule.NetKit;
|
||||
// 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 =>
|
||||
ASMhQ45fSDKUTILITY.Instance.RegistIosParam((i =>
|
||||
{
|
||||
SuperApplication.Instance.attribution = i == 0 ? "organic" : "non_organic";
|
||||
Debug.Log($"ios ab param : {i} attribution=== {SuperApplication.Instance.attribution}");
|
||||
@@ -50,45 +38,18 @@ namespace BallKingdomCrush
|
||||
Debug.Log($"************* game config result : {result}, config : {config}");
|
||||
}
|
||||
// SDK初始化方法
|
||||
ZrZYFo6bYXYM71YyLSDKCONTROLLER.Instance.Init(null, null, GameConfig);
|
||||
ASMhQ45fSDKUTILITY.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();
|
||||
return ASMhQ45fSDKUTILITY.Instance.IsInterReady();
|
||||
}
|
||||
public static void ShowInterstitial(string placement = "DefaultInterstitial",
|
||||
UnityAction<bool> onCompleted = null)
|
||||
@@ -96,15 +57,21 @@ namespace BallKingdomCrush
|
||||
if (CheckInterstitialReady())
|
||||
{
|
||||
Debug.Log($"广告已经准备好,播放");
|
||||
ZrZYFo6bYXYM71YyLSDKCONTROLLER.Instance.ShowInter(placement, () =>
|
||||
ASMhQ45fSDKUTILITY.Instance.ShowInter(placement, () =>
|
||||
{
|
||||
onCompleted?.Invoke(true);
|
||||
DOVirtual.DelayedCall(0.1f, () =>
|
||||
{
|
||||
onCompleted?.Invoke(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"广告未准备好,不播放");
|
||||
onCompleted?.Invoke(false);
|
||||
DOVirtual.DelayedCall(0.1f, () =>
|
||||
{
|
||||
onCompleted?.Invoke(false);
|
||||
});
|
||||
}
|
||||
|
||||
// if (MaxSdk.IsInterstitialReady(interstitialADUnitID))
|
||||
@@ -122,74 +89,15 @@ namespace BallKingdomCrush
|
||||
// }
|
||||
}
|
||||
|
||||
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();
|
||||
return ASMhQ45fSDKUTILITY.Instance.IsVideoReady();
|
||||
}
|
||||
|
||||
public static UnityAction<bool> onVideoAdCompleted = null;
|
||||
@@ -207,23 +115,32 @@ namespace BallKingdomCrush
|
||||
|
||||
if (CheckRewardedReady())
|
||||
{
|
||||
ZrZYFo6bYXYM71YyLSDKCONTROLLER.Instance.ShowRewardVideo(_placement, b =>
|
||||
ASMhQ45fSDKUTILITY.Instance.ShowRewardVideo(_placement, b =>
|
||||
{
|
||||
onVideoAdCompleted?.Invoke(b);
|
||||
DOVirtual.DelayedCall(0.1f, () =>
|
||||
{
|
||||
onVideoAdCompleted?.Invoke(b);
|
||||
});
|
||||
}, ()=>
|
||||
{
|
||||
Debug.Log($"激励广告关闭");
|
||||
if (GameHelper.IsGiftSwitch() && !SaveData.GetSaveObject().is_get_removead && (UnityEngine.Random.Range(0, 100) < GameHelper.GetCommonModel().rewardinsertion))
|
||||
DOVirtual.DelayedCall(0.2f, () =>
|
||||
{
|
||||
TrackKit.SendEvent(ADEventTrack.AD_Event, ADEventTrack.Property.afterRewardAdShow);
|
||||
Debug.Log($"激励广告关闭");
|
||||
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");
|
||||
}
|
||||
GameHelper.ShowInterstitial("AfterReward");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
onVideoAdCompleted?.Invoke(false);
|
||||
DOVirtual.DelayedCall(0.1f, () =>
|
||||
{
|
||||
onVideoAdCompleted?.Invoke(false);
|
||||
});
|
||||
}
|
||||
// if (MaxSdk.IsRewardedAdReady(rewardedADUnitID))
|
||||
// {
|
||||
@@ -240,229 +157,6 @@ namespace BallKingdomCrush
|
||||
#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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user