2026-06-04 17:16:17 +08:00
|
|
|
using System;
|
2026-06-17 15:40:25 +08:00
|
|
|
using System.Collections.Generic;
|
2026-06-04 17:16:17 +08:00
|
|
|
using Dirichlet.Mediation;
|
|
|
|
|
using Runtime.ADAggregator;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public sealed class TapadnAwardVideoPlayer : ADPlayer, IDirichletRewardVideoAutoAdListener
|
|
|
|
|
{
|
2026-06-04 17:24:54 +08:00
|
|
|
private const float RewardCloseSettleDelaySeconds = 0.25f;
|
|
|
|
|
|
2026-06-17 15:40:25 +08:00
|
|
|
private readonly Dictionary<string, RewardedSlotCache> _slotCaches = new Dictionary<string, RewardedSlotCache>(StringComparer.Ordinal);
|
|
|
|
|
|
2026-06-04 17:16:17 +08:00
|
|
|
private DirichletAdNative _adNative;
|
2026-06-17 15:40:25 +08:00
|
|
|
private string _defaultSlotId;
|
|
|
|
|
private string _activeSlotId;
|
2026-06-04 17:16:17 +08:00
|
|
|
private bool _rewardVerified;
|
2026-06-04 17:24:54 +08:00
|
|
|
private bool _rewardVerifyReceived;
|
|
|
|
|
private bool _closePendingRewardVerify;
|
|
|
|
|
private bool _showSettled;
|
|
|
|
|
private AdTimeHandler _rewardCloseSettleHandler;
|
2026-06-04 17:16:17 +08:00
|
|
|
|
|
|
|
|
public override int MaxLoadAttempts => TapadnAdController.CurrentOptions?.RewardedMaxLoadAttempts ?? base.MaxLoadAttempts;
|
|
|
|
|
public override float LoadRetryDelaySeconds => Math.Max(0f, (TapadnAdController.CurrentOptions?.RewardedLoadRetryDelayMs ?? 500) / 1000f);
|
|
|
|
|
public override float ShowPendingTimeoutSeconds => Math.Max(1f, (TapadnAdController.CurrentOptions?.RewardedShowTimeoutMs ?? 20000) / 1000f);
|
|
|
|
|
public override bool AutoPreloadOnInit => TapadnAdController.CurrentOptions?.RewardedPrewarmOnInit ?? false;
|
|
|
|
|
|
|
|
|
|
public override void OnInit()
|
|
|
|
|
{
|
2026-06-17 15:40:25 +08:00
|
|
|
_defaultSlotId = Key;
|
2026-06-04 17:16:17 +08:00
|
|
|
_adNative = DirichletAdManager.CreateAdNative();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool IsReadly()
|
|
|
|
|
{
|
2026-06-17 15:40:25 +08:00
|
|
|
var slotId = ResolveCurrentSlotId();
|
2026-06-04 17:16:17 +08:00
|
|
|
if (UseAutoLoad())
|
|
|
|
|
{
|
2026-06-17 15:40:25 +08:00
|
|
|
return TapadnAdRequestFactory.TryParseSlotId(slotId, out _);
|
2026-06-04 17:16:17 +08:00
|
|
|
}
|
|
|
|
|
|
2026-06-17 15:40:25 +08:00
|
|
|
var cache = GetCache(slotId);
|
|
|
|
|
if (IsCacheReady(cache))
|
2026-06-04 17:16:17 +08:00
|
|
|
{
|
|
|
|
|
curState = 2;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-17 15:40:25 +08:00
|
|
|
if (cache != null && cache.Loading)
|
|
|
|
|
{
|
|
|
|
|
curState = 1;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cache != null)
|
|
|
|
|
{
|
|
|
|
|
RemoveCache(slotId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
curState = 0;
|
2026-06-04 17:16:17 +08:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void LoadAD()
|
|
|
|
|
{
|
2026-06-17 18:15:02 +08:00
|
|
|
var slotId = ResolveCurrentSlotId(out var mapped);
|
|
|
|
|
Debug.Log($"[TapADN] Rewarded load requested. scene={NormalizeScenario(AdScene)}, slot={slotId}, source={GetSlotSource(mapped)}, auto={UseAutoLoad()}");
|
2026-06-17 15:40:25 +08:00
|
|
|
if (!TapadnAdRequestFactory.TryParseSlotId(slotId, out _))
|
2026-06-04 17:16:17 +08:00
|
|
|
{
|
2026-06-17 15:40:25 +08:00
|
|
|
Debug.LogError($"[TapADN] Invalid rewarded slot id: {slotId}");
|
2026-06-04 17:16:17 +08:00
|
|
|
curState = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (UseAutoLoad())
|
|
|
|
|
{
|
|
|
|
|
curState = 2;
|
|
|
|
|
try
|
|
|
|
|
{
|
2026-06-17 15:40:25 +08:00
|
|
|
_adNative.PreLoad(TapadnAdRequestFactory.BuildRewarded(slotId, TapadnAdController.CurrentOptions), 3);
|
2026-06-04 17:16:17 +08:00
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogWarning($"[TapADN] Rewarded preload skipped: {exception.Message}");
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-17 15:40:25 +08:00
|
|
|
var cache = GetCache(slotId);
|
|
|
|
|
if (cache != null && (cache.Loading || IsCacheReady(cache)))
|
2026-06-04 17:16:17 +08:00
|
|
|
{
|
2026-06-17 15:40:25 +08:00
|
|
|
curState = cache.Loading ? 1 : 2;
|
2026-06-04 17:16:17 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-17 15:40:25 +08:00
|
|
|
cache = new RewardedSlotCache { Loading = true };
|
|
|
|
|
_slotCaches[slotId] = cache;
|
2026-06-04 17:16:17 +08:00
|
|
|
curState = 1;
|
2026-06-17 15:40:25 +08:00
|
|
|
TapadnSmartLoadOrchestrator.OnLoadStarted(AD_Type.AwardVideo, AdScene, slotId);
|
2026-06-04 17:16:17 +08:00
|
|
|
_adNative.LoadRewardVideoAd(
|
2026-06-17 15:40:25 +08:00
|
|
|
TapadnAdRequestFactory.BuildRewarded(slotId, TapadnAdController.CurrentOptions),
|
2026-06-04 17:16:17 +08:00
|
|
|
ad =>
|
|
|
|
|
{
|
2026-06-17 15:40:25 +08:00
|
|
|
TapadnSmartLoadOrchestrator.OnLoadResult(AD_Type.AwardVideo, AdScene, true, slotId);
|
|
|
|
|
DestroyCachedAd(cache);
|
|
|
|
|
cache.Ad = ad;
|
|
|
|
|
cache.Loading = false;
|
|
|
|
|
cache.LoadedUnix = GetNowUnixSeconds();
|
|
|
|
|
RegisterManualEvents(slotId, cache.Ad);
|
|
|
|
|
ScheduleCacheExpiration(slotId, cache);
|
|
|
|
|
curState = string.Equals(slotId, ResolveCurrentSlotId(), StringComparison.Ordinal) ? 2 : curState;
|
|
|
|
|
Debug.Log($"[TapADN] Rewarded loaded. scene={NormalizeScenario(AdScene)}, slot={slotId}");
|
2026-06-04 17:16:17 +08:00
|
|
|
},
|
|
|
|
|
error =>
|
|
|
|
|
{
|
2026-06-17 15:40:25 +08:00
|
|
|
TapadnSmartLoadOrchestrator.OnLoadResult(AD_Type.AwardVideo, AdScene, false, slotId);
|
|
|
|
|
RemoveCache(slotId);
|
|
|
|
|
curState = string.Equals(slotId, ResolveCurrentSlotId(), StringComparison.Ordinal) ? 0 : curState;
|
|
|
|
|
Debug.LogError($"[TapADN] Rewarded load failed. slot={slotId}, code={error.Code}, message={error.Message}");
|
2026-06-04 17:16:17 +08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void ShowAD(Action onClose, Action<bool> onVideoComplete)
|
|
|
|
|
{
|
|
|
|
|
adListener.onClose = onClose;
|
|
|
|
|
adListener.onVideoComplete = onVideoComplete;
|
|
|
|
|
_rewardVerified = false;
|
2026-06-04 17:24:54 +08:00
|
|
|
_rewardVerifyReceived = false;
|
|
|
|
|
_closePendingRewardVerify = false;
|
|
|
|
|
_showSettled = false;
|
|
|
|
|
_rewardCloseSettleHandler?.Kill();
|
|
|
|
|
_rewardCloseSettleHandler = null;
|
2026-06-17 18:15:02 +08:00
|
|
|
_activeSlotId = ResolveCurrentSlotId(out var mapped);
|
2026-06-17 15:40:25 +08:00
|
|
|
Key = _activeSlotId;
|
2026-06-04 17:16:17 +08:00
|
|
|
curState = 0;
|
2026-06-17 18:15:02 +08:00
|
|
|
Debug.Log($"[TapADN] Rewarded show requested. scene={NormalizeScenario(AdScene)}, slot={_activeSlotId}, source={GetSlotSource(mapped)}, auto={UseAutoLoad()}");
|
2026-06-04 17:16:17 +08:00
|
|
|
|
|
|
|
|
if (UseAutoLoad())
|
|
|
|
|
{
|
2026-06-17 15:40:25 +08:00
|
|
|
_adNative.ShowRewardVideoAutoAd(TapadnAdRequestFactory.BuildRewarded(_activeSlotId, TapadnAdController.CurrentOptions), this);
|
2026-06-04 17:16:17 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-17 15:40:25 +08:00
|
|
|
var cache = GetCache(_activeSlotId);
|
|
|
|
|
if (!IsCacheReady(cache) || cache.Ad == null || !cache.Ad.Show())
|
2026-06-04 17:16:17 +08:00
|
|
|
{
|
2026-06-17 15:40:25 +08:00
|
|
|
RemoveCache(_activeSlotId);
|
2026-06-04 17:24:54 +08:00
|
|
|
OnError(new DirichletError("show_failed", "ShowRewardVideoAd returned false"));
|
2026-06-04 17:16:17 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnError(DirichletError error)
|
|
|
|
|
{
|
2026-06-04 17:24:54 +08:00
|
|
|
if (_showSettled)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_showSettled = true;
|
|
|
|
|
_rewardCloseSettleHandler?.Kill();
|
|
|
|
|
_rewardCloseSettleHandler = null;
|
2026-06-04 17:16:17 +08:00
|
|
|
curState = 0;
|
2026-06-17 15:40:25 +08:00
|
|
|
TapadnSmartLoadOrchestrator.OnShowError(AD_Type.AwardVideo, AdScene, _activeSlotId);
|
|
|
|
|
Debug.LogError($"[TapADN] Rewarded show failed. slot={_activeSlotId}, code={error?.Code}, message={error?.Message}");
|
2026-06-04 17:16:17 +08:00
|
|
|
adListener.OnShowError();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnAdShow()
|
|
|
|
|
{
|
2026-06-17 15:40:25 +08:00
|
|
|
TapadnSmartLoadOrchestrator.OnShowStart(AD_Type.AwardVideo, AdScene, _activeSlotId);
|
2026-06-04 17:16:17 +08:00
|
|
|
NotifyShowStarted();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnAdClose()
|
|
|
|
|
{
|
2026-06-04 17:24:54 +08:00
|
|
|
if (_showSettled)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_rewardVerifyReceived)
|
|
|
|
|
{
|
|
|
|
|
CompleteRewardedClose();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_closePendingRewardVerify = true;
|
|
|
|
|
_rewardCloseSettleHandler?.Kill();
|
|
|
|
|
_rewardCloseSettleHandler = ADManager.Instance.CreateTimer(RewardCloseSettleDelaySeconds, CompleteRewardedClose);
|
2026-06-04 17:16:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnRewardVerify(DirichletRewardVerificationEventArgs args)
|
|
|
|
|
{
|
2026-06-04 17:24:54 +08:00
|
|
|
_rewardVerifyReceived = true;
|
2026-06-04 17:16:17 +08:00
|
|
|
_rewardVerified = args != null && args.IsVerified;
|
2026-06-04 17:24:54 +08:00
|
|
|
if (_closePendingRewardVerify)
|
|
|
|
|
{
|
|
|
|
|
CompleteRewardedClose();
|
|
|
|
|
}
|
2026-06-04 17:16:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnAdClick()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-05 21:44:35 +08:00
|
|
|
public override void OnPlayRequestStarted()
|
|
|
|
|
{
|
2026-06-17 18:15:02 +08:00
|
|
|
var slotId = ResolveCurrentSlotId(out var mapped);
|
2026-06-17 15:40:25 +08:00
|
|
|
Key = slotId;
|
2026-06-17 18:15:02 +08:00
|
|
|
Debug.Log($"[TapADN] Rewarded play request. scene={NormalizeScenario(AdScene)}, slot={slotId}, source={GetSlotSource(mapped)}, auto={UseAutoLoad()}");
|
2026-06-17 15:40:25 +08:00
|
|
|
TapadnSmartLoadOrchestrator.OnPlayRequestStarted(AD_Type.AwardVideo, AdScene, !UseAutoLoad() && IsReadly(), slotId);
|
2026-06-05 21:44:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void EnterAdScenario(string scenario)
|
|
|
|
|
{
|
2026-06-17 15:40:25 +08:00
|
|
|
AdScene = NormalizeScenario(scenario);
|
2026-06-17 18:15:02 +08:00
|
|
|
var slotId = ResolveCurrentSlotId(out var mapped);
|
2026-06-17 15:40:25 +08:00
|
|
|
Key = slotId;
|
2026-06-17 18:15:02 +08:00
|
|
|
Debug.Log($"[TapADN] Rewarded enter scene. scene={AdScene}, slot={slotId}, source={GetSlotSource(mapped)}");
|
2026-06-17 15:40:25 +08:00
|
|
|
TapadnSmartLoadOrchestrator.OnEnterAdScenario(AD_Type.AwardVideo, AdScene, slotId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string ResolveCurrentSlotId()
|
|
|
|
|
{
|
2026-06-17 18:15:02 +08:00
|
|
|
return ResolveCurrentSlotId(out _);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string ResolveCurrentSlotId(out bool mapped)
|
|
|
|
|
{
|
|
|
|
|
if (TapadnAdController.CurrentOptions == null)
|
|
|
|
|
{
|
|
|
|
|
mapped = false;
|
|
|
|
|
return string.IsNullOrWhiteSpace(_defaultSlotId) ? _defaultSlotId : _defaultSlotId.Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var slotId = TapadnAdController.CurrentOptions.ResolveRewardedSlotId(_defaultSlotId, AdScene, out mapped);
|
2026-06-17 15:40:25 +08:00
|
|
|
return string.IsNullOrWhiteSpace(slotId) ? _defaultSlotId : slotId.Trim();
|
2026-06-05 21:44:35 +08:00
|
|
|
}
|
|
|
|
|
|
2026-06-17 18:15:02 +08:00
|
|
|
private static string GetSlotSource(bool mapped)
|
|
|
|
|
{
|
|
|
|
|
return mapped ? "scene" : "default";
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-04 17:16:17 +08:00
|
|
|
private bool UseAutoLoad()
|
|
|
|
|
{
|
|
|
|
|
return TapadnAdController.CurrentOptions?.RewardedAutoLoad ?? true;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-17 15:40:25 +08:00
|
|
|
private RewardedSlotCache GetCache(string slotId)
|
|
|
|
|
{
|
|
|
|
|
return !string.IsNullOrWhiteSpace(slotId) && _slotCaches.TryGetValue(slotId, out var cache) ? cache : null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool IsCacheReady(RewardedSlotCache cache)
|
|
|
|
|
{
|
|
|
|
|
if (cache == null || cache.Loading || cache.Ad == null || !cache.Ad.IsLoaded || !cache.Ad.IsValid)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var maxAgeSeconds = TapadnAdController.CurrentOptions?.RewardedCacheMaxAgeSeconds ?? 0;
|
|
|
|
|
return maxAgeSeconds <= 0 || GetNowUnixSeconds() - cache.LoadedUnix <= maxAgeSeconds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RegisterManualEvents(string slotId, DirichletRewardVideoAd ad)
|
|
|
|
|
{
|
|
|
|
|
if (ad == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ad.Shown += () => OnManualShown(slotId);
|
|
|
|
|
ad.Clicked += OnManualClicked;
|
|
|
|
|
ad.ShowFailed += error => OnManualShowFailed(slotId, error);
|
|
|
|
|
ad.RewardVerified += OnManualRewardVerify;
|
|
|
|
|
ad.Closed += () => OnManualClosed(slotId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ScheduleCacheExpiration(string slotId, RewardedSlotCache cache)
|
|
|
|
|
{
|
|
|
|
|
cache.ExpireHandler?.Kill();
|
|
|
|
|
cache.ExpireHandler = null;
|
|
|
|
|
|
|
|
|
|
var maxAgeSeconds = TapadnAdController.CurrentOptions?.RewardedCacheMaxAgeSeconds ?? 600;
|
|
|
|
|
if (maxAgeSeconds <= 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cache.ExpireHandler = ADManager.Instance.CreateTimer(maxAgeSeconds, () =>
|
|
|
|
|
{
|
|
|
|
|
if (!ReferenceEquals(GetCache(slotId), cache))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Debug.Log($"[TapADN] Rewarded cache expired. slot={slotId}, maxAgeSeconds={maxAgeSeconds}");
|
|
|
|
|
RemoveCache(slotId);
|
|
|
|
|
if (string.Equals(slotId, ResolveCurrentSlotId(), StringComparison.Ordinal))
|
|
|
|
|
{
|
|
|
|
|
curState = 0;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnManualShown(string slotId)
|
2026-06-04 17:16:17 +08:00
|
|
|
{
|
2026-06-17 15:40:25 +08:00
|
|
|
_activeSlotId = slotId;
|
2026-06-05 21:44:35 +08:00
|
|
|
OnAdShow();
|
2026-06-04 17:16:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnManualClicked()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-17 15:40:25 +08:00
|
|
|
private void OnManualShowFailed(string slotId, DirichletError error)
|
2026-06-04 17:24:54 +08:00
|
|
|
{
|
2026-06-17 15:40:25 +08:00
|
|
|
RemoveCache(slotId);
|
2026-06-04 17:24:54 +08:00
|
|
|
OnError(error);
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-04 17:16:17 +08:00
|
|
|
private void OnManualRewardVerify(DirichletRewardVerificationEventArgs args)
|
|
|
|
|
{
|
2026-06-04 17:24:54 +08:00
|
|
|
OnRewardVerify(args);
|
2026-06-04 17:16:17 +08:00
|
|
|
}
|
|
|
|
|
|
2026-06-17 15:40:25 +08:00
|
|
|
private void OnManualClosed(string slotId)
|
2026-06-04 17:16:17 +08:00
|
|
|
{
|
2026-06-17 15:40:25 +08:00
|
|
|
RemoveCache(slotId);
|
2026-06-04 17:16:17 +08:00
|
|
|
OnAdClose();
|
|
|
|
|
}
|
2026-06-04 17:24:54 +08:00
|
|
|
|
2026-06-17 15:40:25 +08:00
|
|
|
private void RemoveCache(string slotId)
|
|
|
|
|
{
|
|
|
|
|
var cache = GetCache(slotId);
|
|
|
|
|
if (cache == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DestroyCachedAd(cache);
|
|
|
|
|
_slotCaches.Remove(slotId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void DestroyCachedAd(RewardedSlotCache cache)
|
|
|
|
|
{
|
|
|
|
|
if (cache?.Ad == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
cache.ExpireHandler?.Kill();
|
|
|
|
|
cache.ExpireHandler = null;
|
|
|
|
|
cache.Ad.Destroy();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogWarning($"[TapADN] Rewarded Destroy failed: {exception.Message}");
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
cache.Ad = null;
|
|
|
|
|
cache.Loading = false;
|
|
|
|
|
cache.LoadedUnix = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-04 17:24:54 +08:00
|
|
|
private void CompleteRewardedClose()
|
|
|
|
|
{
|
|
|
|
|
if (_showSettled)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_showSettled = true;
|
|
|
|
|
_closePendingRewardVerify = false;
|
|
|
|
|
_rewardCloseSettleHandler?.Kill();
|
|
|
|
|
_rewardCloseSettleHandler = null;
|
|
|
|
|
adListener.OnRewardVerify(_rewardVerified, TapadnAdController.CurrentOptions?.RewardAmount ?? 1, TapadnAdController.CurrentOptions?.RewardName ?? string.Empty);
|
|
|
|
|
adListener.OnAdClose();
|
|
|
|
|
}
|
2026-06-17 15:40:25 +08:00
|
|
|
|
|
|
|
|
private static string NormalizeScenario(string scenario)
|
|
|
|
|
{
|
|
|
|
|
return string.IsNullOrWhiteSpace(scenario) ? "__default__" : scenario.Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static long GetNowUnixSeconds()
|
|
|
|
|
{
|
|
|
|
|
return (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private sealed class RewardedSlotCache
|
|
|
|
|
{
|
|
|
|
|
public DirichletRewardVideoAd Ad;
|
|
|
|
|
public bool Loading;
|
|
|
|
|
public long LoadedUnix;
|
|
|
|
|
public AdTimeHandler ExpireHandler;
|
|
|
|
|
}
|
2026-06-04 17:16:17 +08:00
|
|
|
}
|