feat:1、添加项目
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using AppsFlyerSDK;
|
||||
using ASMhQ45fSDK;
|
||||
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 void Init()
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
// 注册 ab事件,0或1,0为自然量版本,1为激励版本
|
||||
ASMhQ45fSDKUTILITY.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初始化方法
|
||||
ASMhQ45fSDKUTILITY.Instance.Init(null, null, GameConfig);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#region 插屏广告相关
|
||||
public static UnityAction<bool> onInterstitialAdCompleted = null;
|
||||
|
||||
public static bool CheckInterstitialReady()
|
||||
{
|
||||
return ASMhQ45fSDKUTILITY.Instance.IsInterReady();
|
||||
}
|
||||
public static void ShowInterstitial(string placement = "DefaultInterstitial",
|
||||
UnityAction<bool> onCompleted = null)
|
||||
{
|
||||
if (CheckInterstitialReady())
|
||||
{
|
||||
Debug.Log($"广告已经准备好,播放");
|
||||
ASMhQ45fSDKUTILITY.Instance.ShowInter(placement, () =>
|
||||
{
|
||||
DOVirtual.DelayedCall(0.1f, () =>
|
||||
{
|
||||
onCompleted?.Invoke(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"广告未准备好,不播放");
|
||||
DOVirtual.DelayedCall(0.1f, () =>
|
||||
{
|
||||
onCompleted?.Invoke(false);
|
||||
});
|
||||
}
|
||||
|
||||
// if (MaxSdk.IsInterstitialReady(interstitialADUnitID))
|
||||
// {
|
||||
// // Debug.Log($"广告已经准备好,播放");
|
||||
// MaxSdk.ShowInterstitial(interstitialADUnitID, placement);
|
||||
// onInterstitialAdCompleted = onCompleted;
|
||||
//
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // Debug.Log($"广告未准备好,不播放");
|
||||
//
|
||||
// onCompleted?.Invoke(false);
|
||||
// }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 激励视频广告相关
|
||||
|
||||
public static bool CheckRewardedReady()
|
||||
{
|
||||
return ASMhQ45fSDKUTILITY.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())
|
||||
{
|
||||
ASMhQ45fSDKUTILITY.Instance.ShowRewardVideo(_placement, b =>
|
||||
{
|
||||
DOVirtual.DelayedCall(0.1f, () =>
|
||||
{
|
||||
onVideoAdCompleted?.Invoke(b);
|
||||
});
|
||||
}, ()=>
|
||||
{
|
||||
DOVirtual.DelayedCall(0.2f, () =>
|
||||
{
|
||||
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");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
DOVirtual.DelayedCall(0.1f, () =>
|
||||
{
|
||||
onVideoAdCompleted?.Invoke(false);
|
||||
});
|
||||
}
|
||||
// if (MaxSdk.IsRewardedAdReady(rewardedADUnitID))
|
||||
// {
|
||||
// MaxSdk.ShowRewardedAd(rewardedADUnitID, _placement);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (_waitForVideoAd != null)
|
||||
// {
|
||||
// CrazyAsyKit.StopCoroutine(_waitForVideoAd);
|
||||
// }
|
||||
// _waitForVideoAd = CrazyAsyKit.StartCoroutine(WaitForVideoAd());
|
||||
// }
|
||||
#endif
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user