| 
									
										
										
										
											2025-08-31 05:15:14 +00:00
										 |  |  | using System; | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  | using System.Collections; | 
					
						
							|  |  |  | using System.Collections.Generic; | 
					
						
							| 
									
										
										
										
											2025-09-01 03:39:21 +00:00
										 |  |  | using System.Linq; | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  | using System.Threading; | 
					
						
							|  |  |  | using AnyThinkAds.Api; | 
					
						
							|  |  |  | using AnyThinkAds.ThirdParty.LitJson; | 
					
						
							|  |  |  | using UnityEngine; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-01 10:32:50 +00:00
										 |  |  | namespace WZ | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-09-02 09:14:49 +00:00
										 |  |  |     public class TpnAdsManager : D_MonoSingleton<TpnAdsManager>, IAdService | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-09-01 07:14:26 +00:00
										 |  |  |         public string ClientName => "Topon"; | 
					
						
							|  |  |  |         public PlatformType Platfrom => PlatformType.Topon; | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |         public string _topon_app_id; | 
					
						
							|  |  |  |         public string _topon_app_key; | 
					
						
							|  |  |  |         public string _topon_interstitial_units; | 
					
						
							|  |  |  |         public string _topon_rewarded_units; | 
					
						
							| 
									
										
										
										
											2025-08-31 05:15:14 +00:00
										 |  |  |         private string _rvPos; | 
					
						
							|  |  |  |         private string _ivPos; | 
					
						
							| 
									
										
										
										
											2025-09-04 06:24:18 +00:00
										 |  |  |         private Action<bool, double> _rvCloseCallback = null; | 
					
						
							| 
									
										
										
										
											2025-09-01 14:14:33 +00:00
										 |  |  |         private Action<double> _ivCloseCallback = null; | 
					
						
							| 
									
										
										
										
											2025-08-31 05:15:14 +00:00
										 |  |  |         private Action _rvShowFailedCallback = null; | 
					
						
							| 
									
										
										
										
											2025-09-02 15:25:00 +00:00
										 |  |  |         public bool _initialized { get; private set; } = false; | 
					
						
							| 
									
										
										
										
											2025-09-03 11:58:43 +00:00
										 |  |  |         private bool _receivedReward = false; | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |         public void Initialize() | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-09-03 11:58:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |             LoggerUtils.Debug("[Tpn] 初始化 Tpn 广告 SDK appid:" + _topon_app_id + " appkey:" + _topon_app_key + " ivId:" + _topon_interstitial_units + " rvId:" + _topon_rewarded_units); | 
					
						
							| 
									
										
										
										
											2025-09-03 11:58:43 +00:00
										 |  |  |             if (_initialized) return; | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |             if (!string.IsNullOrEmpty(_topon_app_id) && !string.IsNullOrEmpty(_topon_app_key)) | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |                 ATSDKAPI.initSDK(_topon_app_id, _topon_app_key); | 
					
						
							| 
									
										
										
										
											2025-09-03 11:58:43 +00:00
										 |  |  |                 _initialized = true; | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |                 ATSDKAPI.setLogDebug(false); | 
					
						
							|  |  |  |                 InitRewarded(); | 
					
						
							|  |  |  |                 InitInterstitial(); | 
					
						
							| 
									
										
										
										
											2025-09-03 11:58:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |         public void RefreshAdsData() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             _topon_app_id = AdConfigParser.GetTopOnAppId(); | 
					
						
							|  |  |  |             _topon_app_key = AdConfigParser.GetTopOnAppKey(); | 
					
						
							|  |  |  |             _topon_interstitial_units = AdConfigParser.GetTopOnAdUnits(AdsType.Interstitial).FirstOrDefault(); | 
					
						
							|  |  |  |             _topon_rewarded_units = AdConfigParser.GetTopOnAdUnits(AdsType.Rewarded).FirstOrDefault(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |         #region 激励广告功能 | 
					
						
							|  |  |  |         private void InitRewarded() | 
					
						
							| 
									
										
										
										
											2025-08-31 12:54:15 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |             if (string.IsNullOrEmpty(_topon_rewarded_units)) return; | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |             ATRewardedAutoVideo.Instance.client.onAdLoadEvent += OnAdLoadedEvent; | 
					
						
							|  |  |  |             ATRewardedAutoVideo.Instance.client.onAdLoadFailureEvent += OnAdLoadedFailEvent; | 
					
						
							|  |  |  |             ATRewardedAutoVideo.Instance.client.onAdVideoCloseEvent += OnAdVideoClosedEvent; | 
					
						
							|  |  |  |             ATRewardedAutoVideo.Instance.client.onAdVideoStartEvent += OnAdVideoStartEvent; | 
					
						
							|  |  |  |             ATRewardedAutoVideo.Instance.client.onAdVideoFailureEvent += OnAdVideoFailureEvent; | 
					
						
							|  |  |  |             ATRewardedAutoVideo.Instance.client.onAdClickEvent += OnAdVideoClickedEvent; | 
					
						
							| 
									
										
										
										
											2025-09-03 11:58:43 +00:00
										 |  |  |             ATRewardedAutoVideo.Instance.client.onRewardEvent += OnAdRewardEvent; | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |             ATRewardedAutoVideo.Instance.addAutoLoadAdPlacementID(new string[] { _topon_rewarded_units }); | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-15 05:59:03 +00:00
										 |  |  |             AdsActionEvents.TrackAdStartLoad(Platfrom, AdsType.Rewarded); | 
					
						
							| 
									
										
										
										
											2025-09-01 07:14:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-08-31 12:54:15 +00:00
										 |  |  |         public void LoadRewarded() { } | 
					
						
							| 
									
										
										
										
											2025-09-04 06:24:18 +00:00
										 |  |  |         public void DisplayRewarded(string adPos, Action<bool, double> rewardCallback = null, Action showFailedCallback = null) | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-08-31 05:15:14 +00:00
										 |  |  |             _rvPos = adPos; | 
					
						
							|  |  |  |             _rvCloseCallback = rewardCallback; | 
					
						
							|  |  |  |             _rvShowFailedCallback = showFailedCallback; | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |             ATRewardedAutoVideo.Instance.showAutoAd(_topon_rewarded_units); | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public double GetRewardedRevenue() { return 0; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public bool IsRewardedAvailable() | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |             return string.IsNullOrEmpty(_topon_rewarded_units) ? false : ATRewardedAutoVideo.Instance.autoLoadRewardedVideoReadyForPlacementID(_topon_rewarded_units); | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         #endregion | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         #region 插页广告功能 | 
					
						
							|  |  |  |         private void InitInterstitial() | 
					
						
							| 
									
										
										
										
											2025-08-31 12:54:15 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |             if (string.IsNullOrEmpty(_topon_interstitial_units)) return; | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |             ATInterstitialAutoAd.Instance.client.onAdLoadEvent += OnAdLoadedEvent; | 
					
						
							|  |  |  |             ATInterstitialAutoAd.Instance.client.onAdLoadFailureEvent += OnAdLoadedFailEvent; | 
					
						
							|  |  |  |             ATInterstitialAutoAd.Instance.client.onAdCloseEvent += OnAdVideoClosedEvent; | 
					
						
							|  |  |  |             ATInterstitialAutoAd.Instance.client.onAdShowEvent += OnAdVideoStartEvent; | 
					
						
							|  |  |  |             ATInterstitialAutoAd.Instance.client.onAdShowFailureEvent += OnAdVideoFailureEvent; | 
					
						
							|  |  |  |             ATInterstitialAutoAd.Instance.client.onAdClickEvent += OnAdVideoClickedEvent; | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |             ATInterstitialAutoAd.Instance.addAutoLoadAdPlacementID(new string[] { _topon_interstitial_units }); | 
					
						
							| 
									
										
										
										
											2025-09-15 05:59:03 +00:00
										 |  |  |             AdsActionEvents.TrackAdStartLoad(Platfrom, AdsType.Interstitial); | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-31 12:54:15 +00:00
										 |  |  |         public void LoadInterstitial() { } | 
					
						
							|  |  |  |         public double GetInterstitialRevenue() { return 0; } | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-01 14:14:33 +00:00
										 |  |  |         public void DisplayInterstitial(string ivPos, IvType _IvType = IvType.IV1, Action<double> closeCallback = null) | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-08-31 05:15:14 +00:00
										 |  |  |             _ivPos = ivPos; | 
					
						
							|  |  |  |             _ivCloseCallback = closeCallback; | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |             ATInterstitialAutoAd.Instance.showAutoAd(_topon_interstitial_units); | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public bool IsInterstitialAvailable() | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |             return string.IsNullOrEmpty(_topon_interstitial_units) ? false : ATInterstitialAutoAd.Instance.autoLoadInterstitialAdReadyForPlacementID(_topon_interstitial_units); | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |         #endregion | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         #region 代理 | 
					
						
							|  |  |  |         private void OnAdLoadedEvent(object sender, ATAdEventArgs erg) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-09-01 07:14:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |             if (erg.placementId.Equals(_topon_interstitial_units)) | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |             { | 
					
						
							|  |  |  |                 LoggerUtils.Debug("[Tpn] ads tpn topon interstitial loaded"); | 
					
						
							| 
									
										
										
										
											2025-09-04 06:24:18 +00:00
										 |  |  |                 var info = JsonUtility.FromJson<TopOnCallback>(ATInterstitialAutoAd.Instance.checkAutoAdStatus(erg.placementId)); | 
					
						
							|  |  |  |                 AdsActionEvents.TrackAdLoaded(Platfrom, | 
					
						
							|  |  |  |                 ClientName + "_" + info.adInfo.network_firm_id, | 
					
						
							|  |  |  |                 info.adInfo.adunit_id, | 
					
						
							|  |  |  |                 erg.placementId.Equals(_topon_rewarded_units) ? AdsType.Rewarded : AdsType.Interstitial, | 
					
						
							|  |  |  |                 0); | 
					
						
							| 
									
										
										
										
											2025-08-31 14:18:31 +00:00
										 |  |  |                 AdsKeyEvents.Instance.LogAdFPUEvents(AdsType.Interstitial); | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |             else if (erg.placementId.Equals(_topon_rewarded_units)) | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |             { | 
					
						
							|  |  |  |                 LoggerUtils.Debug("[Tpn] ads tpn topon rewarded loaded"); | 
					
						
							| 
									
										
										
										
											2025-09-04 06:24:18 +00:00
										 |  |  |                 var info = JsonUtility.FromJson<TopOnCallback>(ATRewardedAutoVideo.Instance.checkAutoAdStatus(erg.placementId)); | 
					
						
							|  |  |  |                 AdsActionEvents.TrackAdLoaded(Platfrom, | 
					
						
							|  |  |  |                 ClientName + "_" + info.adInfo.network_firm_id, | 
					
						
							|  |  |  |                 info.adInfo.adunit_id, | 
					
						
							|  |  |  |                 erg.placementId.Equals(_topon_rewarded_units) ? AdsType.Rewarded : AdsType.Interstitial, | 
					
						
							|  |  |  |                 0); | 
					
						
							| 
									
										
										
										
											2025-08-31 14:18:31 +00:00
										 |  |  |                 AdsKeyEvents.Instance.LogAdFPUEvents(AdsType.Rewarded); | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         private void OnAdLoadedFailEvent(object sender, ATAdErrorEventArgs erg) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-08-31 12:54:15 +00:00
										 |  |  |             LoggerUtils.Debug("[Tpn] 广告加载失败:" + JsonMapper.ToJson(erg.callbackInfo.toDictionary())); | 
					
						
							| 
									
										
										
										
											2025-09-01 07:14:26 +00:00
										 |  |  |             AdsActionEvents.TrackAdFailToLoad(Platfrom, | 
					
						
							|  |  |  |                 ClientName + "_" + erg.callbackInfo.network_firm_id, | 
					
						
							|  |  |  |                 erg.callbackInfo.adunit_id, | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |                 erg.placementId.Equals(_topon_rewarded_units) ? AdsType.Rewarded : AdsType.Interstitial, | 
					
						
							| 
									
										
										
										
											2025-09-01 07:14:26 +00:00
										 |  |  |                 0, | 
					
						
							|  |  |  |                 erg.errorMessage); | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         private void OnAdVideoStartEvent(object sender, ATAdEventArgs erg) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             LoggerUtils.Debug("[Tpn] 广告开始播放:" + JsonMapper.ToJson(erg.callbackInfo.toDictionary())); | 
					
						
							| 
									
										
										
										
											2025-08-31 12:54:15 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             TrackAdImpression(erg); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |             ThreadUtils.QueueOnMainThread(pObj => | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |                 if (erg.placementId.Equals(_topon_rewarded_units)) | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |                 { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |                 else if (erg.placementId.Equals(_topon_interstitial_units)) | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |                 { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             }, ""); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         private void OnAdVideoFailureEvent(object sender, ATAdErrorEventArgs erg) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             LoggerUtils.Debug("[Tpn] 广告播放失败" + JsonMapper.ToJson(erg.callbackInfo.toDictionary())); | 
					
						
							|  |  |  |             ThreadUtils.QueueOnMainThread(pObj => | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |                 if (erg.placementId.Equals(_topon_rewarded_units)) | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-08-31 05:15:14 +00:00
										 |  |  |                     _rvShowFailedCallback?.Invoke(); | 
					
						
							|  |  |  |                     _rvShowFailedCallback = null; | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |                 else if (erg.placementId.Equals(_topon_interstitial_units)) | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-09-01 14:14:33 +00:00
										 |  |  |                     _ivCloseCallback?.Invoke(0); | 
					
						
							| 
									
										
										
										
											2025-08-31 05:15:14 +00:00
										 |  |  |                     _ivCloseCallback = null; | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |                 } | 
					
						
							|  |  |  |             }, ""); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-03 11:58:43 +00:00
										 |  |  |         private void OnAdRewardEvent(object sender, ATAdEventArgs erg) | 
					
						
							| 
									
										
										
										
											2025-09-04 06:24:18 +00:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-09-03 11:58:43 +00:00
										 |  |  |             LoggerUtils.Debug("[Tpn] 广告奖励"); | 
					
						
							|  |  |  |             _receivedReward = true; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |         private void OnAdVideoClosedEvent(object sender, ATAdEventArgs erg) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             LoggerUtils.Debug("[Tpn] 广告关闭了:" + JsonMapper.ToJson(erg.callbackInfo.toDictionary())); | 
					
						
							| 
									
										
										
										
											2025-09-01 07:14:26 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             AdsActionEvents.TrackAdClosed(Platfrom, | 
					
						
							|  |  |  |                 ClientName + "_" + erg.callbackInfo.network_firm_id, | 
					
						
							|  |  |  |                 erg.callbackInfo.adunit_id, | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |                 erg.placementId.Equals(_topon_rewarded_units) ? AdsType.Rewarded : AdsType.Interstitial, | 
					
						
							| 
									
										
										
										
											2025-09-09 06:19:16 +00:00
										 |  |  |                 erg.placementId.Equals(_topon_rewarded_units) ? _rvPos : _ivPos, | 
					
						
							| 
									
										
										
										
											2025-09-01 07:14:26 +00:00
										 |  |  |                 erg.callbackInfo.publisher_revenue); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |             ThreadUtils.QueueOnMainThread(pObj => | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |                 if (erg.placementId.Equals(_topon_rewarded_units)) | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-09-03 11:58:43 +00:00
										 |  |  |                     _rvCloseCallback?.Invoke(_receivedReward, erg.callbackInfo.publisher_revenue); | 
					
						
							| 
									
										
										
										
											2025-08-31 05:15:14 +00:00
										 |  |  |                     _rvCloseCallback = null; | 
					
						
							| 
									
										
										
										
											2025-09-03 11:58:43 +00:00
										 |  |  |                     _receivedReward = false; | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |                 else if (erg.placementId.Equals(_topon_interstitial_units)) | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |                 { | 
					
						
							| 
									
										
										
										
											2025-09-01 14:14:33 +00:00
										 |  |  |                     _ivCloseCallback?.Invoke(erg.callbackInfo.publisher_revenue); | 
					
						
							| 
									
										
										
										
											2025-08-31 05:15:14 +00:00
										 |  |  |                     _ivCloseCallback = null; | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |                 } | 
					
						
							|  |  |  |             }, ""); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         private void OnAdVideoClickedEvent(object sender, ATAdEventArgs erg) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             LoggerUtils.Debug("[Tpn] 点击广告了:" + JsonMapper.ToJson(erg.callbackInfo.toDictionary())); | 
					
						
							| 
									
										
										
										
											2025-09-01 07:14:26 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             AdsActionEvents.TrackAdClicked(Platfrom, | 
					
						
							|  |  |  |                 ClientName + "_" + erg.callbackInfo.network_firm_id, | 
					
						
							|  |  |  |                 erg.callbackInfo.adunit_id, | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |                 erg.placementId.Equals(_topon_rewarded_units) ? AdsType.Rewarded : AdsType.Interstitial, | 
					
						
							| 
									
										
										
										
											2025-09-09 06:19:16 +00:00
										 |  |  |                 erg.placementId.Equals(_topon_rewarded_units) ? _rvPos : _ivPos, | 
					
						
							| 
									
										
										
										
											2025-09-01 07:14:26 +00:00
										 |  |  |                 erg.callbackInfo.publisher_revenue); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |             ThreadUtils.QueueOnMainThread(pObj => | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |                 if (erg.placementId.Equals(_topon_rewarded_units)) | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |                 { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |                 else if (erg.placementId.Equals(_topon_interstitial_units)) | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |                 { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             }, ""); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         #endregion | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         #region 开屏广告功能 | 
					
						
							|  |  |  |         public void LoadSplash() { } | 
					
						
							|  |  |  |         public bool IsSplashAvailable() { return false; } | 
					
						
							| 
									
										
										
										
											2025-08-31 12:54:15 +00:00
										 |  |  |         public void DisplaySplash() { } | 
					
						
							|  |  |  |         public double GetSplashRevenue() { return 0; } | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         #endregion | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         #region 原生广告功能 | 
					
						
							| 
									
										
										
										
											2025-08-31 12:54:15 +00:00
										 |  |  |         public void LoadNative() { } | 
					
						
							| 
									
										
										
										
											2025-09-02 02:07:10 +00:00
										 |  |  |         public bool IsNativeAvailable(string adUnitId) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public void DisplayNative(string _adPos, string adUnitId, NativeAdPosition position) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-09-04 06:24:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-02 02:07:10 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public void RemoveNative(string adUnitId) | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-09-04 06:24:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-02 02:07:10 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public double GetNativeRevenue(string adUnitId) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return 0; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-31 12:54:15 +00:00
										 |  |  |         public double GetNativeRevenue() { return 0; } | 
					
						
							|  |  |  |         public void DisplayNative(NativeAdPosition position) { } | 
					
						
							|  |  |  |         public bool IsNativeAvailable() { return false; } | 
					
						
							|  |  |  |         public void RemoveNative() { } | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         #endregion | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         #region 横幅广告功能 | 
					
						
							| 
									
										
										
										
											2025-08-31 12:54:15 +00:00
										 |  |  |         public void LoadBanner() { } | 
					
						
							| 
									
										
										
										
											2025-09-16 13:29:51 +00:00
										 |  |  |         public bool IsBannerAvailable(BannerType bannerType) { return false; } | 
					
						
							|  |  |  |         public void HideBanner(BannerType bannerType) { } | 
					
						
							|  |  |  |         public double GetBannerRevenue(BannerType bannerType) { return 0; } | 
					
						
							|  |  |  |         public void DisplayBanner(BannerType bannerType,BannerAlignType bannerAlignType) { } | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |         #endregion | 
					
						
							| 
									
										
										
										
											2025-08-31 13:19:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-31 12:54:15 +00:00
										 |  |  |         #region 广告收益上报 | 
					
						
							|  |  |  |         public void TrackAdImpression(ATAdEventArgs erg) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             AdjustTrackEvent.Instance.TrackAdEvent(erg.callbackInfo.publisher_revenue, | 
					
						
							|  |  |  |                 ClientName + "_" + erg.callbackInfo.network_firm_id, | 
					
						
							|  |  |  |                 erg.callbackInfo.adunit_id, | 
					
						
							|  |  |  |                 erg.callbackInfo.network_placement_id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             FireBaseAnalyticsManager.Instance.OnAdRevenueEvent(ClientName, | 
					
						
							|  |  |  |                 ClientName + "_" + erg.callbackInfo.network_firm_id, | 
					
						
							|  |  |  |                 erg.callbackInfo.adunit_id, | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |                 erg.placementId.Equals(_topon_rewarded_units) ? AdsType.Rewarded : AdsType.Interstitial, | 
					
						
							| 
									
										
										
										
											2025-08-31 12:54:15 +00:00
										 |  |  |                 erg.callbackInfo.publisher_revenue, | 
					
						
							| 
									
										
										
										
											2025-09-09 06:19:16 +00:00
										 |  |  |                 erg.placementId.Equals(_topon_rewarded_units) ? _rvPos : _ivPos, | 
					
						
							| 
									
										
										
										
											2025-09-04 09:19:05 +00:00
										 |  |  |                 AdPlayCountManager.GetAdsActionCount(erg.placementId.Equals(_topon_rewarded_units) ? AdsType.Rewarded : AdsType.Interstitial,AdPlayCountManager.PLAY_COUNT_SUFFIX)); | 
					
						
							| 
									
										
										
										
											2025-08-31 12:54:15 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             ShuShuEvent.Instance.OnAdRevenueEvent(ClientName, | 
					
						
							|  |  |  |                 ClientName + "_" + erg.callbackInfo.network_firm_id, | 
					
						
							|  |  |  |                 erg.callbackInfo.adunit_id, | 
					
						
							| 
									
										
										
										
											2025-09-01 12:53:08 +00:00
										 |  |  |                 erg.placementId.Equals(_topon_rewarded_units) ? AdsType.Rewarded.ToString() : AdsType.Interstitial.ToString(), | 
					
						
							| 
									
										
										
										
											2025-08-31 12:54:15 +00:00
										 |  |  |                 erg.callbackInfo.publisher_revenue, | 
					
						
							| 
									
										
										
										
											2025-09-09 06:19:16 +00:00
										 |  |  |                 erg.placementId.Equals(_topon_rewarded_units) ? _rvPos : _ivPos, | 
					
						
							| 
									
										
										
										
											2025-09-04 09:19:05 +00:00
										 |  |  |                 AdPlayCountManager.GetAdsActionCount(erg.placementId.Equals(_topon_rewarded_units) ? AdsType.Rewarded : AdsType.Interstitial,AdPlayCountManager.PLAY_COUNT_SUFFIX)); | 
					
						
							| 
									
										
										
										
											2025-08-31 12:54:15 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-08-31 13:19:46 +00:00
										 |  |  |         #endregion | 
					
						
							| 
									
										
										
										
											2025-09-04 06:24:18 +00:00
										 |  |  |          | 
					
						
							|  |  |  |         [Serializable] | 
					
						
							|  |  |  |         public class TopOnCallback | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             public bool isLoading; | 
					
						
							|  |  |  |             public bool isReady; | 
					
						
							|  |  |  |             public TopOnCallbackInfo adInfo; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         [Serializable] | 
					
						
							|  |  |  |         public class TopOnCallbackInfo | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             public double publisher_revenue; | 
					
						
							|  |  |  |             public string adunit_id; | 
					
						
							|  |  |  |             public int network_firm_id; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-08-31 01:11:05 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | } |