Esempio n. 1
0
        public IEnumerator WaitAndDisplayRewardedAd()
        {
            yield return(new WaitUntil(() => Monetization.IsReady(placementID_Rewarded)));

            ShowAdPlacementContent adContent = Monetization.GetPlacementContent(placementID_Rewarded) as ShowAdPlacementContent;

            adContent.gamerSid = "[CALLBACK SERVER ID HERE]";

            ShowAdCallbacks callbackOptions = new ShowAdCallbacks();

            callbackOptions.finishCallback += RewardCallback;

            if (adContent != null)
            {
                adContent.Show(callbackOptions);
            }
            else
            {
                Debug.LogWarning("Placement content returned null.");
            }
            customEventParams.Add("ar_content", false);
            AnalyticsResult eventResult = AnalyticsEvent.adStart(true, null, placementID_Rewarded, customEventParams);

            Debug.LogFormat("Event result", eventResult);
        }
Esempio n. 2
0
    public void ShowAd()
    {
        if (PlayerPrefs.HasKey("AdCount"))
        {
            if (PlayerPrefs.GetInt("AdCount") == 2)
            {
                if (Monetization.IsReady(video_ad))
                {
                    ShowAdPlacementContent ad = null;
                    ad = Monetization.GetPlacementContent(video_ad) as ShowAdPlacementContent;

                    if (ad != null)
                    {
                        ad.Show();
                    }
                }
                PlayerPrefs.SetInt("AdCount", 0);
            }
            else
            {
                PlayerPrefs.SetInt("AdCount", PlayerPrefs.GetInt("AdCount") + 1);
            }
        }
        else
        {
            PlayerPrefs.SetInt("AdCount", 0);
        }
    }
Esempio n. 3
0
    public void ShowAd()
    {
        //Get Content for a placement
        PlacementContent placementContent = Monetization.GetPlacementContent(placementName);

        //Convert to ShowAdPlacementContent to show the ad
        //This works for most ad types (Video, Playable, Display, Promo, AR, etc.)
        //IAP Promo does require additional configuration. (See: PromoExample)
        ShowAdPlacementContent showAd = (ShowAdPlacementContent)placementContent;

        //We can check if this is a rewarded placement from the placement content
        if (showAd.rewarded == true)
        {
            ShowAdCallbacks callbacks = new ShowAdCallbacks
            {
                finishCallback = HandleReward
            };
            Debug.Log("Showing Rewarded Ad - Placement: " + placementContent.placementId);
            showAd.Show(callbacks);
        }
        else
        {
            Debug.Log("Showing Non-rewarded Ad - Placement: " + placementContent.placementId);
            showAd.Show();
        }
    }
Esempio n. 4
0
    IEnumerator WaitForAd(bool rewarded = false)
    {
        string selectPlacementID = rewarded? placementId_Rewarded: placementId_No;

        while (!Monetization.IsReady(selectPlacementID))
        {
            yield return(null);
        }

        ShowAdPlacementContent ad = null;

        ad = Monetization.GetPlacementContent(selectPlacementID) as ShowAdPlacementContent;

        if (ad != null)
        {
            if (rewarded)
            {
                ad.Show(AdFinished);
            }
            else
            {
                ad.Show(AdFinished_No);
            }
        }
    }
Esempio n. 5
0
 private async void WaitForAds()
 {
     SetBtGetMoreInteractable(false);
     while (true)
     {
         //if (this.rewardedAd.IsLoaded() || Monetization.IsReady(placementId)) break;
         if (Monetization.IsReady(placementId))
         {
             break;
         }
         await Task.Delay(100);
     }
     //if (this.rewardedAd.IsLoaded())
     //{
     //    SetBtGetMoreInteractable(true);
     //}
     if (Monetization.IsReady(placementId))
     {
         ad = Monetization.GetPlacementContent(placementId) as ShowAdPlacementContent;
         if (ad != null)
         {
             SetBtGetMoreInteractable(true);
         }
     }
 }
Esempio n. 6
0
    private IEnumerator ShowAdBuffered()
    {
        hasAdStarted = false;
        float timer = 0;

        LoadingGUI.SetActive(true);
        while (!hasAdStarted && timer < 10)
        {
            timer += Time.deltaTime;
            if (Monetization.IsReady(reward_ad))
            {
                ad = null;
                ad = Monetization.GetPlacementContent(reward_ad) as ShowAdPlacementContent;

                if (ad != null)
                {
                    rewardedForCurrentAd = false;
                    ad.Show();
                    isAdShowing = true;
                    Debug.Log(ad.placementId);
                    hasAdStarted = true;
                }
            }
            yield return(null);
        }
        LoadingGUI.SetActive(false);
    }
Esempio n. 7
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetButton("Fire1"))
     {
         if (Monetization.IsReady("video"))
         {
             ShowAdPlacementContent ad = null;
             ad = Monetization.GetPlacementContent("video") as ShowAdPlacementContent;
             if (ad != null)
             {
                 ad.Show();
             }
         }
     }
     if (Input.GetKeyDown(KeyCode.S))
     {
         if (Monetization.IsReady("rewardedVideo"))
         {
             ShowAdPlacementContent ad = null;
             ad = Monetization.GetPlacementContent("rewardedVideo") as ShowAdPlacementContent;
             if (ad != null)
             {
                 ad.Show();
             }
         }
     }
 }
Esempio n. 8
0
    IEnumerator WaitForAd(bool reward = false)
    {
        string placementId = reward? placementId_rewardedVideo : placementId_video;

        while (!Monetization.IsReady(placementId))
        {
            yield return(null);
        }

        ShowAdPlacementContent ad = null;

        ad = Monetization.GetPlacementContent(placementId) as ShowAdPlacementContent;

        if (ad != null)
        {
            if (reward)
            {
                ad.Show(AdFinished);
            }
            else
            {
                ad.Show();
            }
        }
    }
Esempio n. 9
0
    public void ShowAd()
    {
        ShowAdCallbacks options = new ShowAdCallbacks();

        options.finishCallback = HandleShowResult;
        ShowAdPlacementContent ad = Monetization.GetPlacementContent("rewardedVideo") as ShowAdPlacementContent;

        ad.Show(options);
    }
Esempio n. 10
0
	public void showInterstitialAd()
	{
		try
		{
			currentAdDisplayTime = Time.time;
			float num = currentAdDisplayTime - Global.lastAdDisplayTime;
			if (interstitial != null && interstitial.IsLoaded())
			{
				interstitial.Show();
				Global.lastAdDisplayTime = currentAdDisplayTime;
			}
			else if (isLoaded)
			{
				interstitialAd.Show();
				Global.lastAdDisplayTime = currentAdDisplayTime;
			}
			else if (num > Global.backFillAdGap && Monetization.IsReady(video_ad))
			{
				ShowAdPlacementContent showAdPlacementContent = null;
				(Monetization.GetPlacementContent(video_ad) as ShowAdPlacementContent)?.Show(HandleShowResult);
			}
			else if (num > Global.backFillAdGap && IronSource.Agent.isInterstitialReady())
			{
				ShowIronAd();
				Global.lastAdDisplayTime = currentAdDisplayTime;
			}
			else if (num > Global.backFillAdGap && interstitial2 != null && interstitial2.IsLoaded())
			{
				interstitial2.Show();
				Global.lastAdDisplayTime = currentAdDisplayTime;
			}
			else if (Monetization.IsReady(rewarded_Video) || rewardLoaded)
			{
				Global.isRewardVidAvail = true;
				gm.retry.SetActive(value: true);
				gm.menu.SetActive(value: true);
				if (gm.gameFailed.activeSelf)
				{
					gm.failMenu.SetActive(value: true);
					gm.failRetry.SetActive(value: true);
				}
			}
			else
			{
				gm.retry.SetActive(value: true);
				gm.menu.SetActive(value: true);
				if (gm.gameFailed.activeSelf)
				{
					gm.failMenu.SetActive(value: true);
					gm.failRetry.SetActive(value: true);
				}
			}
		}
		catch (Exception)
		{
		}
	}
Esempio n. 11
0
    void ShowAd()
    {
        ShowAdCallbacks options = new ShowAdCallbacks();

        options.finishCallback = HandleShowResult;
        ShowAdPlacementContent ad = Monetization.GetPlacementContent(placementId) as ShowAdPlacementContent;

        ad.Show(options);
    }
Esempio n. 12
0
 // Start is called before the first frame update
 public void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Player")
     {
         if (Monetization.isInitialized)
         {
             PlayerPrefs.SetInt("Die", PlayerPrefs.GetInt("Die") + 1);
         }
         if (mod == 1)
         {
             SceneManager.LoadScene("Balance");
             Time.timeScale = 1;
             if (time1.sec > 40)
             {
                 if (Monetization.IsReady("video"))
                 {
                     ShowAdPlacementContent ad = Monetization.GetPlacementContent("video") as ShowAdPlacementContent;
                     if (ad != null)
                     {
                         ad.Show();
                     }
                 }
             }
         }
         if (mod == 2)
         {
             SceneManager.LoadScene("BalanceMod");
             Time.timeScale = 1;
             if (wood.BalanceValueNow > 20)
             {
                 if (Monetization.IsReady("video"))
                 {
                     ShowAdPlacementContent ad = Monetization.GetPlacementContent("video") as ShowAdPlacementContent;
                     if (ad != null)
                     {
                         ad.Show();
                     }
                 }
             }
         }
         if (PlayerPrefs.GetInt("Die") >= 10)
         {
             if (Monetization.IsReady("video"))
             {
                 ShowAdCallbacks options = new ShowAdCallbacks();
                 options.finishCallback = HandleShowResult;
                 ShowAdPlacementContent ad = Monetization.GetPlacementContent("video") as ShowAdPlacementContent;
                 ad.Show(options);
             }
         }
     }
     else
     {
         Destroy(collision.gameObject);
     }
 }
Esempio n. 13
0
    public void ShowPromo()
    {
        if (Monetization.IsReady(placementName) == false)
        {
            Debug.Log("Placement Not Ready: " + placementName);
            return;
        }

        //Get Content for a placement
        PlacementContent placementContent = Monetization.GetPlacementContent(placementName);

        if (placementContent == null)
        {
            Debug.LogError("Placement Content Empty for Placement ID: " + placementContent.placementId);
            return;
        }

        //Convert to ShowAdPlacementContent to show the ad
        //This works for most ad types (Video, Playable, Display, Promo, AR, etc.)
        //IAP Promo requires that the Purcahsing Adapter is set, otherwise placement will never be Ready
        ShowAdPlacementContent showAd = (ShowAdPlacementContent)placementContent;

        if (showAd == null)
        {
            Debug.LogError("Show Ad Placement Content Empty for Placement ID: " + showAd.placementId);
            return;
        }


        //Since this is a Personalized Placement, it can be an Ad or an IAP Promo. And we can check which if needed.
        if (showAd.GetType() == typeof(ShowAdPlacementContent))
        {
            Debug.Log("Showing Ad - Placement: " + showAd.placementId);
        }

        if (showAd.GetType() == typeof(PromoAdPlacementContent))
        {
            Debug.Log("Showing Promo - Placement: " + showAd.placementId);
        }

        //We can check if this is a rewarded placement from the placement content
        if (showAd.rewarded == true)
        {
            ShowAdCallbacks callbacks = new ShowAdCallbacks
            {
                finishCallback = HandleReward
            };
            Debug.Log("Showing Rewarded Ad - Placement: " + placementContent.placementId);
            showAd.Show(callbacks);
        }
        else
        {
            Debug.Log("Showing Non-rewarded Ad - Placement: " + placementContent.placementId);
            showAd.Show();
        }
    }
