Пример #1
0
    //What to do after level complete
    public static void OnLevelComplete(LevelInfo data)
    {
        bool isUnityAd = DataManager.Instance.adsSettings.unityAds;
        bool isAdmob   = DataManager.Instance.adsSettings.adMob;
        int  devider   = DataManager.Instance.adsSettings.showAdAfterLevel;

        if (devider > 0) //Show AD depending on setted preferences
        {
            if (((data.currentLevel - 1) % devider) == 0)
            {
                if (isUnityAd && isAdmob)
                {
#if ENABLE_ADMOB && UNITY_ADS
                    if (Random.Range(0, 2) == 1)
                    {
                        if (!AdMob.ShowAdMobAD())
                        {
                            ShowUnityAD();
                        }
                    }

                    else if (!ShowUnityAD())
                    {
                        AdMob.ShowAdMobAD();
                    }
#endif
                }
                else
                {
                    if (isUnityAd)
                    {
#if UNITY_ADS
                        ShowUnityAD();
#endif
                    }
#if ENABLE_ADMOB
                    else
                    {
                        AdMob.ShowAdMobAD();
                    }
#endif
                }
            }
        }
        //Load new scene
        if (data.currentLevel > DataManager.Instance.GetData(data.directoryName).dirLength)
        {
            LoadScene(0);
        }
        else
        {
            LoadScene(1);
        }
    }