void RewardedAdCompletedHandler(RewardedAdNetwork network, EasyMobile.AdPlacement location) { //Just ads the points when add completed apparently //Increases rewards to make want player watch more ads //Potentiall this will be changed from current points to MAX obtained points. ClickerCounter.waifuPoints += pointsToAdd; }
private CBLocation ToCBLocation(AdPlacement placement) { return(placement == null || placement == AdPlacement.Default ? CBLocation.Default : CBLocation.locationFromName(placement.Name)); }
//------------------------------------------------------------ // Rewarded Ads. //------------------------------------------------------------ protected override void InternalLoadRewardedAd(AdPlacement _) { // Unity Ads handles loading automatically. }
//------------------------------------------------------------ // Rewarded Ads. //------------------------------------------------------------ /// <summary> /// Instructs the underlaying SDK to load a rewarded ad. Only invoked if the client is initialized. /// AdMob doesn't really support loading multiple rewarded ads at the same time, so we restrict that /// only one ad at any placement can be loaded at a time. The user must consume that ad, or it fails /// to load, before another rewarded ad can be loaded. /// </summary> /// <param name="placement">Placement.</param> protected override void InternalLoadRewardedAd(AdPlacement placement) { #if EM_ADMOB // Loading a new rewarded ad seems to disable all events of the currently playing ad, // so we shouldn't perform rewarded ad loading while playing another one. if (mIsRewardedAdPlaying) { return; } string id = placement == AdPlacement.Default ? mAdSettings.DefaultRewardedAdId.Id : FindIdForPlacement(mAdSettings.CustomRewardedAdIds, placement); if (string.IsNullOrEmpty(id)) { Debug.Log("Attempting to load AdMob rewarded ad with an undefined ID at placement " + AdPlacement.GetPrintableName(placement)); return; } if (placement == AdPlacement.Default) // Default rewarded ad... { if (mIsLoadingCustomRewardedAd) { Debug.LogFormat("An AdMob rewarded ad at placement {0} is being loaded. " + "Please consume it before loading a new one at placement {1}", AdPlacement.GetPrintableName(mLoadingCustomRewardedAdPlacement), AdPlacement.GetPrintableName(AdPlacement.Default)); return; } SetLoadingDefaultRewardedAd(); } else // Custom rewarded ad... { bool isLoadingAnotherOne = false; AdPlacement otherPlacement = null; if (mIsLoadingDefaultRewardedAd) { isLoadingAnotherOne = true; otherPlacement = AdPlacement.Default; } else if (mIsLoadingCustomRewardedAd && mLoadingCustomRewardedAdPlacement != placement) { isLoadingAnotherOne = true; otherPlacement = mLoadingCustomRewardedAdPlacement; } if (isLoadingAnotherOne) { Debug.LogFormat("An AdMob rewarded ad at placement {0} is being loaded. " + "Please consume it before loading a new one at placement {1}", AdPlacement.GetPrintableName(otherPlacement), AdPlacement.GetPrintableName(placement)); return; } SetLoadingCustomRewardedAd(placement); } if (mRewardedAd == null) { mRewardedAd = CreateNewRewardedAd(); } mRewardedAd.LoadAd(CreateAdMobAdRequest(), id); #endif }
//------------------------------------------------------------ // Banner Ads. //------------------------------------------------------------ protected override void InternalShowBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize size) { #if EM_ADMOB string id = placement == AdPlacement.Default ? mAdSettings.DefaultBannerAdId.Id : FindIdForPlacement(mAdSettings.CustomBannerAdIds, placement); if (string.IsNullOrEmpty(id)) { Debug.Log("Attempting to show AdMob banner ad with an undefined ID at placement " + AdPlacement.GetPrintableName(placement)); return; } // If the requested banner (default or custom) doesn't exist or player request a banner with different size, create a new one and show it. // Otherwise just show the existing banner (which might be hidden before). if (placement == AdPlacement.Default) // Default banner... { if (mDefaultBanner == null || mCurrentDefaultBannerSize != size) { mDefaultBanner = CreateNewBanner(position, size, id); mCurrentDefaultBannerSize = size; Debug.Log("Creating new default banner..."); } mDefaultBanner.SetPosition(ToAdMobAdPosition(position)); mDefaultBanner.Show(); } else // Custom banner... { if (!mCustomBannerAds.ContainsKey(placement) || mCustomBannerAds[placement].Value == null || mCustomBannerAds[placement].Key != size) { mCustomBannerAds[placement] = new KeyValuePair <BannerAdSize, BannerView>(size, CreateNewBanner(position, size, id)); Debug.Log("Creating new custom banner..."); } mCustomBannerAds[placement].Value.SetPosition(ToAdMobAdPosition(position)); mCustomBannerAds[placement].Value.Show(); } #endif }
protected string ToIronSourcePlacementName(AdPlacement placement) { return(placement == null || placement == AdPlacement.Default ? null : placement.Name); }
protected override void InternalLoadInterstitialAd(AdPlacement _) { #if EM_IRONSOURCE IronSource.Agent.loadInterstitial(); #endif }
protected override void InternalDestroyBannerAd(AdPlacement _) { Debug.Log(BANNER_UNSUPPORTED_MESSAGE); }
private bool TryFindCustomAdPlacementWithId(Dictionary <AdPlacement, AdId> customSource, string id, out AdPlacement placement) { if (customSource == null) { placement = null; return(false); } foreach (var pair in customSource) { if (pair.Value != null && pair.Value.Id.Equals(id)) { placement = pair.Key; return(true); } } placement = null; return(false); }
protected bool TryFindCustomRewardedVideoAdPlacementWithId(string id, out AdPlacement placement) { return(TryFindCustomAdPlacementWithId(mAdSettings.CustomRewardedAdIds, id, out placement)); }
protected bool TryFindCustomInterstitialAdPlacementWithId(string id, out AdPlacement placement) { return(TryFindCustomAdPlacementWithId(mAdSettings.CustomInterstitialAdIds, id, out placement)); }
protected bool TryFindCustomBannerPlacementWithId(string id, out AdPlacement placement) { return(TryFindCustomAdPlacementWithId(mAdSettings.CustomBannerIds, id, out placement)); }
protected virtual void SetupInterstitialAdEvents(InterstitialAd interstitialAd, AdPlacement placement) { if (interstitialAd != null) { interstitialAd.InterstitialAdDidClose += () => OnInterstitialAdClosed(placement); interstitialAd.InterstitialAdDidClick += OnInterstitialAdClicked; interstitialAd.InterstitialAdDidFailWithError += OnInterstitialAdFailedWithError; interstitialAd.InterstitialAdDidLoad += OnInterstitialAdLoaded; interstitialAd.InterstitialAdWillClose += OnInterstitialWillClose; interstitialAd.InterstitialAdWillLogImpression += OnInterstitialWillLogImpression; } }
/// <summary> /// Create new interstitial with specific id. /// </summary> protected virtual Interstitial CreateNewInterstitialAd(string interstitialId, AdPlacement placement) { if (string.IsNullOrEmpty(interstitialId)) { return(null); } InterstitialAd newInterstitial = new InterstitialAd(interstitialId); SetupInterstitialAdEvents(newInterstitial, placement); newInterstitial.Register(mAdHandlerObject); return(new Interstitial(newInterstitial)); }
void CBDidDismissInterstitial(CBLocation location) { OnInterstitialAdCompleted(AdPlacement.PlacementWithName(location.ToString())); }
protected override void InternalLoadRewardedAd(AdPlacement placement) { }
protected override void InternalShowBannerAd(AdPlacement _, BannerAdPosition __, BannerAdSize ___) { Debug.Log(BANNER_UNSUPPORTED_MESSAGE); }
protected override bool InternalIsRewardedAdReady(AdPlacement placement) { return(false); }
protected override void InternalHideBannerAd(AdPlacement _) { #if EM_IRONSOURCE IronSource.Agent.hideBanner(); #endif }
public override bool IsValidPlacement(AdPlacement placement, AdType type) { return(false); }
protected override void InternalLoadRewardedAd(AdPlacement _) { // IronSource loads rewarded video ads in the background automatically, // so we don't need to do anything here. }
protected override void InternalShowBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize size) { }
private void OnInterstititalAdClosed() { OnInterstitialAdCompleted(mLastShownInterstitialPlacement); mLastShownInterstitialPlacement = AdPlacement.Default; }
protected override void InternalHideBannerAd(AdPlacement placement) { }
//------------------------------------------------------------ // Interstitial Ads. //------------------------------------------------------------ protected override void InternalLoadInterstitialAd(AdPlacement placement) { #if EM_ADMOB string id = placement == AdPlacement.Default ? mAdSettings.DefaultInterstitialAdId.Id : FindIdForPlacement(mAdSettings.CustomInterstitialAdIds, placement); if (string.IsNullOrEmpty(id)) { Debug.Log("Attempting to load AdMob interstitial ad with an undefined ID at placement " + AdPlacement.GetPrintableName(placement)); return; } if (placement == AdPlacement.Default) // Default interstitial... { // Note: On iOS, InterstitialAd objects are one time use objects. // That means once an interstitial is shown, the InterstitialAd object can't be used to load another ad. // To request another interstitial, you'll need to create a new InterstitialAd object. if (mDefaultInterstitialAd == null) { mDefaultInterstitialAd = CreateNewInterstitialAd(id, placement); } mDefaultInterstitialAd.LoadAd(CreateAdMobAdRequest()); } else // Custom interstitial { /// Create a new custom interstitial ad and load it. if (!mCustomInterstitialAds.ContainsKey(placement) || mCustomInterstitialAds[placement] == null) { mCustomInterstitialAds[placement] = CreateNewInterstitialAd(id, placement); } mCustomInterstitialAds[placement].LoadAd(CreateAdMobAdRequest()); } #endif }
protected override void InternalDestroyBannerAd(AdPlacement placement) { }
//------------------------------------------------------------ // Banner Ads. //------------------------------------------------------------ protected override void InternalShowBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize size) { #if UNITY_MONETIZATION string id = placement == AdPlacement.Default ? mAdSettings.DefaultBannerAdId.Id : FindIdForPlacement(mAdSettings.CustomBannerAdIds, placement); if (string.IsNullOrEmpty(id)) { Debug.Log("Attempting to show UnityAds banner ad with an undefined ID at placement " + AdPlacement.GetPrintableName(placement)); return; } if (!Advertisement.Banner.isLoaded) { BannerLoadOptions options = new BannerLoadOptions(); options.errorCallback += ((string message) => { Debug.Log("Error loading Unity banner ad: " + message); }); options.loadCallback += (() => { DoShowBannerAd(id, placement); }); Advertisement.Banner.SetPosition(ToUnityAdsBannerPosition(position)); Advertisement.Banner.Load(id, options); } else { DoShowBannerAd(id, placement); } #else Debug.LogWarning(BANNER_UNSUPPORTED_MESSAGE); #endif }
protected override bool InternalIsInterstitialAdReady(AdPlacement placement) { return(false); }
private void LoadBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize size) { #if EM_ADCOLONY string id = placement == AdPlacement.Default ? mAdSettings.DefaultBannerAdId.Id : FindIdForPlacement(mAdSettings.CustomBannerAdIds, placement); AdColony.AdPosition bannerPosition = AdPosition.Bottom; switch (position) { case BannerAdPosition.Top: bannerPosition = AdPosition.Top; break; case BannerAdPosition.Bottom: bannerPosition = AdPosition.Bottom; break; case BannerAdPosition.TopLeft: bannerPosition = AdPosition.TopLeft; break; case BannerAdPosition.TopRight: bannerPosition = AdPosition.TopRight; break; case BannerAdPosition.BottomLeft: bannerPosition = AdPosition.BottomLeft; break; case BannerAdPosition.BottomRight: bannerPosition = AdPosition.BottomRight; break; default: break; } var adOptions = new AdOptions() { ShowPrePopup = mAdSettings.EnableRewardedAdPrePopup, ShowPostPopup = mAdSettings.EnableRewardedAdPostPopup }; if (!string.IsNullOrEmpty(id)) { AdColony.Ads.RequestAdView(id, AdColony.AdSize.Banner, bannerPosition, adOptions); } else { Debug.Log("Attempting to load AdColony banner ad with an undefined ID at placement " + AdPlacement.GetPrintableName(placement)); } #endif }
protected override void InternalShowInterstitialAd(AdPlacement placement) { }