Esempio n. 14
0
    public void ShowAd()
    {
        // Loading.SetActive(true);
        ShowAdCallbacks options = new ShowAdCallbacks();

        options.finishCallback = HandleShowResult;
        ShowAdPlacementContent ad = Monetization.GetPlacementContent(placementId) as ShowAdPlacementContent;

        ad.Show(options);
    }
Esempio n. 15
0
    private void ShowAd()
    {
        SoundManager.Instance.MenuTouch();
        ShowAdCallbacks options = new ShowAdCallbacks();

        options.finishCallback = HandleShowResult;
        ShowAdPlacementContent ad = Monetization.GetPlacementContent(placementId) as ShowAdPlacementContent;

        ad.Show(options);
    }
Esempio n. 16
0
    void ShowAd()
    {
        ShowAdCallbacks options = new ShowAdCallbacks();

        options.finishCallback = HandleShowResult;
        ShowAdPlacementContent ad = Monetization.GetPlacementContent(placementId) as ShowAdPlacementContent;

        secLife.GetComponent <Animator>().enabled = false;
        ad.Show(options);
    }
Esempio n. 17
0
    public void ShowEnterActionPhaseFromMainMenuAd()
    {
        ShowAdCallbacks options = new ShowAdCallbacks();

        options.finishCallback = HandleLoadGame;

        ShowAdPlacementContent ad = Monetization.GetPlacementContent(enterActionPhaseFromMainMenuAd) as ShowAdPlacementContent;

        ad.Show(options);
    }
Esempio n. 18
0
    public void ShowEnterActionPhaseAfterRestartAd()
    {
        ShowAdCallbacks options = new ShowAdCallbacks();

        options.finishCallback = HandleLoadMenu;

        ShowAdPlacementContent ad = Monetization.GetPlacementContent(enterActionPhaseAfterRestartAd) as ShowAdPlacementContent;

        ad.Show(options);
    }
Esempio n. 19
0
    public override void ShowAd(string placement)
    {
        ShowAdCallbacks options = new ShowAdCallbacks
        {
            finishCallback = HandleShowResult
        };
        ShowAdPlacementContent ad = Monetization.GetPlacementContent(placement) as ShowAdPlacementContent;

        ad.Show(options);
    }
Esempio n. 20
0
    /* public void rewardedvideoclick(){
     *  if (Monetization.IsReady(rewarded_ad)){
     *      ShowAdPlacementContent ad = null;
     *      ad= Monetization.GetPlacementContent(rewarded_ad) as ShowAdPlacementContent;
     *
     *      if(ad != null){
     *          ad.Show();
     *      }
     *  }
     * }
     *
     * void Update(){
     *
     *  if(Input.GetKeyDown(KeyCode.R))
     *  {
     *    if (Monetization.IsReady(rewarded_ad))
     *    {
     *      ShowAdPlacementContent ad = null;
     *      ad= Monetization.GetPlacementContent(rewarded_ad) as ShowAdPlacementContent;
     *
     *      if(ad != null)
     *          ad.Show();
     *    }
     *  }
     *  }*/



    public void ShowAdrewarded()
    {
        if (networkon == true)
        {
            ShowAdCallbacks options = new ShowAdCallbacks();
            options.finishCallback = HandleShowResult;
            ShowAdPlacementContent ad = Monetization.GetPlacementContent(rewarded_ad) as ShowAdPlacementContent;
            ad.Show(options);
        }
    }
Esempio n. 21
0
    private void ShowAd()
    {
        // 广告回调函数
        ShowAdCallbacks options = new ShowAdCallbacks();

        options.finishCallback = HandleResult;
        // 广告对象
        ShowAdPlacementContent ad = Monetization.GetPlacementContent(placementId) as ShowAdPlacementContent;

        ad.Show(options);
    }
