예제 #1
0
 public void ShowRewardedAd(AdLocation location)
 {
     #if UNITY_ADS
     if (IsRewardedAdReady(location))
     {
         var showOptions = new ShowOptions
         {
             resultCallback = (result) =>
             {
                 RewardedAdCallback(result, location);
             }
         };
         Advertisement.Show(
             location == AdLocation.Default ? DEFAULT_REWARDED_ZONE_ID : location.ToUnityAdsZoneId(),
             showOptions
             );
     }
     else
     {
         Debug.Log("Could not show UnityAds rewarded ad: ad is not loaded.");
     }
     #else
     Debug.LogError(NO_SDK_MESSAGE);
     #endif
 }
예제 #2
0
        /// <summary>
        /// 添加一条记录
        /// </summary>
        public ResultSet Add(AdLocation entity)
        {
            Func <AdLocation, ResultStatus> validate = (_entity) =>
            {
                return(new ResultStatus());
            };

            Func <AdLocation, ResultStatus> op = (_entity) =>
            {
                int ret = new AdLocationDal().Add(entity);
                if (ret > 0)
                {
                    return(new ResultStatus());
                }
                else
                {
                    return new ResultStatus()
                           {
                               Success     = false,
                               Code        = StatusCollection.AddFailed.Code,
                               Description = StatusCollection.AddFailed.Description
                           }
                };
            };

            return(HandleBusiness(entity, op, validate));
        }
예제 #3
0
        //------------------------------------------------------------
        // Interstitial Ads.
        //------------------------------------------------------------

        public void LoadInterstitialAd(AdLocation location)
        {
            #if EM_ADMOB
            // 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 (interstitialAd != null && interstitialAd.IsLoaded())
            {
                return;
            }

            if (interstitialAd == null)
            {
                // Create new interstitial object.
                interstitialAd = new InterstitialAd(globalAdSettings.AdMobIds.InterstitialAdId);

                // Register for interstitial ad events.
                interstitialAd.OnAdLoaded             += HandleAdMobInterstitialLoaded;
                interstitialAd.OnAdFailedToLoad       += HandleAdMobInterstitialFailedToLoad;
                interstitialAd.OnAdOpening            += HandleAdMobInterstitialOpened;
                interstitialAd.OnAdClosed             += HandleAdMobInterstitialClosed;
                interstitialAd.OnAdLeavingApplication += HandleAdMobInterstitialLeftApplication;
            }

            // By this time interstitialAd either holds the existing, unloaded, unused ad object, or the newly created one.
            interstitialAd.LoadAd(CreateAdMobAdRequest());
            #else
            Debug.LogError(NO_SDK_MESSAGE);
            #endif
        }
예제 #4
0
		public bool IsAdAvailable(string placement) {
			bool retValue = false;
			if(GameUtility.Me.playerData.isRemoveAds && !placement.ToLower().Contains("free")) {
				MyDebug.Log("AdsMCG::IsAdAvailable => Remove Ad purchsed");
				return false;
			}

			AdLocation al = GetPlacement(placement);
			StoreInfo storeInfo = al.GetIdsFor(_store);
			if(null == storeInfo) {
				MyDebug.Log("AdsMCG::IsAdsAvailable => There are not info of {0} store for {1} location", _store, al.Name);
				return false;
			}

			MyDebug.Log(false, "AdsMCG::IsAdsAvailable => Is Ads Available Called");
			switch(storeInfo.Type) {
			case AdType.Interstitial:
				retValue = IsInterstitialAvailable(storeInfo);
				break;

			case AdType.RewardVideo:
				retValue = IsRewardAdAvailable(storeInfo);
				break;

			case AdType.MoreApp:
				retValue = false;
				MyDebug.Warning(false, "AdsMCG::IsAdsAvailable => More App Wall Is not Integrated");
				break;
			}
			return retValue;
		}
예제 #5
0
 void CBDidCloseInterstitial(CBLocation location)
 {
     if (InterstitialAdCompleted != null)
     {
         InterstitialAdCompleted(InterstitialAdNetwork.Chartboost, AdLocation.LocationFromName(location.ToString()));
     }
 }
예제 #6
0
    void RewardedAdCompletedHandler(RewardedAdNetwork network, AdLocation location)
    {
        int beers = PlayerPrefs.GetInt("BEERS");

        PlayerPrefs.SetInt("BEERS", beers + 15);
        UpdateIndicators();
    }
