public void Init()
    {
        if (BuildConfig.HIDE_ADS || this.adsDisabled)
        {
            return;
        }
        this.GetServerConfig();
        this.ads            = this.CreateAdsNetwork();
        this.bannerDisabled = !this.config.BannerIsOn();
        this.fsDisabled     = !this.config.FsIsOn();
        string b            = this.bannerDisabled ? null : this.config.bannerAdUnit;
        string fs           = this.fsDisabled ? null : this.config.fsAdUnit;
        string rewardAdUnit = this.config.rewardAdUnit;

        FMLogger.vAds(string.Concat(new object[]
        {
            "init. b: ",
            !this.bannerDisabled,
            " fs: ",
            !this.fsDisabled
        }));
        this.ads.Configure(this.config.adsTest, this.config.bannerShowTime, this.config.bannerLoadDelay, this.config.fsInternalOnReward);
        this.ads.Initialize(b, this.config.bannerPos, fs, rewardAdUnit);
        this.ads.RewardedComplete += delegate(object sender, EventArgs e)
        {
            if (this.RewardedVideoComplete != null)
            {
                this.RewardedVideoComplete();
            }
        };
    }
 public void InitializeBanner(string bAdUnit, BannerPosition bannerPos)
 {
     if (this.bannerEnabled)
     {
         return;
     }
     if (!string.IsNullOrEmpty(bAdUnit))
     {
         try
         {
             this.bannerAdUnit   = bAdUnit;
             this.bannerEnabled  = true;
             this.bannerPosition = ((bannerPos != BannerPosition.Bottom) ? MoPubBase.AdPosition.TopCenter : MoPubBase.AdPosition.BottomCenter);
             this.InternalInit(this.bannerAdUnit);
             MoPubAndroid.LoadBannerPluginsForAdUnits(new string[]
             {
                 this.bannerAdUnit
             });
         }
         catch (Exception ex)
         {
             this.bannerEnabled = false;
             FMLogger.vAds("failed to init mopab banner. error: " + ex.Message);
         }
         this.RequestBanner();
     }
 }
 private void onRewardedVideoLoadedEvent(string adUnitId)
 {
     FMLogger.vAds("onRewardedVideoLoadedEvent: " + adUnitId);
     AdsManager.Instance.rewardInfo.IterateLoaded();
     AdsManager.Instance.rewardInfo.LoadTime = (int)(DateTime.Now - this.rewardLoadReqTime).TotalSeconds;
     AnalyticsManager.RewardLoaded(AdsManager.Instance.rewardInfo);
 }
    private AdConfig LoadDefaultConfig()
    {
        AdConfig adConfig = null;
        string   @string  = PlayerPrefs.GetString("adsconfig", string.Empty);

        if (!string.IsNullOrEmpty(@string))
        {
            adConfig = JsonUtility.FromJson <AdConfig>(@string);
        }
        FMLogger.vCore("cfg str: " + @string);
        if (adConfig == null)
        {
            adConfig = ((!this.isTablet) ? AdConfig.DefaultPhone() : AdConfig.DefaultTablet());
        }
        if (string.IsNullOrEmpty(adConfig.bannerAdUnit))
        {
            adConfig.bannerAdUnit = ((!this.isTablet) ? "f22e60410d82403aa5e0fb791ef9c153" : "1253b5589a4d45869288611de14229d6");
            FMLogger.vAds("cfg fix banner unit");
        }
        if (string.IsNullOrEmpty(adConfig.fsAdUnit))
        {
            adConfig.fsAdUnit = ((!this.isTablet) ? "72bb0678c400487b8d1a941944fa6888" : "8cae328870984a9987623f9c6e52b25d");
            FMLogger.vAds("cfg fix fs unit");
        }
        if (string.IsNullOrEmpty(adConfig.rewardAdUnit))
        {
            adConfig.rewardAdUnit = ((!this.isTablet) ? "6bc3898062484e71a114d0ab59cb1c78" : "0543e571406140dd96252ac1351b99f5");
            FMLogger.vAds("cfg fix reward unit");
        }
        this.SaveConfig(adConfig);
        FMLogger.vAds("loaded saved cfg: " + adConfig);
        return(adConfig);
    }
