Esempio n. 1
0
 //call whenever provider dissmiss ad
 public static void OnDimissAd(AdType type)
 {
     if (type == AdType.Interstitial && cachedInterstitialCallback != null)
     {
         cachedInterstitialCallback(ShowAdResult.Shown);
         cachedInterstitialCallback = null;
     }
     RevertTimeScale();
 }
Esempio n. 2
0
 static void NotifyInterstitialEvent(InterstitialCallBack callback, ShowAdResult result)
 {
     if (callback != null)
     {
         callback(result);
     }
     if (allInterstitialsEvent != null)
     {
         allInterstitialsEvent(result);
     }
 }
Esempio n. 3
0
        static bool ShowInterstitial(InterstitialCallBack callback = null, string key = null, bool isLimited = true)
        {
            if (instance == null)
            {
                return(false);
            }
            // Kiểm tra kết nối internet.
            if (isLimited && config.RequiredInternetConnection && !NetworkUtil.HasNetworkConnection())
            {
                NotifyInterstitialEvent(callback, ShowAdResult.NoInternet);
                return(false);
            }
            // Kiểm tra giới hạn thời gian
            if (isLimited && config.IsTimeLimited &&
                (!EnableInterstitial || TimeUtil.SecondsFrom(LastInterstitialTime) < config.BetweenInterstitialLimited))
            {
                //CLog.Log(this, "Showing interstitial has been skipped for startup");
                NotifyInterstitialEvent(callback, ShowAdResult.SkipByOther);
                return(false);
            }
            // Check skip by step
            if (isLimited && config.IsSkipInterstitial)
            {
                if (skipInterstitialCount == -1)
                {
                    skipInterstitialCount = config.SkipInterstitialStep;
                }
                if (skipInterstitialCount == 0)
                {
                    //bắt đầu đếm lại
                    skipInterstitialCount = config.SkipInterstitialStep;
                    //CLog.Log(this, "Showing interstitial has been skipped for startup");
                    NotifyInterstitialEvent(callback, ShowAdResult.SkipByOther);
                    return(false);
                }
            }

            var selectedProviderIds = GetProfileByType(AdType.Interstitial);

            for (int i = 0; i < selectedProviderIds.Count; i++)
            {
                ProviderID id       = selectedProviderIds[i];
                var        provider = FindActiveAdProvider(id);
                if (provider == null || !provider.IsSupport(AdType.Interstitial))
                {
                    //CLog.Warn(this, id.ToString() + " has not supported Interstitial!");
                    continue;
                }
                else if (provider.IsLoadedInterstitial(key))
                {
                    if (isLimited)
                    {
                        LastInterstitialTime = DateTime.Now;
                        skipInterstitialCount--;
                    }
                    // Cache callback to involke later
                    cachedInterstitialCallback = callback;
                    // Only sequence mode
                    if (config.interstitialProfileMode == ProfileMode.Sequence)
                    {
                        MoveItemToEndOfList(i, selectedProviderIds);
                    }
                    else if (config.interstitialProfileMode == ProfileMode.Random)
                    {
                        ShuffleProviders(selectedProviderIds);
                    }
                    if (AdsMaster.settings.ActiveZeroTimeScale)
                    {
                        DisableTimeScale();
                    }
                    provider.ShowInterstitial();
                    return(true);
                }
            }
            //has no ad
            NotifyInterstitialEvent(callback, ShowAdResult.NoAds);
            return(false);
        }
Esempio n. 4
0
 public static bool ShowInterstitialForced(InterstitialCallBack callback = null, string key = null)
 {
     return(ShowInterstitial(callback, key, false));
 }