.
This commit is contained in:
parent
0ad11e3e21
commit
d4d8a89f4d
@ -226,7 +226,8 @@ end
|
|||||||
--- 广告
|
--- 广告
|
||||||
function SDKManager:isAdLoaded()
|
function SDKManager:isAdLoaded()
|
||||||
if CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.Android then
|
if CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.Android then
|
||||||
return CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr.AdLoaded
|
-- return CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr.AdLoaded
|
||||||
|
return true
|
||||||
elseif CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.IPhonePlayer then
|
elseif CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.IPhonePlayer then
|
||||||
return CS.AdManager.Instance:IsRewardedAdReady()
|
return CS.AdManager.Instance:IsRewardedAdReady()
|
||||||
elseif EDITOR_MODE then
|
elseif EDITOR_MODE then
|
||||||
@ -236,52 +237,52 @@ function SDKManager:isAdLoaded()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function SDKManager:tryLoadRewardedAdDelay()
|
function SDKManager:tryLoadRewardedAdDelay()
|
||||||
if self.adDelaySid then
|
-- if self.adDelaySid then
|
||||||
SchedulerManager:unscheduleGlobal(self.adDelaySid)
|
-- SchedulerManager:unscheduleGlobal(self.adDelaySid)
|
||||||
self.adDelaySid = nil
|
-- self.adDelaySid = nil
|
||||||
end
|
-- end
|
||||||
self.adDelaySid = SchedulerManager:performWithDelayGlobal(function()
|
-- self.adDelaySid = SchedulerManager:performWithDelayGlobal(function()
|
||||||
self.adDelaySid = nil
|
-- self.adDelaySid = nil
|
||||||
CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr:TryLoadRewardedAd()
|
-- CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr:TryLoadRewardedAd()
|
||||||
end, 5)
|
-- end, 5)
|
||||||
end
|
end
|
||||||
|
|
||||||
function SDKManager:initAdsListener()
|
function SDKManager:initAdsListener()
|
||||||
if CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.Android then
|
if CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.Android then
|
||||||
CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr:SetAdShowCallback(function(code)
|
-- CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr:SetAdShowCallback(function(code)
|
||||||
-- code 为0 表示广告播放成功
|
-- -- code 为0 表示广告播放成功
|
||||||
if code == 0 then
|
-- if code == 0 then
|
||||||
BIReport:postAdPlaySuccess(self.adsClickType)
|
-- BIReport:postAdPlaySuccess(self.adsClickType)
|
||||||
else
|
-- else
|
||||||
self:tryLoadRewardedAdDelay()
|
-- self:tryLoadRewardedAdDelay()
|
||||||
end
|
-- end
|
||||||
end)
|
-- end)
|
||||||
CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr:SetAdLoadedCallback(function(code)
|
-- CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr:SetAdLoadedCallback(function(code)
|
||||||
-- code 为0 表示广告加载成功
|
-- -- code 为0 表示广告加载成功
|
||||||
if code ~= 0 then
|
-- if code ~= 0 then
|
||||||
self:tryLoadRewardedAdDelay()
|
-- self:tryLoadRewardedAdDelay()
|
||||||
end
|
-- end
|
||||||
end)
|
-- end)
|
||||||
CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr:SetAdEarnedRewardCallback(function(code, result)
|
-- CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr:SetAdEarnedRewardCallback(function(code, result)
|
||||||
if self.adCallback then
|
-- if self.adCallback then
|
||||||
if DataManager.PlayerData then
|
-- if DataManager.PlayerData then
|
||||||
DataManager.PlayerData:addAdCount()
|
-- DataManager.PlayerData:addAdCount()
|
||||||
local data = {}
|
-- local data = {}
|
||||||
data.ads_num = DataManager.PlayerData:getAdCount()
|
-- data.ads_num = DataManager.PlayerData:getAdCount()
|
||||||
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data)
|
-- CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data)
|
||||||
end
|
-- end
|
||||||
self:adRewradAd()
|
-- self:adRewradAd()
|
||||||
self.adCallback()
|
-- self.adCallback()
|
||||||
BIReport:postAdRewardGet(self.adsClickType)
|
-- BIReport:postAdRewardGet(self.adsClickType)
|
||||||
self.adsClickType = nil
|
-- self.adsClickType = nil
|
||||||
self.adCallback = nil
|
-- self.adCallback = nil
|
||||||
end
|
-- end
|
||||||
end)
|
-- end)
|
||||||
CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr:SetAdRevenuePaidEventCallback(function (result)
|
-- CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr:SetAdRevenuePaidEventCallback(function (result)
|
||||||
if result and result ~= GConst.EMPTY_STRING then
|
-- if result and result ~= GConst.EMPTY_STRING then
|
||||||
BIReport:postIronSourceAdRevenue(result)
|
-- BIReport:postIronSourceAdRevenue(result)
|
||||||
end
|
-- end
|
||||||
end)
|
-- end)
|
||||||
elseif CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.IPhonePlayer then
|
elseif CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.IPhonePlayer then
|
||||||
-- 初始化一下
|
-- 初始化一下
|
||||||
local adManager = CS.AdManager.Instance
|
local adManager = CS.AdManager.Instance
|
||||||
@ -338,15 +339,15 @@ function SDKManager:showFullScreenAds(adsClickType, adCallback)
|
|||||||
-- return true
|
-- return true
|
||||||
-- end
|
-- end
|
||||||
if CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.Android then
|
if CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.Android then
|
||||||
if not CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr.AdLoaded then
|
-- if not CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr.AdLoaded then
|
||||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.NO_ADS))
|
-- GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.NO_ADS))
|
||||||
return false
|
-- return false
|
||||||
end
|
-- end
|
||||||
CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr:SetAdPlacement(adsClickType)
|
-- CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr:SetAdPlacement(adsClickType)
|
||||||
CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr.AdLoaded = false
|
-- CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr.AdLoaded = false
|
||||||
self.adCallback = adCallback
|
-- self.adCallback = adCallback
|
||||||
self.adsClickType = adsClickType
|
-- self.adsClickType = adsClickType
|
||||||
CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr:ShowFullScreenAds()
|
-- CS.BF.BFMain.Instance.SDKMgr.BFIronSourceSDKMgr:ShowFullScreenAds()
|
||||||
return true
|
return true
|
||||||
elseif CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.IPhonePlayer then
|
elseif CS.UnityEngine.Application.platform == CS.UnityEngine.RuntimePlatform.IPhonePlayer then
|
||||||
if not CS.AdManager.Instance:IsRewardedAdReady() then
|
if not CS.AdManager.Instance:IsRewardedAdReady() then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user