예제 #7
0
        //------------------------------------------------------------
        // Rewarded Ads.
        //------------------------------------------------------------

        public void LoadRewardedAd(AdLocation location)
        {
            #if EM_ADCOLONY
            if (!isInitialized)
            {
                return;
            }

            // Do nothing if a rewarded ad is already loaded.
            if (rewardedAd != null && !rewardedAd.Expired)
            {
                return;
            }

            var adOptions = new EM_AdColony.AdOptions()
            {
                ShowPrePopup  = globalAdSettings.AdColonyShowRewardedAdPrePopup,
                ShowPostPopup = globalAdSettings.AdColonyShowRewardedAdPostPopup
            };

            EM_AdColony.Ads.RequestInterstitialAd(globalAdSettings.AdColonyIds.RewardedAdId, adOptions);
            #else
            Debug.LogError(NO_SDK_MESSAGE);
            #endif
        }
예제 #8
0
        //------------------------------------------------------------
        // Rewarded Ads.
        //------------------------------------------------------------

        public void LoadRewardedAd(AdLocation location)
        {
            // Unity Ads are loaded automatically if enabled.
            #if !UNITY_ADS
            Debug.LogError(NO_SDK_MESSAGE);
            #endif
        }
예제 #9
0
        //------------------------------------------------------------
        // Rewarded Ads.
        //------------------------------------------------------------

        public void LoadRewardedAd(AdLocation location)
        {
            #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 (isRewardedAdPlaying)
            {
                return;
            }

            if (rewardedAd == null)
            {
                rewardedAd = RewardBasedVideoAd.Instance;

                // RewardBasedVideoAd is a singleton, so handlers should only be registered once.
                rewardedAd.OnAdLoaded             += HandleAdMobRewardBasedVideoLoaded;
                rewardedAd.OnAdFailedToLoad       += HandleAdMobRewardBasedVideoFailedToLoad;
                rewardedAd.OnAdOpening            += HandleAdMobRewardBasedVideoOpened;
                rewardedAd.OnAdStarted            += HandleAdMobRewardBasedVideoStarted;
                rewardedAd.OnAdRewarded           += HandleAdMobRewardBasedVideoRewarded;
                rewardedAd.OnAdClosed             += HandleAdMobRewardBasedVideoClosed;
                rewardedAd.OnAdLeavingApplication += HandleAdMobRewardBasedVideoLeftApplication;
            }

            rewardedAd.LoadAd(CreateAdMobAdRequest(), globalAdSettings.AdMobIds.RewardedAdId);
            #else
            Debug.LogError(NO_SDK_MESSAGE);
            #endif
        }
예제 #10
0
        //------------------------------------------------------------
        // Rewarded Ads.
        //------------------------------------------------------------

        public void LoadRewardedAd(AdLocation location)
        {
            #if EM_HEYZAP
            HZIncentivizedAd.Fetch();
            #else
            Debug.LogError(NO_SDK_MESSAGE);
            #endif
        }
예제 #11
0
 public bool IsInterstitialAdReady(AdLocation location)
 {
     #if EM_HEYZAP
     return(HZInterstitialAd.IsAvailable());
     #else
     return(false);
     #endif
 }
예제 #12
0
        //------------------------------------------------------------
        // Interstitial Ads.
        //------------------------------------------------------------

        public void LoadInterstitialAd(AdLocation location)
        {
            #if EM_HEYZAP
            HZInterstitialAd.Fetch();
            #else
            Debug.LogError(NO_SDK_MESSAGE);
            #endif
        }
예제 #13
0
 public bool IsRewardedAdReady(AdLocation location)
 {
     #if EM_CHARTBOOST
     return(Chartboost.hasRewardedVideo(location.ToChartboostLocation()));
     #else
     return(false);
     #endif
 }
예제 #14
0
        //------------------------------------------------------------
        // Rewarded Ads.
        //------------------------------------------------------------

        public void LoadRewardedAd(AdLocation location)
        {
            #if EM_CHARTBOOST
            Chartboost.cacheRewardedVideo(location.ToChartboostLocation());
            #else
            Debug.LogError(NO_SDK_MESSAGE);
            #endif
        }
예제 #15
0
 public bool IsInterstitialAdReady(AdLocation location)
 {
     #if EM_CHARTBOOST
     return(Chartboost.hasInterstitial(location.ToChartboostLocation()));
     #else
     return(false);
     #endif
 }
예제 #16
0
        void OnRewardedAdCompleted(RewardedAdNetwork adNetwork, AdLocation location)
        {
            // Unsubscribe
            AdManager.RewardedAdCompleted -= OnRewardedAdCompleted;

            // Reward the user with coins
            RewardCoins();
        }
예제 #17
0
 public bool IsRewardedAdReady(AdLocation location)
 {
     #if EM_HEYZAP
     return(HZIncentivizedAd.IsAvailable());
     #else
     return(false);
     #endif
 }