Exemple #5
0
 private IEnumerator Checker()
 {
     FMLogger.vAds("hint btn start checker. rs:" + this.hasRewarded);
     while (this.shouldCheckRewarded)
     {
         while (!this.hasRewarded)
         {
             this.hasRewarded = AdsManager.Instance.HasRewardedVideo();
             if (this.hasRewarded)
             {
                 this.label.text = this.AD_STR;
                 FMLogger.vAds("hint checker upd. AD");
             }
             yield return(new WaitForSeconds(1f));
         }
         while (this.hasRewarded)
         {
             this.hasRewarded = AdsManager.Instance.HasRewardedVideo();
             if (!this.hasRewarded)
             {
                 this.label.text = GeneralSettings.HintsCount.ToString();
                 FMLogger.vAds("hint checker upd. Rewarded GONE");
             }
             yield return(new WaitForSeconds(3f));
         }
         yield return(0);
     }
     yield break;
 }
    private void InitRewarded()
    {
        if (BuildConfig.HIDE_ADS || this.ads != null)
        {
            return;
        }
        if (this.ads == null)
        {
            this.ads = this.CreateAdsNetwork();
        }
        if (!this.configRequested)
        {
            this.GetServerConfig();
        }
        string rewardAdUnit = this.config.rewardAdUnit;

        if (string.IsNullOrEmpty(rewardAdUnit))
        {
            FMLogger.vAds("Init rewarded fail. Empty ad unit");
            return;
        }
        this.ads.InitializeRewarded(rewardAdUnit);
        this.ads.RewardedComplete += delegate(object sender, EventArgs e)
        {
            if (this.RewardedVideoComplete != null)
            {
                this.RewardedVideoComplete();
            }
        };
        FMLogger.vAds("Init rewarded only");
    }
 private void Start()
 {
     this.AdjustInit();
     this.FirebaseInit();
     this.CheckDailyBonus();
     try
     {
         PlayTimeEventTracker.AppResume();
     }
     catch (Exception ex)
     {
         UnityEngine.Debug.Log("PlayTimeEventTracker ex. " + ex.Message);
     }
     this.deepLinker = new DeeplinkController(base.GetComponent <FMDeepLink>());
     this.deepLinker.BonusCodeReceived += this.OnFBDeeplinkOpened;
     AppState.ContentReqTime            = DateTime.Now;
     base.StartCoroutine(this.LoadSysParameters(delegate
     {
         AdsManager.Instance.SetParams(this.adsId, this.adsLimitied);
         if (GeneralSettings.AdsDisabled)
         {
             FMLogger.vAds("casual disable ads on startup");
             AdsManager.Instance.DisableAds();
         }
         else
         {
             FMLogger.vAds("ads init");
             AdsManager.Instance.Init();
             AdsManager.Instance.StartFsInterval();
         }
         TGFModule.Instance.Init(this.adsId, this.adsLimitied, this.countryCode, this.langCode);
         ImageManager.Instance.Init();
         SharedData.Instance.Init();
         //FB.Init(null, null, null);
         AppState.LaunchTime = DateTime.Now;
         this.fairyController.StartTimer();
         this.deepLinker.Check();
         TGFModule.Instance.PrecachePages();
         try
         {
             AnalyticsManager.SetUserDeviceTypeProperty(SafeLayout.IsTablet);
         }
         catch (Exception ex2)
         {
             FMLogger.vCore("SetUserDeviceTypeProperty crash. " + ex2.Message);
         }
         float delay = 0.5f;
         if (AppManager.__f__mg_cache0 == null)
         {
             AppManager.__f__mg_cache0 = new Action(UserLifecycle.AppLaunch);
         }
         base.StartCoroutine(this.DelayAction(delay, AppManager.__f__mg_cache0));
         AppManager.inited = true;
         if (this.Loaded != null)
         {
             this.Loaded();
         }
     }));
 }
    private IEnumerator BannerHideWorkaround()
    {
        yield return(0);

        FMLogger.vAds("hide banner after req on next frame. workaround");
        MoPubAndroid.ShowBanner(this.bannerAdUnit, false);
        yield break;
    }
 public void ShouldReward(string dummy)
 {
     FMLogger.vAds("FAdsManager ShouldReward received");
     if (FAdsManager.RewardedCompleted != null)
     {
         FAdsManager.RewardedCompleted();
     }
 }
 public void HideBanner()
 {
     if (!this.bannerEnabled)
     {
         return;
     }
     FMLogger.vAds("hide banner inv");
     FAdsIOS.HideBanner();
 }
 private void SaveConfig(AdConfig c)
 {
     if (c == null)
     {
         return;
     }
     PlayerPrefs.SetString("adsconfig", JsonUtility.ToJson(c));
     FMLogger.vAds("saving new cfg: " + c);
 }
    private IEnumerator FsReloadTimeout()
    {
        FMLogger.vAds("start fs reload timer");
        yield return(new WaitForSeconds(15f));

        FMLogger.vAds("start fs reload timeout. requesting new");
        this.RequestInterstitial();
        yield break;
    }
    private void GetServerConfig()
    {
        this.configRequested = true;
        string     url  = this.adsUrl + this.adsUrlQueue;
        WebGetTask task = new WebGetTask(url, delegate(bool success, string text)
        {
            if (!this.IsEnabled())
            {
                FMLogger.vAds("recieved ads config, but ads is off");
                return;
            }
            if (success && !string.IsNullOrEmpty(text))
            {
                try
                {
                    byte[] bytes = Convert.FromBase64String(text);
                    text         = Encoding.UTF8.GetString(bytes);
                    char[] array = text.ToCharArray();
                    Array.Reverse(array);
                    text          = new string(array);
                    byte[] bytes2 = Convert.FromBase64String(text);
                    text          = Encoding.UTF8.GetString(bytes2);
                    AdsServerResponse adsServerResponse = JsonUtility.FromJson <AdsServerResponse>(text);
                    if (adsServerResponse != null)
                    {
                        if (adsServerResponse.ad_module_active == 0)
                        {
                            FMLogger.vAds("disable ads from config");
                            this.DisableAds();
                            this.config.DisableAds();
                            this.config.UpdateReward(AdConfig.FromRespone(adsServerResponse.rewarded_config, true), adsServerResponse.adUnit_rewarded);
                            this.SaveConfig(this.config);
                        }
                        else
                        {
                            AdConfig adConfig = AdConfig.FromResponse(adsServerResponse, this.isTablet);
                            this.SaveConfig(adConfig);
                            this.config.UpdateFsParamsFromServer(adConfig);
                            this.fsDisabled     = !this.config.FsIsOn();
                            this.bannerDisabled = !adConfig.BannerIsOn();
                        }
                    }
                }
                catch (Exception ex)
                {
                    FMLogger.vAds("config parse ex. msg:" + ex.Message);
                }
            }
            else
            {
                FMLogger.vAds("config  req server error. reschedule request");
                base.StartCoroutine(this.DelayAction(20f, new Action(this.GetServerConfig)));
            }
        });

        WebLoader.Instance.LoadText(task);
    }
    private IEnumerator RewardReloadTimeout()
    {
        FMLogger.vAds("start reward reload timer");
        yield return(new WaitForSeconds(16f));

        FMLogger.vAds("start reward reload timeout. requesting new");
        this.InternalRewardedRequest();
        yield break;
    }
 public void ShowBanner()
 {
     if (!this.bannerEnabled)
     {
         return;
     }
     FMLogger.vAds("show banner inv");
     FAdsIOS.ShowBanner();
 }
    private IEnumerator FsClickDelayEvent(string adUnit, string placement)
    {
        yield return(0);

        yield return(0);

        AnalyticsManager.FsClick(adUnit, placement);
        FMLogger.vAds("FsClick event sent");
        yield break;
    }
 public void RequestInterstitial()
 {
     if (!this.fsEnabled)
     {
         return;
     }
     this.fsLoadReqTime = DateTime.Now;
     MoPubAndroid.RequestInterstitialAd(this.interstitialAdUnit, string.Empty, string.Empty);
     FMLogger.vAds("start fs request");
 }
 public void UtilizeBanner()
 {
     if (!this.bannerEnabled)
     {
         return;
     }
     this.bannerEnabled = false;
     FMLogger.vAds("utilize banner inv");
     MoPubAndroid.DestroyBanner(this.bannerAdUnit);
 }
    public void SdkInitialized(string argsJson)
    {
        FMLogger.vAds("FAdsManager SdkInitialized received");
        FAdsInitData obj = this.ParseInitEventData(argsJson);

        if (FAdsManager.Initialized != null)
        {
            FAdsManager.Initialized(obj);
        }
    }
    public void AdsEvent(string argsJson)
    {
        FMLogger.vAds("FAdsManager AdsEvent received args: " + ((!string.IsNullOrEmpty(argsJson)) ? argsJson : "null"));
        FAdsEventData obj = this.ParseAdsEventData(argsJson);

        if (FAdsManager.AdsEventReceived != null)
        {
            FAdsManager.AdsEventReceived(obj);
        }
    }
 public void RequestRewardedVideo()
 {
     if (!this.rewardedEnabled)
     {
         return;
     }
     this.autoloadRewarded = true;
     this.InternalRewardedRequest();
     FMLogger.vAds("start reward request");
 }
 public void ShowRewardedVideo()
 {
     if (!this.rewardedEnabled)
     {
         return;
     }
     FMLogger.vAds("show rewarded");
     AdsManager.Instance.rewardInfo.IterateImpression();
     FAdsIOS.ShowRewarded();
 }
 public void RequestRewardedVideo()
 {
     if (!this.rewardedEnabled)
     {
         return;
     }
     this.autoloadRewarded = true;
     FMLogger.vAds("start reward request");
     FAdsIOS.LoadRewarded();
 }
 public void ShowInterstitial(AdPlacement fsPlacement)
 {
     if (!this.fsEnabled)
     {
         return;
     }
     this.fsAdPlacement = AdConfig.AdPlacementToString(fsPlacement);
     FMLogger.vAds("fs show inv");
     FAdsIOS.ShowInterstitial();
 }
 private void onRewardedVideoReceivedRewardEvent(string adUnitId, string label, float amount)
 {
     this.rewardReceived = true;
     if (this.RewardedComplete != null)
     {
         this.RewardedComplete(null, EventArgs.Empty);
     }
     FMLogger.vAds("onRewardedVideoReceivedRewardEvent: " + adUnitId);
     AnalyticsManager.RewardFinish(adUnitId);
 }
 public void HideBanner()
 {
     if (!this.bannerEnabled)
     {
         return;
     }
     FMLogger.vAds("hide banner inv");
     MoPubAndroid.ShowBanner(this.bannerAdUnit, false);
     this.bannerVisable = false;
 }
 public void DisableAds()
 {
     this.HideBanner(true);
     if (this.ads != null)
     {
         this.ads.UtilizeBanner();
         this.ads.Utilize();
     }
     this.adsDisabled = true;
     FMLogger.vAds("AdsManager - disable ads");
 }
    private IEnumerator CheckIfRewardedCanceled(string adUnit)
    {
        yield return(new WaitForSeconds(0.5f));

        if (!this.rewardReceived)
        {
            FMLogger.vAds("rewarded cancel");
            AnalyticsManager.RewardCancel(adUnit);
        }
        yield break;
    }
 public void ShowInterstitial(AdPlacement fsPlacement)
 {
     if (!this.fsEnabled)
     {
         return;
     }
     this.fsAdPlacement = AdConfig.AdPlacementToString(fsPlacement);
     FMLogger.vAds("fs show inv");
     MoPubAndroid.ShowInterstitialAd(this.interstitialAdUnit);
     this.hasLoadedInterstitial = false;
     AnalyticsManager.FsImpression(this.interstitialAdUnit, this.fsAdPlacement);
 }
 public void ShowRewardedVideo()
 {
     if (!this.rewardedEnabled)
     {
         return;
     }
     FMLogger.vAds("show rewarded");
     this.rewardReceived = false;
     MoPubAndroid.ShowRewardedVideo(this.rewardUnit, null);
     AdsManager.Instance.rewardInfo.IterateImpression();
     AnalyticsManager.RewardImpression(this.rewardUnit, AdsManager.Instance.rewardInfo);
 }