Beispiel #1
0
    public void RequestNativeAds(AdPosition nativeAdPosition)
    {
        if (isNativeAdLoaded)
        {
            return;
        }

        // Create a 320x50 native express ad at the top of the screen.
        nativeExpressAdView = new NativeExpressAdView(_nativeAdsId, new AdSize(320, 150), nativeAdPosition);
        // Load a banner ad.
        nativeExpressAdView.LoadAd(new AdRequest.Builder()
                                   .AddTestDevice(AdRequest.TestDeviceSimulator)      // Simulator.
                                   .AddTestDevice("2077ef9a63d2b398840261c8221a0c9b") // My test device.
                                   .Build());

        //Debug.Log("Load native ads");

        if (!handleNativeAdsSet)
        {
            // Called when an ad request has successfully loaded.
            nativeExpressAdView.OnAdLoaded += HandleOnNativeAdLoaded;
            // Called when an ad request failed to load.
            nativeExpressAdView.OnAdFailedToLoad += HandleOnNativeAdFailedToLoad;

            // Called when an ad is clicked.
            //nativeExpressAdView.OnAdOpened += HandleOnAdOpened;
            // Called when the user returned from the app after an ad click.
            //nativeExpressAdView.OnAdClosed += HandleOnNativeAdClosed;
            // Called when the ad click caused the user to leave the application.
            //nativeExpressAdView.OnAdLeavingApplication += HandleOnAdLeavingApplication;

            handleNativeAdsSet = true;
        }
    }
Beispiel #2
0
 public void LoadNative()
 {
     if (nativeAd != null)
     {
         AdRequest request = new AdRequest.Builder().Build();
         nativeAd.LoadAd(request);
     }
 }
Beispiel #3
0
    private void RequestBanner()
    {
                #if UNITY_EDITOR
        string adUnitId = "unused";
                #elif UNITY_ANDROID
        string adUnitId = "ca-app-pub-3804976617812716/4394413705";
                #elif UNITY_IPHONE
        string adUnitId = "unused";
                #else
        string adUnitId = "unexpected_platform";
                #endif

        AdRequest adRequest = new AdRequest.Builder()
                              .AddTestDevice("2645D5FFD3A4D7B1")
                              .Build();


        if (screenWidth <= 500)
        {
            bannerView = new NativeExpressAdView(adUnitId, new AdSize(280, 250), 10, 120);      //SIZE MUST BE SAME AS ADMOB SIZE
        }
        else if (screenWidth <= 600)
        {
            bannerView = new NativeExpressAdView(adUnitId, new AdSize(280, 250), 40, 140);      //SIZE MUST BE SAME AS ADMOB SIZE
        }
        else if (screenWidth <= 900)
        {
            bannerView = new NativeExpressAdView(adUnitId, new AdSize(280, 250), 40, 120 + (screenWidth / 16));      //SIZE MUST BE SAME AS ADMOB SIZE 40 + (screenWidth / 16)
        }
        else if (screenWidth <= 1100)
        {
            bannerView = new NativeExpressAdView(adUnitId, new AdSize(300, 300), 10 + (screenWidth / 20), 50 + (screenWidth / 14));      //1920 x 1080
        }
        else if (screenWidth <= 1400)
        {
            bannerView = new NativeExpressAdView(adUnitId, new AdSize(340, 340), 42 + (screenWidth / 13), 120 + (screenWidth / 6));      //Nexus 7
        }
        else if (screenWidth <= 1800)
        {
            bannerView = new NativeExpressAdView(adUnitId, new AdSize(340, 340), 15 + (screenWidth / 13), 50 + (screenWidth / 12));      //1440 x 2560
        }
        else
        {
            bannerView = new NativeExpressAdView(adUnitId, new AdSize(340, 340), 42 + (screenWidth / 13), 120 + (screenWidth / 6));      //SIZE MUST BE SAME AS ADMOB SIZE
        }

        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder().Build();
        // Load the banner with the request.
        bannerView.LoadAd(request);
    }
        private void SetAdView()
        {
            var adContainer = view.FindViewById <Android.Widget.RelativeLayout>(Resource.Id.adContainer);
            var adView      = new NativeExpressAdView(Context);

            adView.AdSize   = new AdSize(AdSize.FullWidth, 150);
            adView.AdUnitId = "ca-app-pub-XXXXXXXXXXXXXXX";

            adContainer.AddView(adView);

            adView.LoadAd(new AdRequest
                          .Builder()
                          .Build());
        }
