You've already forked Commercialization.topon
115 lines
3.3 KiB
C#
115 lines
3.3 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using AnyThinkAds.Api;
|
|||
|
|
using Runtime.ADAggregator;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
public class InteractionPlayer : ADPlayer , ATInterstitialAdListener
|
|||
|
|
{
|
|||
|
|
private ATInterstitialAd _atInterstitialAd;
|
|||
|
|
private ADListenerAggregator _aggregator;
|
|||
|
|
|
|||
|
|
public override void OnInit()
|
|||
|
|
{
|
|||
|
|
this._atInterstitialAd = ATInterstitialAd.Instance;
|
|||
|
|
this._aggregator = new ADListenerAggregator();
|
|||
|
|
this._aggregator.BindInterstitialAdListener(this._atInterstitialAd.client,this);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override void ShowAD(Action onClose, Action<bool> onVideoComplete)
|
|||
|
|
{
|
|||
|
|
if (curState == 2)
|
|||
|
|
{
|
|||
|
|
ATInterstitialAd.Instance.showInterstitialAd(this.Key);
|
|||
|
|
curState = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override void LoadAD()
|
|||
|
|
{
|
|||
|
|
if (curState == 0)
|
|||
|
|
{
|
|||
|
|
{
|
|||
|
|
//加载广告
|
|||
|
|
Dictionary<string, object> jsonmap = new Dictionary<string, object>();
|
|||
|
|
//只针对Sigmob,Sigmob的激励视频广告源当做插屏使用
|
|||
|
|
// jsonmap.Add(AnyThinkAds.Api.ATConst.USE_REWARDED_VIDEO_AS_INTERSTITIAL, AnyThinkAds.Api.ATConst.USE_REWARDED_VIDEO_AS_INTERSTITIAL_NO);
|
|||
|
|
var width = (int) (Screen.width * 0.7f);
|
|||
|
|
ATSize atSize = new ATSize(width, (int) (width * 1.5f));
|
|||
|
|
jsonmap.Add(ATInterstitialAdLoadingExtra.kATInterstitialAdLoadingExtraInterstitialAdSizeStruct , atSize);
|
|||
|
|
curState = 1;
|
|||
|
|
this._atInterstitialAd.loadInterstitialAd(this.Key, jsonmap);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region SDK
|
|||
|
|
|
|||
|
|
public void onInterstitialAdLoad(string placementId)
|
|||
|
|
{
|
|||
|
|
this.curState = 2;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void onInterstitialAdLoadFail(string placementId, string code, string message)
|
|||
|
|
{
|
|||
|
|
this.curState = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void onInterstitialAdShow(string placementId, ATCallbackInfo callbackInfo)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void onInterstitialAdFailedToShow(string placementId)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void onInterstitialAdClose(string placementId, ATCallbackInfo callbackInfo)
|
|||
|
|
{
|
|||
|
|
this.adListener.OnAdClose();
|
|||
|
|
this.adListener.OnShowComplete();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void onInterstitialAdClick(string placementId, ATCallbackInfo callbackInfo)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void onInterstitialAdStartPlayingVideo(string placementId, ATCallbackInfo callbackInfo)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void onInterstitialAdEndPlayingVideo(string placementId, ATCallbackInfo callbackInfo)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void onInterstitialAdFailedToPlayVideo(string placementId, string code, string message)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void startLoadingADSource(string placementId, ATCallbackInfo callbackInfo)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void finishLoadingADSource(string placementId, ATCallbackInfo callbackInfo)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void failToLoadADSource(string placementId, ATCallbackInfo callbackInfo, string code, string message)
|
|||
|
|
{
|
|||
|
|
this.OnError(code , message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void startBiddingADSource(string placementId, ATCallbackInfo callbackInfo)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void finishBiddingADSource(string placementId, ATCallbackInfo callbackInfo)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void failBiddingADSource(string placementId, ATCallbackInfo callbackInfo, string code, string message)
|
|||
|
|
{
|
|||
|
|
this.OnError(code , message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|