kwai插屏竞价逻辑
This commit is contained in:
parent
94fe636f02
commit
6d11d8d294
|
@ -62,6 +62,33 @@ namespace WZ
|
|||
return _rvConfig.floors;
|
||||
}
|
||||
|
||||
public static bool GetKwaiIvFloorOpen()
|
||||
{
|
||||
if (_ivConfig == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return _ivConfig.kwai_floor_open == 1;
|
||||
}
|
||||
|
||||
public static int GetIvParallelRequests()
|
||||
{
|
||||
if (_ivConfig == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return _ivConfig.parallel_requests;
|
||||
}
|
||||
|
||||
public static List<FloorConfig> GetIvFloorConfigs()
|
||||
{
|
||||
if (_ivConfig == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _ivConfig.floors;
|
||||
}
|
||||
|
||||
public static string GetKwaiAppId()
|
||||
{
|
||||
return _rvConfig?.kwai_appid;
|
||||
|
|
|
@ -35,8 +35,6 @@ namespace WZ
|
|||
public PlatformType Platfrom => PlatformType.Kwai;
|
||||
public bool _initialized { get; private set; } = false;
|
||||
public bool _receivedReward = false;
|
||||
|
||||
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
|
@ -45,7 +43,12 @@ namespace WZ
|
|||
|
||||
if (KwaiAdsConfigParser.GetKwaiRvFloorOpen())
|
||||
{
|
||||
KwaiFloorAdsManager.Instance.InitializeWithFloors();
|
||||
KwaiFloorRvManager.Instance.InitializeWithFloors();
|
||||
}
|
||||
|
||||
if (KwaiAdsConfigParser.GetKwaiIvFloorOpen())
|
||||
{
|
||||
KwaiFloorIvManager.Instance.InitializeWithFloors();
|
||||
}
|
||||
|
||||
var kwaiAdConfig = new KwaiAds.Scripts.Api.KwaiAdConfig.Builder()
|
||||
|
@ -66,20 +69,22 @@ namespace WZ
|
|||
_token = AdConfigParser.GetKwaiAppToken();
|
||||
_rewardAdUnitId = AdConfigParser.GetKwaiAdUnits(AdsType.Rewarded).FirstOrDefault();
|
||||
_interstitialAdUnitId = AdConfigParser.GetKwaiAdUnits(AdsType.Interstitial).FirstOrDefault();
|
||||
KwaiFloorAdsManager.Instance.LoadKwaiBiddingConfig();
|
||||
KwaiFloorRvManager.Instance.LoadKwaiBiddingConfig();
|
||||
KwaiFloorIvManager.Instance.LoadKwaiBiddingConfig();
|
||||
}
|
||||
|
||||
|
||||
#region 激励广告
|
||||
public void LoadRewarded()
|
||||
{
|
||||
AdsActionEvents.TrackAdStartLoad(Platfrom, AdsType.Rewarded);
|
||||
if (!KwaiAdsConfigParser.GetKwaiRvFloorOpen())
|
||||
{
|
||||
LoadRewardedStandard();
|
||||
return;
|
||||
}
|
||||
|
||||
KwaiFloorAdsManager.Instance.LoadRewardedWithFloors();
|
||||
KwaiFloorRvManager.Instance.LoadRewardedWithFloors();
|
||||
}
|
||||
|
||||
public void LoadRewardedStandard()
|
||||
|
@ -95,8 +100,7 @@ namespace WZ
|
|||
_rewardAdController = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getRewardAdController();
|
||||
KwaiRewardAdRequest kwaiRewardAdRequest = new KwaiRewardAdRequest(_rewardAdUnitId);
|
||||
_rewardAdController.Load(kwaiRewardAdRequest, new RewardAdListener(), new RewardAdLoadListener());
|
||||
AdsActionEvents.TrackAdStartLoad(Platfrom, "", "", AdsType.Rewarded);
|
||||
_ivStartLoadTime = Time.realtimeSinceStartup;
|
||||
_rvStartLoadTime = Time.realtimeSinceStartup;
|
||||
}
|
||||
|
||||
public bool IsRewardedAvailable()
|
||||
|
@ -110,7 +114,7 @@ namespace WZ
|
|||
else
|
||||
{
|
||||
// 对于竞价模式,检查是否有成功的楼层广告
|
||||
return KwaiFloorAdsManager.Instance.IsRewardedAvailable();
|
||||
return KwaiFloorRvManager.Instance.IsRewardedAvailable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,7 +138,7 @@ namespace WZ
|
|||
}
|
||||
else
|
||||
{
|
||||
KwaiFloorAdsManager.Instance.ShowRewarded(()=> { _rvShowFailedCallback?.Invoke(); });
|
||||
KwaiFloorRvManager.Instance.ShowRewarded(()=> { _rvShowFailedCallback?.Invoke(); });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,6 +151,17 @@ namespace WZ
|
|||
|
||||
#region 插屏
|
||||
public void LoadInterstitial()
|
||||
{
|
||||
AdsActionEvents.TrackAdStartLoad(Platfrom, AdsType.Interstitial);
|
||||
if (!KwaiAdsConfigParser.GetKwaiIvFloorOpen())
|
||||
{
|
||||
LoadInterstitialStandard();
|
||||
return;
|
||||
}
|
||||
KwaiFloorIvManager.Instance.LoadInterstitialWithFloors();
|
||||
}
|
||||
|
||||
private void LoadInterstitialStandard()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_interstitialAdUnitId)) return;
|
||||
if (_interstitialAdController != null)
|
||||
|
@ -159,28 +174,42 @@ namespace WZ
|
|||
_interstitialAdController = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getInterstitialAdController();
|
||||
KwaiInterstitialAdRequest kwaiInterstitialAdRequest = new KwaiInterstitialAdRequest(_interstitialAdUnitId);
|
||||
_interstitialAdController.Load(kwaiInterstitialAdRequest, new InterstitialAdListener(), new InterstitialAdLoadListener());
|
||||
AdsActionEvents.TrackAdStartLoad(Platfrom, "", "", AdsType.Interstitial);
|
||||
_ivStartLoadTime = Time.realtimeSinceStartup;
|
||||
}
|
||||
|
||||
public bool IsInterstitialAvailable()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_interstitialAdUnitId)) return false;
|
||||
return _interstitialAdController != null && _interstitialAdController.IsReady();
|
||||
if (!KwaiAdsConfigParser.GetKwaiIvFloorOpen())
|
||||
{
|
||||
if (string.IsNullOrEmpty(_interstitialAdUnitId)) return false;
|
||||
return _interstitialAdController != null && _interstitialAdController.IsReady();
|
||||
}
|
||||
else
|
||||
{
|
||||
return KwaiFloorIvManager.Instance.IsInterstitialAdAvailable();
|
||||
}
|
||||
}
|
||||
|
||||
public void DisplayInterstitial(string _adPos, IvType _IvType = IvType.IV1, Action<double> _closeCallback = null)
|
||||
{
|
||||
_ivPos = _adPos;
|
||||
_ivCloseCallback = _closeCallback;
|
||||
if (_interstitialAdController != null)
|
||||
|
||||
if (!KwaiAdsConfigParser.GetKwaiIvFloorOpen())
|
||||
{
|
||||
_interstitialAdController.Show();
|
||||
if (_interstitialAdController != null)
|
||||
{
|
||||
_interstitialAdController.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
_closeCallback?.Invoke(0);
|
||||
LoadInterstitial();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_closeCallback?.Invoke(0);
|
||||
LoadInterstitial();
|
||||
KwaiFloorIvManager.Instance.ShowInterstitialAd(()=> { _ivCloseCallback?.Invoke(0); });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,182 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GoogleMobileAds.Common;
|
||||
using JetBrains.Annotations;
|
||||
using KwaiAds.Scripts.Api.Interstitial;
|
||||
using KwaiAds.Scripts.Api.Reward;
|
||||
using UnityEngine;
|
||||
using static WZ.KwaiAdsConfigParser;
|
||||
|
||||
namespace WZ
|
||||
{
|
||||
public class KwaiFloorIvManager : D_MonoSingleton<KwaiFloorIvManager>
|
||||
{
|
||||
private int _ivParallelRequests = 3;
|
||||
private List<FloorConfig> _ivFloorConfigs = new List<FloorConfig>();
|
||||
public Dictionary<string, IInterstitialAdController> _ivFloorAdControllers = new Dictionary<string, IInterstitialAdController>();
|
||||
private List<FloorConfig> _sortedFloors = new List<FloorConfig>();
|
||||
private int _currentFloorIndex = 0;
|
||||
private bool _isRequestingFloors = false;
|
||||
private List<FloorConfig> _currentRequestBatch = new List<FloorConfig>();
|
||||
private FloorConfig _successfulFloor = null;
|
||||
|
||||
public float _ivStartLoadTime = 0;
|
||||
|
||||
public void InitializeWithFloors()
|
||||
{
|
||||
// 对楼层按价格从高到低排序
|
||||
_sortedFloors = _ivFloorConfigs.OrderByDescending(f => f.price).ToList();
|
||||
LoggerUtils.Debug("[kwai] floor inter Sorted floors: " + string.Join(", ", _sortedFloors.Select(f => $"{f.id}:{f.price}")));
|
||||
}
|
||||
|
||||
public void LoadKwaiBiddingConfig()
|
||||
{
|
||||
_ivParallelRequests = KwaiAdsConfigParser.GetIvParallelRequests();
|
||||
_ivFloorConfigs = KwaiAdsConfigParser.GetIvFloorConfigs();
|
||||
LoggerUtils.Debug($"[kwai] floor inter bidding config loaded. FloorOpen: {KwaiAdsConfigParser.GetKwaiIvFloorOpen()}, ParallelRequests: {_ivParallelRequests}, Floors: {_ivFloorConfigs.Count}");
|
||||
}
|
||||
|
||||
public void LoadInterstitialWithFloors()
|
||||
{
|
||||
if (_ivFloorConfigs == null || _ivFloorConfigs.Count == 0)
|
||||
{
|
||||
LoggerUtils.Debug("[kwai] floor inter No floor configs available, using standard load");
|
||||
KwaiAdsManager.Instance.LoadRewardedStandard();
|
||||
return;
|
||||
}
|
||||
_ivStartLoadTime = Time.realtimeSinceStartup;
|
||||
// 重置状态
|
||||
_currentFloorIndex = 0;
|
||||
_successfulFloor = null;
|
||||
_isRequestingFloors = true;
|
||||
|
||||
// 清理之前的广告控制器
|
||||
foreach (var controller in _ivFloorAdControllers.Values)
|
||||
{
|
||||
controller.Destroy();
|
||||
}
|
||||
_ivFloorAdControllers.Clear();
|
||||
|
||||
// 开始请求楼层广告
|
||||
RequestNextFloorBatch();
|
||||
}
|
||||
|
||||
private void RequestNextFloorBatch()
|
||||
{
|
||||
if (!_isRequestingFloors || _successfulFloor != null) return;
|
||||
|
||||
// 获取下一批要请求的楼层
|
||||
_currentRequestBatch = new List<FloorConfig>();
|
||||
int count = 0;
|
||||
|
||||
while (_currentFloorIndex < _sortedFloors.Count && count < _ivParallelRequests)
|
||||
{
|
||||
_currentRequestBatch.Add(_sortedFloors[_currentFloorIndex]);
|
||||
_currentFloorIndex++;
|
||||
count++;
|
||||
}
|
||||
|
||||
if (_currentRequestBatch.Count == 0)
|
||||
{
|
||||
// 所有楼层都请求完毕,没有填充
|
||||
LoggerUtils.Debug("[kwai] floor inter All floors requested, no fill");
|
||||
_isRequestingFloors = false;
|
||||
return;
|
||||
}
|
||||
|
||||
LoggerUtils.Debug($"[kwai] floor inter Requesting floor batch: {string.Join(", ", _currentRequestBatch.Select(f => $"{f.id}({f.price})"))}");
|
||||
|
||||
// 并行请求当前批次的楼层
|
||||
foreach (var floor in _currentRequestBatch)
|
||||
{
|
||||
RequestFloorAd(floor);
|
||||
}
|
||||
}
|
||||
|
||||
private void RequestFloorAd(FloorConfig floor)
|
||||
{
|
||||
IInterstitialAdController controller = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getInterstitialAdController();;
|
||||
_ivFloorAdControllers[floor.id] = controller;
|
||||
|
||||
KwaiInterstitialAdRequest kwaiInterstitialAdRequest = new KwaiInterstitialAdRequest(floor.unite_id);
|
||||
controller.Load(kwaiInterstitialAdRequest,
|
||||
new FloorInterAdListener(this, floor),
|
||||
new FloorInterAdLoadListener(this, floor));
|
||||
}
|
||||
|
||||
// 处理楼层广告加载成功
|
||||
public void OnFloorAdLoaded(FloorConfig floor, IInterstitialAdController controller)
|
||||
{
|
||||
if (!_isRequestingFloors || _successfulFloor != null) return;
|
||||
|
||||
LoggerUtils.Debug($"[kwai] floor inter Floor ad loaded: {floor.id} with price: {floor.price}");
|
||||
|
||||
// 暂停其他并行请求
|
||||
_successfulFloor = floor;
|
||||
_isRequestingFloors = false;
|
||||
|
||||
// 取消其他楼层的请求
|
||||
foreach (var kvp in _ivFloorAdControllers)
|
||||
{
|
||||
if (kvp.Key != floor.id)
|
||||
{
|
||||
kvp.Value.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理楼层广告加载失败
|
||||
public void OnFloorAdFailed(FloorConfig floor, string error)
|
||||
{
|
||||
if (!_isRequestingFloors || _successfulFloor != null) return;
|
||||
|
||||
LoggerUtils.Debug($"[kwai] floor inter Floor ad failed: {floor.id} with error: {error}");
|
||||
|
||||
// 检查当前批次是否全部失败
|
||||
bool allFailedInBatch = true;
|
||||
foreach (var f in _currentRequestBatch)
|
||||
{
|
||||
if (f.id == floor.id) continue;
|
||||
|
||||
if (_ivFloorAdControllers.ContainsKey(f.id) &&
|
||||
_ivFloorAdControllers[f.id] != null &&
|
||||
_ivFloorAdControllers[f.id].IsReady())
|
||||
{
|
||||
allFailedInBatch = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果当前批次全部失败,请求下一批
|
||||
if (allFailedInBatch)
|
||||
{
|
||||
RequestNextFloorBatch();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsInterstitialAdAvailable()
|
||||
{
|
||||
return _successfulFloor != null &&
|
||||
_ivFloorAdControllers.ContainsKey(_successfulFloor.id) &&
|
||||
_ivFloorAdControllers[_successfulFloor.id] != null &&
|
||||
_ivFloorAdControllers[_successfulFloor.id].IsReady();
|
||||
}
|
||||
|
||||
public void ShowInterstitialAd(Action _action)
|
||||
{
|
||||
if (_successfulFloor != null &&
|
||||
_ivFloorAdControllers.ContainsKey(_successfulFloor.id) &&
|
||||
_ivFloorAdControllers[_successfulFloor.id] != null)
|
||||
{
|
||||
_ivFloorAdControllers[_successfulFloor.id].Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
_action?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 37e131b55920549caa8c6a18259d0607
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -9,7 +9,7 @@ using static WZ.KwaiAdsConfigParser;
|
|||
|
||||
namespace WZ
|
||||
{
|
||||
public class KwaiFloorAdsManager : D_MonoSingleton<KwaiFloorAdsManager>
|
||||
public class KwaiFloorRvManager : D_MonoSingleton<KwaiFloorRvManager>
|
||||
{
|
||||
private int _rvParallelRequests = 3;
|
||||
private List<FloorConfig> _rvFloorConfigs = new List<FloorConfig>();
|
||||
|
@ -20,11 +20,13 @@ namespace WZ
|
|||
private List<FloorConfig> _currentRequestBatch = new List<FloorConfig>();
|
||||
private FloorConfig _successfulFloor = null;
|
||||
|
||||
public float _rvStartLoadTime = 0;
|
||||
|
||||
public void InitializeWithFloors()
|
||||
{
|
||||
// 对楼层按价格从高到低排序
|
||||
_sortedFloors = _rvFloorConfigs.OrderByDescending(f => f.price).ToList();
|
||||
LoggerUtils.Debug("Sorted floors: " + string.Join(", ", _sortedFloors.Select(f => $"{f.id}:{f.price}")));
|
||||
LoggerUtils.Debug("[kwai] floor reward Sorted floors: " + string.Join(", ", _sortedFloors.Select(f => $"{f.id}:{f.price}")));
|
||||
}
|
||||
|
||||
public void LoadKwaiBiddingConfig()
|
||||
|
@ -33,18 +35,18 @@ namespace WZ
|
|||
_rvFloorConfigs = KwaiAdsConfigParser.GetRvFloorConfigs();
|
||||
KwaiAdsManager.Instance._appId = KwaiAdsConfigParser.GetKwaiAppId();
|
||||
KwaiAdsManager.Instance._token = KwaiAdsConfigParser.GetKwaiAppToken();
|
||||
LoggerUtils.Debug($"Kwai bidding config loaded. FloorOpen: {KwaiAdsConfigParser.GetKwaiRvFloorOpen()}, ParallelRequests: {_rvParallelRequests}, Floors: {_rvFloorConfigs.Count}");
|
||||
LoggerUtils.Debug($"[kwai] floor reward bidding config loaded. FloorOpen: {KwaiAdsConfigParser.GetKwaiRvFloorOpen()}, ParallelRequests: {_rvParallelRequests}, Floors: {_rvFloorConfigs.Count}");
|
||||
}
|
||||
|
||||
public void LoadRewardedWithFloors()
|
||||
{
|
||||
if (_rvFloorConfigs == null || _rvFloorConfigs.Count == 0)
|
||||
{
|
||||
LoggerUtils.Debug("No floor configs available, using standard load");
|
||||
LoggerUtils.Debug("[kwai] floor reward No floor configs available, using standard load");
|
||||
KwaiAdsManager.Instance.LoadRewardedStandard();
|
||||
return;
|
||||
}
|
||||
|
||||
_rvStartLoadTime = Time.realtimeSinceStartup;
|
||||
// 重置状态
|
||||
_currentFloorIndex = 0;
|
||||
_successfulFloor = null;
|
||||
|
@ -79,12 +81,12 @@ namespace WZ
|
|||
if (_currentRequestBatch.Count == 0)
|
||||
{
|
||||
// 所有楼层都请求完毕,没有填充
|
||||
LoggerUtils.Debug("All floors requested, no fill");
|
||||
LoggerUtils.Debug("[kwai] floor reward All floors requested, no fill");
|
||||
_isRequestingFloors = false;
|
||||
return;
|
||||
}
|
||||
|
||||
LoggerUtils.Debug($"Requesting floor batch: {string.Join(", ", _currentRequestBatch.Select(f => $"{f.id}({f.price})"))}");
|
||||
LoggerUtils.Debug($"[kwai] floor reward Requesting floor batch: {string.Join(", ", _currentRequestBatch.Select(f => $"{f.id}({f.price})"))}");
|
||||
|
||||
// 并行请求当前批次的楼层
|
||||
foreach (var floor in _currentRequestBatch)
|
||||
|
@ -102,7 +104,6 @@ namespace WZ
|
|||
controller.Load(kwaiRewardAdRequest,
|
||||
new FloorRewardAdListener(this, floor),
|
||||
new FloorRewardAdLoadListener(this, floor));
|
||||
AdsActionEvents.TrackAdStartLoad(KwaiAdsManager.Instance.Platfrom, floor.id, floor.unite_id, AdsType.Rewarded);
|
||||
}
|
||||
|
||||
// 处理楼层广告加载成功
|
||||
|
@ -110,7 +111,7 @@ namespace WZ
|
|||
{
|
||||
if (!_isRequestingFloors || _successfulFloor != null) return;
|
||||
|
||||
LoggerUtils.Debug($"Floor ad loaded: {floor.id} with price: {floor.price}");
|
||||
LoggerUtils.Debug($"[kwai] floor reward ad loaded: {floor.id} with price: {floor.price}");
|
||||
|
||||
// 暂停其他并行请求
|
||||
_successfulFloor = floor;
|
||||
|
@ -131,7 +132,7 @@ namespace WZ
|
|||
{
|
||||
if (!_isRequestingFloors || _successfulFloor != null) return;
|
||||
|
||||
LoggerUtils.Debug($"Floor ad failed: {floor.id} with error: {error}");
|
||||
LoggerUtils.Debug($"[kwai] floor reward ad failed: {floor.id} with error: {error}");
|
||||
|
||||
// 检查当前批次是否全部失败
|
||||
bool allFailedInBatch = true;
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: dd2c7e270f3414dab9c7f9ac80423ee7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,67 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using KwaiAds.Scripts.Api.Interstitial;
|
||||
using KwaiAds.Scripts.Api.Reward;
|
||||
using UnityEngine;
|
||||
using static WZ.KwaiAdsConfigParser;
|
||||
|
||||
|
||||
namespace WZ
|
||||
{
|
||||
public class FloorInterAdListener : IInterstitialAdListener
|
||||
{
|
||||
private KwaiFloorIvManager _manager;
|
||||
private FloorConfig _floor;
|
||||
public FloorInterAdListener(KwaiFloorIvManager manager, FloorConfig floor)
|
||||
{
|
||||
_manager = manager;
|
||||
_floor = floor;
|
||||
}
|
||||
|
||||
public void OnAdClick()
|
||||
{
|
||||
AdsActionEvents.TrackAdClicked(KwaiAdsManager.Instance.Platfrom,
|
||||
KwaiAdsManager.Instance.ClientName,
|
||||
KwaiAdsManager.Instance._interstitialAdUnitId,
|
||||
AdsType.Interstitial,
|
||||
KwaiAdsManager.Instance._ivPos,
|
||||
KwaiAdsManager.Instance._interstitiaAdRevenue);
|
||||
LoggerUtils.Debug("[kwai] floor inter OnAdClick");
|
||||
}
|
||||
|
||||
public void OnAdClose()
|
||||
{
|
||||
AdsActionEvents.TrackAdClosed(KwaiAdsManager.Instance.Platfrom,
|
||||
KwaiAdsManager.Instance.ClientName,
|
||||
KwaiAdsManager.Instance._interstitialAdUnitId,
|
||||
AdsType.Interstitial,
|
||||
KwaiAdsManager.Instance._ivPos,
|
||||
KwaiAdsManager.Instance._interstitiaAdRevenue);
|
||||
KwaiAdsManager.Instance._ivCloseCallback?.Invoke(KwaiAdsManager.Instance._interstitiaAdRevenue);
|
||||
KwaiAdsManager.Instance._ivCloseCallback = null;
|
||||
KwaiAdsManager.Instance.LoadInterstitial();
|
||||
LoggerUtils.Debug("[kwai] floor inter OnAdClose");
|
||||
}
|
||||
|
||||
public void OnAdPlayComplete()
|
||||
{
|
||||
LoggerUtils.Debug("[kwai] floor inter OnAdPlayComplete");
|
||||
}
|
||||
|
||||
public void OnAdShow()
|
||||
{
|
||||
KwaiAdsManager.Instance.TrackAdImpression(AdsType.Interstitial);
|
||||
LoggerUtils.Debug("[kwai] floor inter OnAdShow");
|
||||
}
|
||||
|
||||
public void OnAdShowFailed(int code, string msg)
|
||||
{
|
||||
KwaiAdsManager.Instance._ivCloseCallback?.Invoke(0);
|
||||
KwaiAdsManager.Instance._ivCloseCallback = null;
|
||||
KwaiAdsManager.Instance.LoadInterstitial();
|
||||
LoggerUtils.Debug("[kwai] floor inter OnAdShowFailed");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4eb90f5c070a841d68c4f2295fc199f5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,51 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using KwaiAds.Scripts.Api.Interstitial;
|
||||
using KwaiAds.Scripts.Api.Reward;
|
||||
using UnityEngine;
|
||||
using static WZ.KwaiAdsConfigParser;
|
||||
|
||||
namespace WZ
|
||||
{
|
||||
public class FloorInterAdLoadListener : IInterstitialAdLoadListener
|
||||
{
|
||||
private KwaiFloorIvManager _manager;
|
||||
private FloorConfig _floor;
|
||||
|
||||
public FloorInterAdLoadListener(KwaiFloorIvManager manager, FloorConfig floor)
|
||||
{
|
||||
_manager = manager;
|
||||
_floor = floor;
|
||||
}
|
||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||
{
|
||||
_manager.OnFloorAdFailed(_floor, msg);
|
||||
AdsActionEvents.TrackAdFailToLoad(KwaiAdsManager.Instance.Platfrom,
|
||||
KwaiAdsManager.Instance.ClientName,
|
||||
trackId,
|
||||
AdsType.Interstitial,
|
||||
Time.realtimeSinceStartup - KwaiFloorIvManager.Instance._ivStartLoadTime,
|
||||
msg);
|
||||
LoggerUtils.Debug("[kwai] floor inter ad load failed: "+trackId+" with error: "+msg);
|
||||
}
|
||||
|
||||
public void OnAdLoadStart(string trackId)
|
||||
{
|
||||
LoggerUtils.Debug("[kwai] floor inter OnAdLoadStart: "+trackId);
|
||||
}
|
||||
|
||||
public void OnAdLoadSuccess(string trackId, string price)
|
||||
{
|
||||
AdsKeyEvents.Instance.LogAdFPUEvents(AdsType.Interstitial);
|
||||
KwaiAdsManager.Instance._interstitiaAdRevenue = DataUtils.StringToDouble(price) / 1000;
|
||||
AdsActionEvents.TrackAdLoaded(KwaiAdsManager.Instance.Platfrom,
|
||||
KwaiAdsManager.Instance.ClientName,
|
||||
trackId,
|
||||
AdsType.Interstitial,
|
||||
Time.realtimeSinceStartup - KwaiFloorIvManager.Instance._ivStartLoadTime);
|
||||
_manager.OnFloorAdLoaded(_floor, _manager._ivFloorAdControllers[_floor.id]);
|
||||
LoggerUtils.Debug("[kwai] floor inter ad load success: "+trackId+" with price: "+price);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 86121ad849f5640f39169e9b96c6d193
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 10f914794bccd4e0ca67450dc1a84aed
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -9,9 +9,9 @@ namespace WZ
|
|||
{
|
||||
public class FloorRewardAdListener : IRewardAdListener
|
||||
{
|
||||
private KwaiFloorAdsManager _manager;
|
||||
private KwaiFloorRvManager _manager;
|
||||
private FloorConfig _floor;
|
||||
public FloorRewardAdListener(KwaiFloorAdsManager manager, FloorConfig floor)
|
||||
public FloorRewardAdListener(KwaiFloorRvManager manager, FloorConfig floor)
|
||||
{
|
||||
_manager = manager;
|
||||
_floor = floor;
|
||||
|
@ -19,31 +19,57 @@ namespace WZ
|
|||
|
||||
public void OnAdClick()
|
||||
{
|
||||
AdsActionEvents.TrackAdClicked(KwaiAdsManager.Instance.Platfrom,
|
||||
KwaiAdsManager.Instance.ClientName,
|
||||
KwaiAdsManager.Instance._rewardAdUnitId,
|
||||
AdsType.Rewarded,
|
||||
KwaiAdsManager.Instance._rvPos,
|
||||
KwaiAdsManager.Instance._rewardAdRevenue);
|
||||
|
||||
LoggerUtils.Debug("[kwai] FloorRewardAdListener RewardAdListener#OnAdClick");
|
||||
|
||||
}
|
||||
|
||||
public void OnAdClose()
|
||||
{
|
||||
AdsActionEvents.TrackAdClosed(KwaiAdsManager.Instance.Platfrom,
|
||||
KwaiAdsManager.Instance.ClientName,
|
||||
KwaiAdsManager.Instance._rewardAdUnitId,
|
||||
AdsType.Rewarded,
|
||||
KwaiAdsManager.Instance._rvPos,
|
||||
KwaiAdsManager.Instance._rewardAdRevenue);
|
||||
|
||||
KwaiAdsManager.Instance._rvCloseCallback?.Invoke(KwaiAdsManager.Instance._receivedReward, KwaiAdsManager.Instance._rewardAdRevenue);
|
||||
KwaiAdsManager.Instance._rvCloseCallback = null;
|
||||
KwaiAdsManager.Instance._receivedReward = false;
|
||||
KwaiAdsManager.Instance.LoadRewarded();
|
||||
LoggerUtils.Debug("[kwai] floor reward RewardAdListener#OnAdClose");
|
||||
}
|
||||
|
||||
public void OnAdPlayComplete()
|
||||
{
|
||||
|
||||
LoggerUtils.Debug("[kwai] floor reward RewardAdListener#OnAdPlayComplete");
|
||||
}
|
||||
|
||||
public void OnAdShow()
|
||||
{
|
||||
KwaiAdsManager.Instance.TrackAdImpression(AdsType.Rewarded);
|
||||
LoggerUtils.Debug("[kwai] floor reward RewardAdListener#OnAdShow");
|
||||
|
||||
}
|
||||
|
||||
public void OnAdShowFailed(int code, string msg)
|
||||
{
|
||||
|
||||
KwaiAdsManager.Instance._rvShowFailedCallback?.Invoke();
|
||||
KwaiAdsManager.Instance._rvShowFailedCallback = null;
|
||||
KwaiAdsManager.Instance.LoadRewarded();
|
||||
LoggerUtils.Debug("[kwai] floor reward RewardAdListener#OnAdShowFailed");
|
||||
}
|
||||
|
||||
public void OnRewardEarned()
|
||||
{
|
||||
KwaiAdsManager.Instance._receivedReward = true;
|
||||
LoggerUtils.Debug("[kwai] floor reward RewardAdListener#OnRewardEarned");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,27 +8,41 @@ namespace WZ
|
|||
{
|
||||
public class FloorRewardAdLoadListener : IRewardAdLoadListener
|
||||
{
|
||||
private KwaiFloorAdsManager _manager;
|
||||
private KwaiFloorRvManager _manager;
|
||||
private FloorConfig _floor;
|
||||
|
||||
public FloorRewardAdLoadListener(KwaiFloorAdsManager manager, FloorConfig floor)
|
||||
public FloorRewardAdLoadListener(KwaiFloorRvManager manager, FloorConfig floor)
|
||||
{
|
||||
_manager = manager;
|
||||
_floor = floor;
|
||||
}
|
||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||
{
|
||||
_manager.OnFloorAdFailed(_floor, msg);
|
||||
_manager.OnFloorAdFailed(_floor, msg);
|
||||
AdsActionEvents.TrackAdFailToLoad(KwaiAdsManager.Instance.Platfrom,
|
||||
KwaiAdsManager.Instance.ClientName,
|
||||
trackId,
|
||||
AdsType.Rewarded,
|
||||
Time.realtimeSinceStartup - KwaiFloorRvManager.Instance._rvStartLoadTime,
|
||||
msg);
|
||||
LoggerUtils.Debug("[kwai] floor reward ad load failed: "+trackId+" with error: "+msg);
|
||||
}
|
||||
|
||||
public void OnAdLoadStart(string trackId)
|
||||
{
|
||||
|
||||
LoggerUtils.Debug("[kwai] floor reward ad load start: "+trackId);
|
||||
}
|
||||
|
||||
public void OnAdLoadSuccess(string trackId, string price)
|
||||
{
|
||||
KwaiAdsManager.Instance._rewardAdRevenue = DataUtils.StringToDouble(price)/1000;
|
||||
AdsActionEvents.TrackAdLoaded(KwaiAdsManager.Instance.Platfrom,
|
||||
KwaiAdsManager.Instance.ClientName,
|
||||
trackId,
|
||||
AdsType.Rewarded,
|
||||
Time.realtimeSinceStartup - KwaiFloorRvManager.Instance._rvStartLoadTime);
|
||||
_manager.OnFloorAdLoaded(_floor, _manager._rvFloorAdControllers[_floor.id]);
|
||||
LoggerUtils.Debug("[kwai] floor reward ad load success: "+trackId+" with price: "+price);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,9 +32,9 @@ namespace WZ
|
|||
{
|
||||
LoggerUtils.Debug($"[kwai] RewardAdLoadListener#OnAdLoadSuccess , trackId:{trackId}, price:{price}");
|
||||
AdsKeyEvents.Instance.LogAdFPUEvents(AdsType.Rewarded);
|
||||
KwaiAdsManager.Instance._rewardRetryAttempt = 0;
|
||||
KwaiAdsManager.Instance._rewardAdRevenue = DataUtils.StringToDouble(price)/1000;
|
||||
AdsActionEvents.TrackAdLoaded(KwaiAdsManager.Instance.Platfrom,
|
||||
KwaiAdsManager.Instance._rewardRetryAttempt = 0;
|
||||
KwaiAdsManager.Instance._rewardAdRevenue = DataUtils.StringToDouble(price)/1000;
|
||||
AdsActionEvents.TrackAdLoaded(KwaiAdsManager.Instance.Platfrom,
|
||||
KwaiAdsManager.Instance.ClientName,
|
||||
trackId,
|
||||
AdsType.Rewarded,
|
||||
|
|
Loading…
Reference in New Issue