Beispiel #5
0
    public void preloadNativeAd()
    {
        TotalData.LoadTotalFromFile();
        if (TotalData.total.noAds)
        {
//			nativeExpressAdView.Hide ();
        }
        else
        {
            nativeExpressAdView = new NativeExpressAdView(adUnitId, AdSize.MediumRectangle, AdPosition.BottomRight);
            AdRequest request = new AdRequest.Builder().Build();
            nativeExpressAdView.LoadAd(request);
            nativeExpressAdView.Hide();
        }
    }
Beispiel #6
0
        public void RequestNativeExpressAdView()
        {
#if UNITY_EDITOR
            string adUnitId = "unused";
#elif UNITY_ANDROID
            string adUnitId = "ca-app-pub-3026969986215886/2601757351";
#elif UNITY_IOS || UNITY_IPHONE
            string adUnitId = "ca-app-pub-3026969986215886/5656546510";
#else
            string adUnitId = "unexpected_platform";
#endif
            float screenHeightInch = Screen.height / Screen.dpi;
            float screenWidthInch  = Screen.width / Screen.dpi;

            int x = 30;
            int y = 300;

            if (screenHeightInch < 3f)
            {
                y = (int)(109f * screenHeightInch);
            }
            else
            {
                float temp = screenHeightInch - 3f;
                y = (int)(screenHeightInch * (110f - (temp * 6f)));
            }


            if (screenWidthInch < 2.5f)
            {
                x = (int)(15f * screenWidthInch);
            }
            else if (screenWidthInch < 3f)
            {
                x = (int)(25f * screenWidthInch);
            }
            else
            {
                float temp = screenWidthInch - 3f;
                x = (int)(screenWidthInch * (33f + temp));
            }

            // Create a 320x50 native express ad at the top of the screen.
            nativeExpressAdView = new NativeExpressAdView(adUnitId, new AdSize(300, 80), x, y);
            // Load a banner ad.
            nativeExpressAdView.LoadAd(new AdRequest.Builder().Build());
        }
Beispiel #7
0
    private void RequestNativeExpressAdView()
    {
#if UNITY_EDITOR
        string adUnitId = "unused";
#elif UNITY_ANDROID
        string adUnitId = "ca-app-pub-8920179393260755/9049692625";
#elif UNITY_IPHONE
        string adUnitId = "ca-app-pub-8920179393260755/9049692625";
#else
        string adUnitId = "unexpected_platform";
#endif

        // Create a 320x50 native express ad at the top of the screen.
        nativeExpressAdView = new NativeExpressAdView(adUnitId, new AdSize(320, 150), AdPosition.Top);
        // Load a banner ad.
        nativeExpressAdView.OnAdFailedToLoad += HandleOnAdFailedToLoad;
        nativeExpressAdView.LoadAd(new AdRequest.Builder().Build());
    }