Esempio n. 22
0
File: Ads.cs Progetto: gagip/GameDev
    // 광고를 실행하는 함수
    public void ShowAd()
    {
        ShowAdCallbacks options = new ShowAdCallbacks();

        options.finishCallback = HandleShowResult;

        ShowAdPlacementContent ad = Monetization.GetPlacementContent(placementld)
                                    as ShowAdPlacementContent; // placementId 는 광고에 대한 설정이 담겨있다. 스킵을 허용하는지 안하는지

        ad.Show(options);
    }
Esempio n. 23
0
 public void PlayVideo()
 {
     if (Monetization.IsReady(video_ad))
     {
         ShowAdPlacementContent ad = Monetization.GetPlacementContent(video_ad) as ShowAdPlacementContent;
         if (ad != null)
         {
             ad.Show();
         }
     }
 }
Esempio n. 24
0
 //rewardedVideo
 public void ShowAds()
 {
     if (Monetization.IsReady("rewardedVideo"))
     {
         Time.timeScale = 0;
         ShowAdCallbacks options = new ShowAdCallbacks();
         options.finishCallback = HandleShowResult;
         ShowAdPlacementContent ad = Monetization.GetPlacementContent("rewardedVideo") as ShowAdPlacementContent;
         ad.Show(options);
     }
 }
Esempio n. 25
0
    public void ShowAd()
    {
        if (!Monetization.IsReady(placementId))
        {
            return;
        }
        ShowAdPlacementContent pc =
            (ShowAdPlacementContent)Monetization.GetPlacementContent(placementId);

        pc.Show(_showAdCallbacks);
    }
Esempio n. 26
0
 public void PlayRewardedVideo()
 {
     if (Monetization.IsReady(rewardedVideo_Ad))
     {
         ShowAdPlacementContent ad = Monetization.GetPlacementContent(rewardedVideo_Ad) as ShowAdPlacementContent;
         if (ad != null)
         {
             ad.Show();
         }
     }
 }
Esempio n. 27
0
    public void ShowMoreBallsReviveAd()
    {
        ShowAdCallbacks options = new ShowAdCallbacks();

        options.finishCallback = HandleMoreBalls;
        ShowAdPlacementContent ad = Monetization.GetPlacementContent(moreBallsAd) as ShowAdPlacementContent;

        ad.Show(options);

        AnalyticsController.Instance.LogIncentivizedAdWatchedEvent("More Balls AD");
    }
    /*    void Update(){
     *
     *    if(Input.GetKeyDown(KeyCode.V))
     *    {
     *      if (Monetization.IsReady(interstitial_ad))
     *      {
     *        ShowAdPlacementContent ad = null;
     *        ad= Monetization.GetPlacementContent(interstitial_ad) as ShowAdPlacementContent;
     *
     *        if(ad != null)
     *            ad.Show();
     *      }
     *    }
     *    }*/

    public void showuinterstitialad()
    {
        ShowAdPlacementContent ad = null;

        ad = Monetization.GetPlacementContent(interstitial_ad) as ShowAdPlacementContent;

        if (ad != null)
        {
            ad.Show();
        }
    }
Esempio n. 29
0
    public void PlayAd()
    {
        if (Monetization.IsReady(video_id))
        {
            ShowAdPlacementContent ad = Monetization.GetPlacementContent(video_id) as ShowAdPlacementContent;

            if (ad != null)
            {
                ad.Show(AdFinished);
            }
        }
    }
 public void GoMenu()
 {
     GetComponent <AudioSource>().Play();
     if (Monetization.IsReady("video"))
     {
         ShowAdCallbacks options = new ShowAdCallbacks();
         //options.finishCallback = HandleShowResult;
         ShowAdPlacementContent ad = Monetization.GetPlacementContent("video") as ShowAdPlacementContent;
         ad.Show(options);
     }
     SceneManager.LoadScene("Scenes/SampleScene");
 }