|
|
@ -31,7 +31,7 @@ namespace Core.Ads |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
if (CoreSettings.data.adsBridgeObiect == null) |
|
|
if (CoreSettings.data.adsBridgeObiect == null) |
|
|
throw new NullReferenceException("ads bridge object is null"); |
|
|
throw new NullReferenceException("Ads bridge object is null"); |
|
|
|
|
|
|
|
|
bridge = GameObject.Instantiate(CoreSettings.data.adsBridgeObiect, holder.transform); |
|
|
bridge = GameObject.Instantiate(CoreSettings.data.adsBridgeObiect, holder.transform); |
|
|
} |
|
|
} |
|
|
@ -44,7 +44,7 @@ namespace Core.Ads |
|
|
_interstitial = bridge.GetComponent<IInterstitialBridge>(); |
|
|
_interstitial = bridge.GetComponent<IInterstitialBridge>(); |
|
|
|
|
|
|
|
|
if (_interstitial == null) |
|
|
if (_interstitial == null) |
|
|
throw new NullReferenceException("ads bridge object does not implement IInterstitialBridge"); |
|
|
throw new NullReferenceException("Ads bridge object does not implement IInterstitialBridge"); |
|
|
|
|
|
|
|
|
_interstitial.OnEnded += () => OnInterstitialShowed?.Invoke(); |
|
|
_interstitial.OnEnded += () => OnInterstitialShowed?.Invoke(); |
|
|
} |
|
|
} |
|
|
@ -57,14 +57,14 @@ namespace Core.Ads |
|
|
_banner = bridge.GetComponent<IBannerBridge>(); |
|
|
_banner = bridge.GetComponent<IBannerBridge>(); |
|
|
|
|
|
|
|
|
if (_banner == null) |
|
|
if (_banner == null) |
|
|
throw new NullReferenceException("ads bridge object does not implement IBannerBridge"); |
|
|
throw new NullReferenceException("Ads bridge object does not implement IBannerBridge"); |
|
|
|
|
|
|
|
|
PurchaseManager.OnPurchaseSuccess += (productId) => |
|
|
PurchaseManager.OnPurchaseSuccess += (productId) => |
|
|
{ |
|
|
{ |
|
|
if (!CoreSettings.data.nonConsumableProducts.Contains(productId)) |
|
|
if (CoreSettings.data.IsProductConsumable(productId)) |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
if (CoreSettings.data.nonConsumableProductsDisableAds[CoreSettings.data.nonConsumableProducts.IndexOf(productId)]) |
|
|
if (CoreSettings.data.IsOnAdsProduct(productId)) |
|
|
HideBanner(); |
|
|
HideBanner(); |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
@ -77,17 +77,15 @@ namespace Core.Ads |
|
|
_rewarded = bridge.GetComponent<IRewardedBridge>(); |
|
|
_rewarded = bridge.GetComponent<IRewardedBridge>(); |
|
|
|
|
|
|
|
|
if (_rewarded == null) |
|
|
if (_rewarded == null) |
|
|
throw new NullReferenceException("ads bridge object does not implement IRewardedBridge"); |
|
|
throw new NullReferenceException("Ads bridge object does not implement IRewardedBridge"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static bool IsAdsDisabled() |
|
|
public static bool IsAdsDisabled() |
|
|
{ |
|
|
{ |
|
|
for (int i = 0; i < CoreSettings.data.nonConsumableProducts.Count; i++) |
|
|
for (int i = 0; i < CoreSettings.data.nonConsumableProducts.Count; i++) |
|
|
{ |
|
|
{ |
|
|
if (CoreSettings.data.nonConsumableProductsDisableAds[i] && PurchaseManager.IsProductPurchased(CoreSettings.data.nonConsumableProducts[i])) |
|
|
if (PurchaseManager.IsProductPurchased(CoreSettings.data.nonConsumableProducts[i])) |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -100,7 +98,7 @@ namespace Core.Ads |
|
|
return false; |
|
|
return false; |
|
|
|
|
|
|
|
|
if (_interstitial == null) |
|
|
if (_interstitial == null) |
|
|
throw new NullReferenceException("ads bridge object does not implement IInterstitialBridge"); |
|
|
throw new NullReferenceException("Ads bridge object does not implement IInterstitialBridge"); |
|
|
|
|
|
|
|
|
if (CoreSettings.data.needInterstitial) |
|
|
if (CoreSettings.data.needInterstitial) |
|
|
return _interstitial.IsReady(); |
|
|
return _interstitial.IsReady(); |
|
|
@ -111,7 +109,7 @@ namespace Core.Ads |
|
|
public static bool IsInterstitialVisible() |
|
|
public static bool IsInterstitialVisible() |
|
|
{ |
|
|
{ |
|
|
if (_interstitial == null) |
|
|
if (_interstitial == null) |
|
|
throw new NullReferenceException("ads bridge object does not implement IInterstitialBridge"); |
|
|
throw new NullReferenceException("Ads bridge object does not implement IInterstitialBridge"); |
|
|
|
|
|
|
|
|
if (CoreSettings.data.needInterstitial) |
|
|
if (CoreSettings.data.needInterstitial) |
|
|
return _interstitial.IsVisible(); |
|
|
return _interstitial.IsVisible(); |
|
|
@ -121,11 +119,13 @@ namespace Core.Ads |
|
|
|
|
|
|
|
|
public static void ShowInterstitial() |
|
|
public static void ShowInterstitial() |
|
|
{ |
|
|
{ |
|
|
|
|
|
Debug.Log("Called show interstitial"); |
|
|
|
|
|
|
|
|
if (IsAdsDisabled()) |
|
|
if (IsAdsDisabled()) |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
if (_interstitial == null) |
|
|
if (_interstitial == null) |
|
|
throw new NullReferenceException("ads bridge object does not implement IInterstitialBridge"); |
|
|
throw new NullReferenceException("Ads bridge object does not implement IInterstitialBridge"); |
|
|
|
|
|
|
|
|
if (CoreSettings.data.needInterstitial) |
|
|
if (CoreSettings.data.needInterstitial) |
|
|
_interstitial.Show(); |
|
|
_interstitial.Show(); |
|
|
@ -139,7 +139,7 @@ namespace Core.Ads |
|
|
return false; |
|
|
return false; |
|
|
|
|
|
|
|
|
if (_rewarded == null) |
|
|
if (_rewarded == null) |
|
|
throw new NullReferenceException("ads bridge object does not implement IRewardedBridge"); |
|
|
throw new NullReferenceException("Ads bridge object does not implement IRewardedBridge"); |
|
|
|
|
|
|
|
|
if (CoreSettings.data.needRewarded) |
|
|
if (CoreSettings.data.needRewarded) |
|
|
return _rewarded.IsReady(); |
|
|
return _rewarded.IsReady(); |
|
|
@ -149,11 +149,13 @@ namespace Core.Ads |
|
|
|
|
|
|
|
|
public static void ShowRewarded(Action onSucces, Action onFailed) |
|
|
public static void ShowRewarded(Action onSucces, Action onFailed) |
|
|
{ |
|
|
{ |
|
|
|
|
|
Debug.Log("Called show rewarded"); |
|
|
|
|
|
|
|
|
if (IsAdsDisabled()) |
|
|
if (IsAdsDisabled()) |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
if (_rewarded == null) |
|
|
if (_rewarded == null) |
|
|
throw new NullReferenceException("ads bridge object does not implement IRewardedBridge"); |
|
|
throw new NullReferenceException("Ads bridge object does not implement IRewardedBridge"); |
|
|
|
|
|
|
|
|
if (CoreSettings.data.needRewarded) |
|
|
if (CoreSettings.data.needRewarded) |
|
|
_rewarded.Show(onSucces, onFailed); |
|
|
_rewarded.Show(onSucces, onFailed); |
|
|
@ -164,7 +166,7 @@ namespace Core.Ads |
|
|
public static bool IsBannerVisible() |
|
|
public static bool IsBannerVisible() |
|
|
{ |
|
|
{ |
|
|
if (_banner == null) |
|
|
if (_banner == null) |
|
|
throw new NullReferenceException("ads bridge object does not implement IBannerBridge"); |
|
|
throw new NullReferenceException("Ads bridge object does not implement IBannerBridge"); |
|
|
|
|
|
|
|
|
if (CoreSettings.data.needBanner) |
|
|
if (CoreSettings.data.needBanner) |
|
|
_banner.IsVisible(); |
|
|
_banner.IsVisible(); |
|
|
@ -176,11 +178,13 @@ namespace Core.Ads |
|
|
|
|
|
|
|
|
public static void ShowBanner(BannerPositions position) |
|
|
public static void ShowBanner(BannerPositions position) |
|
|
{ |
|
|
{ |
|
|
|
|
|
Debug.Log("Called show banner"); |
|
|
|
|
|
|
|
|
if (IsAdsDisabled()) |
|
|
if (IsAdsDisabled()) |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
if (_banner == null) |
|
|
if (_banner == null) |
|
|
throw new NullReferenceException("ads bridge object does not implement IBannerBridge"); |
|
|
throw new NullReferenceException("Ads bridge object does not implement IBannerBridge"); |
|
|
|
|
|
|
|
|
if (CoreSettings.data.needBanner) |
|
|
if (CoreSettings.data.needBanner) |
|
|
_banner.Show(position); |
|
|
_banner.Show(position); |
|
|
@ -190,8 +194,10 @@ namespace Core.Ads |
|
|
|
|
|
|
|
|
public static void HideBanner() |
|
|
public static void HideBanner() |
|
|
{ |
|
|
{ |
|
|
|
|
|
Debug.Log("Called hide banner"); |
|
|
|
|
|
|
|
|
if (_banner == null) |
|
|
if (_banner == null) |
|
|
throw new NullReferenceException("ads bridge object does not implement IBannerBridge"); |
|
|
throw new NullReferenceException("Ads bridge object does not implement IBannerBridge"); |
|
|
|
|
|
|
|
|
if (CoreSettings.data.needBanner) |
|
|
if (CoreSettings.data.needBanner) |
|
|
_banner.Hide(); |
|
|
_banner.Hide(); |
|
|
|