コード例 #1
0
 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;
 }
コード例 #2
0
 private CBLocation ToCBLocation(AdPlacement placement)
 {
     return(placement == null || placement == AdPlacement.Default ? CBLocation.Default : CBLocation.locationFromName(placement.Name));
 }
コード例 #3
0
        //------------------------------------------------------------
        // Rewarded Ads.
        //------------------------------------------------------------

        protected override void InternalLoadRewardedAd(AdPlacement _)
        {
            // Unity Ads handles loading automatically.
        }
コード例 #4
0
        //------------------------------------------------------------
        // 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
        }
コード例 #5
0
        //------------------------------------------------------------
        // 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
        }
コード例 #6
0
 protected string ToIronSourcePlacementName(AdPlacement placement)
 {
     return(placement == null || placement == AdPlacement.Default ? null : placement.Name);
 }
コード例 #7
0
        protected override void InternalLoadInterstitialAd(AdPlacement _)
        {
#if EM_IRONSOURCE
            IronSource.Agent.loadInterstitial();
#endif
        }
コード例 #8
0
 protected override void InternalDestroyBannerAd(AdPlacement _)
 {
     Debug.Log(BANNER_UNSUPPORTED_MESSAGE);
 }
コード例 #9
0
ファイル: MoPubClientImpl.cs プロジェクト: artemy0/Quiz
        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);
        }
コード例 #10
0
ファイル: MoPubClientImpl.cs プロジェクト: artemy0/Quiz
 protected bool TryFindCustomRewardedVideoAdPlacementWithId(string id, out AdPlacement placement)
 {
     return(TryFindCustomAdPlacementWithId(mAdSettings.CustomRewardedAdIds, id, out placement));
 }
コード例 #11
0
ファイル: MoPubClientImpl.cs プロジェクト: artemy0/Quiz
 protected bool TryFindCustomInterstitialAdPlacementWithId(string id, out AdPlacement placement)
 {
     return(TryFindCustomAdPlacementWithId(mAdSettings.CustomInterstitialAdIds, id, out placement));
 }
コード例 #12
0
ファイル: MoPubClientImpl.cs プロジェクト: artemy0/Quiz
 protected bool TryFindCustomBannerPlacementWithId(string id, out AdPlacement placement)
 {
     return(TryFindCustomAdPlacementWithId(mAdSettings.CustomBannerIds, id, out placement));
 }
コード例 #13
0
 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;
     }
 }
コード例 #14
0
        /// <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));
        }
コード例 #15
0
 void CBDidDismissInterstitial(CBLocation location)
 {
     OnInterstitialAdCompleted(AdPlacement.PlacementWithName(location.ToString()));
 }
コード例 #16
0
ファイル: NoOpClientImpl.cs プロジェクト: artemy0/Quiz
 protected override void InternalLoadRewardedAd(AdPlacement placement)
 {
 }
コード例 #17
0
 protected override void InternalShowBannerAd(AdPlacement _, BannerAdPosition __, BannerAdSize ___)
 {
     Debug.Log(BANNER_UNSUPPORTED_MESSAGE);
 }
コード例 #18
0
ファイル: NoOpClientImpl.cs プロジェクト: artemy0/Quiz
 protected override bool InternalIsRewardedAdReady(AdPlacement placement)
 {
     return(false);
 }
コード例 #19
0
        protected override void InternalHideBannerAd(AdPlacement _)
        {
#if EM_IRONSOURCE
            IronSource.Agent.hideBanner();
#endif
        }
コード例 #20
0
ファイル: NoOpClientImpl.cs プロジェクト: artemy0/Quiz
 public override bool IsValidPlacement(AdPlacement placement, AdType type)
 {
     return(false);
 }
コード例 #21
0
 protected override void InternalLoadRewardedAd(AdPlacement _)
 {
     // IronSource loads rewarded video ads in the background automatically,
     // so we don't need to do anything here.
 }
コード例 #22
0
ファイル: NoOpClientImpl.cs プロジェクト: artemy0/Quiz
 protected override void InternalShowBannerAd(AdPlacement placement, BannerAdPosition position, BannerAdSize size)
 {
 }
コード例 #23
0
 private void OnInterstititalAdClosed()
 {
     OnInterstitialAdCompleted(mLastShownInterstitialPlacement);
     mLastShownInterstitialPlacement = AdPlacement.Default;
 }
コード例 #24
0
ファイル: NoOpClientImpl.cs プロジェクト: artemy0/Quiz
 protected override void InternalHideBannerAd(AdPlacement placement)
 {
 }
コード例 #25
0
        //------------------------------------------------------------
        // 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
        }
コード例 #26
0
ファイル: NoOpClientImpl.cs プロジェクト: artemy0/Quiz
 protected override void InternalDestroyBannerAd(AdPlacement placement)
 {
 }
コード例 #27
0
        //------------------------------------------------------------
        // 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
        }
コード例 #28
0
ファイル: NoOpClientImpl.cs プロジェクト: artemy0/Quiz
 protected override bool InternalIsInterstitialAdReady(AdPlacement placement)
 {
     return(false);
 }
コード例 #29
0
        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
        }
コード例 #30
0
ファイル: NoOpClientImpl.cs プロジェクト: artemy0/Quiz
 protected override void InternalShowInterstitialAd(AdPlacement placement)
 {
 }