예제 #18
0
 public bool IsRewardedAdReady(AdLocation location)
 {
     #if EM_ADMOB
     return(rewardedAd != null && rewardedAd.IsLoaded());
     #else
     return(false);
     #endif
 }
예제 #19
0
 public bool IsInterstitialAdReady(AdLocation location)
 {
     #if EM_ADMOB
     return(interstitialAd != null && interstitialAd.IsLoaded());
     #else
     return(false);
     #endif
 }
예제 #20
0
        //------------------------------------------------------------
        // Interstitial Ads.
        //------------------------------------------------------------

        public void LoadInterstitialAd(AdLocation location)
        {
            #if EM_CHARTBOOST
            Chartboost.cacheInterstitial(location.ToChartboostLocation());
            #else
            Debug.LogError(NO_SDK_MESSAGE);
            #endif
        }
예제 #21
0
 public bool IsRewardedAdReady(AdLocation location)
 {
     #if EM_ADCOLONY
     return(rewardedAd != null && !rewardedAd.Expired);
     #else
     return(false);
     #endif
 }
예제 #22
0
 public bool IsInterstitialAdReady(AdLocation location)
 {
     #if EM_ADCOLONY
     return(interstitialAd != null && !interstitialAd.Expired);
     #else
     return(false);
     #endif
 }
예제 #23
0
		private void GMAInterstitialOpening(string adUnitID) {
			AdLocation al = GetPlacement("GameStart");
			StoreInfo si = al.GetIdsFor(_store);
			if(si.AdMobUnitID.Equals(adUnitID)) {
				isFirstTimeShow = false;
				MyDebug.Log(false, "Game Start Ads Shown at " + DateTime.UtcNow.ToString("O"));
			}
		}
예제 #24
0
		private void CacheAdMob(AdLocation al) {
			if(GameUtility.Me.playerData.isRemoveAds && !al.Name.ToLower().Contains("free")) {
				MyDebug.Log(false, "AdsMCG::CacheAdMobRewardAd => Remove Ad purchsed");
				return;
			}
			StoreInfo si = al.GetIdsFor(_store);
			CacheAdMob(si.AdMobUnitID);
		}
예제 #25
0
		void CBDidDisplayInterstitial(CBLocation location) {
			MyDebug.Log(false, "AdsMGS::CBDidDisplayInterstitial: " + location);
			AdLocation al = GetPlacement("GameStart");
			StoreInfo si = al.GetIdsFor(_store);
			if(si.CBLoation.Equals(location.ToString())) {
				isFirstTimeShow = false;
				MyDebug.Log(false, "Game Start Ads Shown at " + DateTime.UtcNow.ToString("O"));
			}
		}
예제 #26
0
		private void GMAInterstitialClosed(string adUnitID) {
			AdLocation al = GetPlacement("BackFromBG");
			StoreInfo si = al.GetIdsFor(_store);
			if(si.AdMobUnitID.Equals(adUnitID)) {
				MyDebug.Log(false, "Back From BG Ads Shown at " + DateTime.UtcNow.ToString("O"));
				_lastBGAddShown = DateTime.UtcNow;
			}
			CacheAdMob(adUnitID);
		}
예제 #27
0
		private AdLocation GetPlacement(string placemnetName) {
			AdLocation al = new AdLocation();
			foreach(AdLocation al1 in adLocations) {
				if(al1.Name.Equals(placemnetName, StringComparison.OrdinalIgnoreCase)) {
					al = al1;
				}
			}
			return al;
		}
예제 #28
0
        public IActionResult GetAd(AdLocation type)
        {
            var adv = new AdvertisingModel();

            if (type.Equals(AdLocation.Home))
            {
                adv.AdName = "测试";
            }
            return(Json(type));
        }
예제 #29
0
 public bool IsRewardedAdReady(AdLocation location)
 {
     #if UNITY_ADS
     return(Advertisement.IsReady(
                location == AdLocation.Default ? DEFAULT_REWARDED_ZONE_ID : location.ToUnityAdsZoneId()
                ));
     #else
     return(false);
     #endif
 }
예제 #30
0
		void CBDidCloseInterstitial(CBLocation location) {
			MyDebug.Log(false, "AdsMGS::CBDidCloseInterstitial: " + location);

			AdLocation al = GetPlacement("BackFromBG");
			StoreInfo si = al.GetIdsFor(_store);
			if(si.CBLoation.Equals(location.ToString())) {
				MyDebug.Log(false, "Back From BG Ads Shown at " + DateTime.UtcNow.ToString("O"));
				_lastBGAddShown = DateTime.UtcNow;
			}
		}