Beispiel #8
0
        public override void SetupDialog(Dialog dialog, int style)
        {
            try
            {
                base.SetupDialog(dialog, style);
                //Get the content View
                View contentView = View.Inflate(this.Context, Resource.Layout.AdmobNative_Layout, null);
                dialog.SetContentView(contentView);

                //Set the coordinator layout behavior
                CoordinatorLayout.LayoutParams Params   = (CoordinatorLayout.LayoutParams)((View)contentView.Parent).LayoutParameters;
                CoordinatorLayout.Behavior     behavior = Params.Behavior;

                //Set callback
                if (behavior != null && behavior.GetType() == typeof(BottomSheetBehavior))
                {
                    ((BottomSheetBehavior)behavior).SetBottomSheetCallback(mBottomSheetBehaviorCallback);
                }

                string android_id = Android.Provider.Settings.Secure.GetString(this.Context.ContentResolver, Android.Provider.Settings.Secure.AndroidId);

                native = contentView.FindViewById <NativeExpressAdView>(Resource.Id.adViewNative);
                // Create an ad request.
                AdRequest.Builder adRequestBuilder = new AdRequest.Builder();

                // Optionally populate the ad request builder.
                adRequestBuilder.AddTestDevice(android_id);

                // Start loading the ad.
                native.LoadAd(adRequestBuilder.Build());

                native.Visibility = ViewStates.Visible;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
    /// <summary>
    /// Loads a banner advert into memory.
    /// </summary>
    /// <param name="AdType">Admob banner ad type.</param>
    /// <param name="XPos">X placement position relative to top left</param>
    /// <param name="YPos">Y placement position relative to top left</param>
    /// <param name="DisplayImmediately">If set to <c>true</c> display immediately when it has finished loading.</param>
    public void LoadBanner(AdSize AdType, int XPos, int YPos, bool DisplayImmediately = false)
    {
        if (!EnableAdMob)
        {
            return;
        }

        // Get the name of the current method
        string MethodName = "LoadBanner";

        DebugLog(MethodName + " called for " + AdType + " - DisplayImmediately: " + DisplayImmediately);

        // Update the state items (Values used to determine if the action in this method should be ran)
        ActionState[MethodName].UpdateItems(new List <bool>()
        {
            !BannerIsLoading, !BannerIsReady, !BannerIsVisible
        });

        // Check if we can perform the action for the current method
        if (CanPerformAction(MethodName, ActionState[MethodName].items))
        {
            // Mark the banner as loading
            BannerIsLoading = true;

            // If we want to display the banner as soon as it's loaded then mark the wanted visible variable as true
            BannerWantedVisible = DisplayImmediately;

            switch (BannerAdType)
            {
            case BannerAdTypeList.Default:
                // Load a banner ad marking it as hidden, this script will handle showing the banner
                AdMobBanner = new BannerView(BannerId, AdType, XPos, YPos);

                // Register the banner ad events
                AdMobBanner.OnAdLoaded             += OnReceiveBanner;
                AdMobBanner.OnAdFailedToLoad       += OnFailReceiveBanner;
                AdMobBanner.OnAdOpening            += OnBannerVisible;
                AdMobBanner.OnAdClosed             += OnBannerHidden;
                AdMobBanner.OnAdLeavingApplication += OnBannerClick;

                AdMobBanner.LoadAd(GenerateAdRequest());
                break;

            case BannerAdTypeList.NativeExpressAds:
                // Load a native banner ad marking it as hidden, this script will handle showing the banner
                AdMobNativeBanner = new NativeExpressAdView(BannerId, AdType, XPos, YPos);

                // Register the native banner ad events
                AdMobNativeBanner.OnAdLoaded             += OnReceiveBanner;
                AdMobNativeBanner.OnAdFailedToLoad       += OnFailReceiveBanner;
                AdMobNativeBanner.OnAdOpening            += OnBannerVisible;
                AdMobNativeBanner.OnAdClosed             += OnBannerHidden;
                AdMobNativeBanner.OnAdLeavingApplication += OnBannerClick;

                AdMobNativeBanner.LoadAd(GenerateAdRequest());
                break;
            }

            BannerInMemoryType   = AdType;
            BannerInMemoryLayout = AdPosition.TopLeft;
        }
        else
        {
            // Google Mobile Ads does not currently support banner repositioning so we are forced to treat new positions as changing to a new banner type (destroying and reloading the advert)
            DestroyBanner();
            LoadBanner(AdType, XPos, YPos, DisplayImmediately);
        }
    }
Beispiel #10
0
    void Start()
    {
        switch (PlayerPrefs.GetString("Mode"))
        {
        case "Easy":
            modeNumber = 0;
            tNumber    = 32;
            break;

        case "Medium":
            modeNumber = 1;
            tNumber    = 24;
            break;

        case "Hard":
            modeNumber = 2;
            tNumber    = 16;
            break;

        case "Insane":
            modeNumber = 3;
            tNumber    = 8;
            transform.GetChild(0).GetChild(4).GetChild(6).GetComponent <Text> ().text = "  end";
            break;
        }

        audioC.transform.GetChild(modeNumber).gameObject.SetActive(true);
        audioC.transform.GetChild(modeNumber).GetComponent <AudioSource> ().Play();

        if (PlayerPrefs.GetString("Sound") == "on")
        {
            pauseScreen.transform.GetChild(5).GetChild(1).gameObject.SetActive(true);
            pauseScreen.transform.GetChild(5).GetChild(2).gameObject.SetActive(false);
        }
        else
        {
            pauseScreen.transform.GetChild(5).GetChild(1).gameObject.SetActive(false);
            pauseScreen.transform.GetChild(5).GetChild(2).gameObject.SetActive(true);
        }

        if (PlayerPrefs.GetString("Music") == "on")
        {
            pauseScreen.transform.GetChild(4).GetChild(1).gameObject.SetActive(true);
            pauseScreen.transform.GetChild(4).GetChild(2).gameObject.SetActive(false);
            Firebase.Analytics.FirebaseAnalytics.LogEvent("start_game_with_music");
        }
        else
        {
            pauseScreen.transform.GetChild(4).GetChild(1).gameObject.SetActive(false);
            pauseScreen.transform.GetChild(4).GetChild(2).gameObject.SetActive(true);
            audioC.transform.GetChild(modeNumber).GetComponent <AudioSource> ().Pause();
            Firebase.Analytics.FirebaseAnalytics.LogEvent("start_game_without_music");
        }


        fieldControlls = field.GetComponent <FieldControlls> ();



        PlayerPrefs.SetInt("Attempts" + PlayerPrefs.GetString("Mode"), PlayerPrefs.GetInt("Attempts" + PlayerPrefs.GetString("Mode")) + 1);

        timer.transform.GetChild(0).GetComponent <Text>().text = tNumber.ToString();
        scoreText.text  = "0";
        recordText.text = PlayerPrefs.GetInt("BestScore" + PlayerPrefs.GetString("Mode")).ToString();

        progressColor.GetComponent <Image> ().color = modeColors [modeNumber];

        transform.GetChild(0).GetChild(0).GetChild(1).GetComponent <Text> ().color = modeColors [modeNumber];
        transform.GetChild(0).GetChild(1).GetChild(1).GetComponent <Text> ().color = modeColors [modeNumber];
        transform.GetChild(0).GetChild(1).GetChild(2).GetComponent <Text> ().color = modeColors [modeNumber];
        transform.GetChild(0).GetChild(2).GetChild(1).GetComponent <Text> ().color = modeColors [modeNumber];
        transform.GetChild(0).GetChild(3).GetChild(1).GetComponent <Text> ().color = modeColors [modeNumber];

        transform.GetChild(1).GetComponent <Image> ().color = modeColors [modeNumber];
        transform.GetChild(2).GetComponent <Image> ().color = modeColors [modeNumber];

        transform.GetChild(3).GetChild(0).GetChild(0).GetComponent <Text> ().color = modeColors [modeNumber];

        loseScreen.transform.GetChild(2).GetComponent <Text> ().color = modeColors [modeNumber] - new Color(0, 0, 0, 1);
        worldRecordText.color = modeColors [modeNumber] - new Color(0, 0, 0, 1);

        barLength = fieldControlls.GetFullScore();

        timer.transform.GetChild(0).GetComponent <Text>().color = modeColors [modeNumber];
        for (int i = 1; i < 9; i++)
        {
            timer.transform.GetChild(i).GetComponent <Image> ().color = modeColors [modeNumber];
        }

        StartCoroutine(StartCellsAnimations());

        if (UnityEngine.Random.Range(0, 2) == 0)
        {
            banner = new BannerView(adBannerId, AdSize.SmartBanner, AdPosition.Bottom);
            banner.LoadAd(new AdRequest.Builder().Build());
        }
        else
        {
            banner2 = new NativeExpressAdView(adBanner2Id, AdSize.SmartBanner, AdPosition.Bottom);
            banner2.LoadAd(new AdRequest.Builder().Build());
        }

        inter = new InterstitialAd(adInterId);
        inter.LoadAd(new AdRequest.Builder().Build());

        /*inter2 = RewardBasedVideoAd.Instance;
         * inter2.LoadAd (new AdRequest.Builder ().Build (), adInter2Id);
         */

        Firebase.Analytics.FirebaseAnalytics.LogEvent("start_game_" + PlayerPrefs.GetString("Mode"));
        Firebase.Analytics.FirebaseAnalytics.LogEvent("start_game_all_modes");
    }