release: 1.4.7

This commit is contained in:
2026-04-22 17:44:49 +08:00
parent 79f478dd5f
commit e38e066a2d
37 changed files with 2598 additions and 78 deletions

View File

@@ -7,28 +7,83 @@ using UnityEngine;
public class InteractionPlayer : ADPlayer , ATInterstitialAdListener
{
private ATInterstitialAd _atInterstitialAd;
private ATInterstitialAutoAd _atInterstitialAutoAd;
private ADListenerAggregator _aggregator;
private bool _autoLoadRegistered;
public override void OnInit()
{
this._atInterstitialAd = ATInterstitialAd.Instance;
this._atInterstitialAutoAd = ATInterstitialAutoAd.Instance;
this._aggregator = new ADListenerAggregator();
this._aggregator.BindInterstitialAdListener(this._atInterstitialAd.client,this);
}
public override void ShowAD(Action onClose, Action<bool> onVideoComplete)
{
if (curState == 2)
if (this.IsReadly())
{
ATInterstitialAd.Instance.showInterstitialAd(this.Key);
this.adListener.onClose = onClose;
this.adListener.onVideoComplete = onVideoComplete;
if (UseAutoLoad())
{
EnsureAutoLoadRegistered();
this._atInterstitialAutoAd.showAutoAd(this.Key, BuildInterstitialExtra());
}
else
{
ATInterstitialAd.Instance.showInterstitialAd(this.Key);
}
curState = 0;
}
}
public override bool IsReadly()
{
if (this.curState == 2)
{
return true;
}
if (UseAutoLoad())
{
if (this._atInterstitialAutoAd != null &&
this._atInterstitialAutoAd.autoLoadInterstitialAdReadyForPlacementID(this.Key))
{
this.curState = 2;
return true;
}
return false;
}
if (this._atInterstitialAd != null && this._atInterstitialAd.hasInterstitialAdReady(this.Key))
{
this.curState = 2;
return true;
}
return false;
}
public override void LoadAD()
{
if (curState == 0)
{
if (UseAutoLoad())
{
EnsureAutoLoadRegistered();
this._atInterstitialAutoAd.setAutoLocalExtra(this.Key, BuildInterstitialExtra());
this.curState = this._atInterstitialAutoAd.autoLoadInterstitialAdReadyForPlacementID(this.Key) ? 2 : 1;
return;
}
if (this._atInterstitialAd != null && this._atInterstitialAd.hasInterstitialAdReady(this.Key))
{
this.curState = 2;
return;
}
{
//加载广告
Dictionary<string, object> jsonmap = new Dictionary<string, object>();
@@ -61,6 +116,8 @@ public class InteractionPlayer : ADPlayer , ATInterstitialAdListener
public void onInterstitialAdFailedToShow(string placementId)
{
this.curState = 0;
this.adListener.OnShowError();
}
public void onInterstitialAdClose(string placementId, ATCallbackInfo callbackInfo)
@@ -83,6 +140,8 @@ public class InteractionPlayer : ADPlayer , ATInterstitialAdListener
public void onInterstitialAdFailedToPlayVideo(string placementId, string code, string message)
{
this.curState = 0;
this.adListener.OnShowError();
}
public void startLoadingADSource(string placementId, ATCallbackInfo callbackInfo)
@@ -112,4 +171,61 @@ public class InteractionPlayer : ADPlayer , ATInterstitialAdListener
}
#endregion
}
public override void OnPlayRequestStarted()
{
if (UseAutoLoad())
{
EnsureAutoLoadRegistered();
this._atInterstitialAutoAd?.setAutoLocalExtra(this.Key, BuildInterstitialExtra());
}
}
public override int MaxLoadAttempts => ToponAdController.CurrentOptions?.InterstitialMaxLoadAttempts ?? base.MaxLoadAttempts;
public override float LoadRetryDelaySeconds =>
Math.Max(0f, (ToponAdController.CurrentOptions?.InterstitialLoadRetryDelayMs ?? 500) / 1000f);
public override bool AutoPreloadOnInit => ToponAdController.CurrentOptions?.InterstitialPrewarmOnInit ?? true;
private bool UseAutoLoad()
{
return ToponAdController.CurrentOptions?.InterstitialAutoLoad ?? true;
}
private void EnsureAutoLoadRegistered()
{
if (_autoLoadRegistered)
{
return;
}
this._atInterstitialAutoAd?.addAutoLoadAdPlacementID(new[] { this.Key });
_autoLoadRegistered = true;
}
private Dictionary<string, string> BuildInterstitialExtra()
{
return new Dictionary<string, string>
{
{ ATConst.SCENARIO, this.AdScene ?? string.Empty }
};
}
public override void EnterAdScenario(string scenario)
{
if (string.IsNullOrWhiteSpace(scenario) || string.Equals(scenario, "__default__", StringComparison.Ordinal))
{
return;
}
if (UseAutoLoad())
{
EnsureAutoLoadRegistered();
this._atInterstitialAutoAd?.entryAutoAdScenarioWithPlacementID(this.Key, scenario);
return;
}
this._atInterstitialAd?.entryScenarioWithPlacementID(this.Key, scenario);
}
}