Ejemplo n.º 1
0
 /// <summary>
 /// Show Admob rewarded video
 /// </summary>
 /// <param name="CompleteMethod">callback called when user closes the rewarded video -> if true video was not skipped</param>
 public void ShowRewardVideo(UnityAction <bool> CompleteMethod)
 {
     if (IsRewardVideoAvailable())
     {
         OnCompleteMethod             = CompleteMethod;
         triggerCompleteMethod        = true;
         triggerRewardedVideoCallback = true;
         rewardedVideo.Show();
     }
 }
Ejemplo n.º 2
0
 public void Show(Action <bool> onAdResult)
 {
     Debug.Log("[ " + this.rewardedAdId + " ] Called Show()");
     this.onAdResult = onAdResult;
     if (rewardedAd.IsLoaded())
     {
         rewardedAd.Show();
     }
     else
     {
         LoadAd(() => rewardedAd.Show());
     }
 }
Ejemplo n.º 3
0
    // Start is called before the first frame update
    void Start()
    {
        MobileAds.Initialize(initStatus => { });

        //this.RequestBanner();
        //this.RequestInterstitialAd();
        this.RequestRewardedAd();

        rewardedAd.OnAdLoaded         += handleOnAdLoaded;
        rewardedAd.OnAdClosed         += handleOnAdClosed;
        rewardedAd.OnAdFailedToLoad   += handleOnAdFailedToLoad;
        rewardedAd.OnAdFailedToShow   += handleOnAdFailedToShow;
        rewardedAd.OnAdOpening        += handleOnAdOpening;
        rewardedAd.OnUserEarnedReward += handleOnUserEarnedReward;

        if (rewardedAd.IsLoaded())
        {
            rewardedAd.Show();
        }

        else
        {
            Debug.Log("Rewarded ad not loaded");
        }
    }
Ejemplo n.º 4
0
    public void ShowRewardedAd()
    {
        ScoreManager.instance.Loading(true);


        StartCoroutine(CheckInternetConnection((isConnected) => {
            if (isConnected && rewardedAd != null && rewardedAd.IsLoaded())
            {
                Debug.Log("Showing Ad");
                ScoreManager.instance.Loading(false);
                rewardedAd.Show();
                rewardedAd = null;
                SetupRewardedAds();
            }
            else
            {
                ScoreManager.instance.Loading(false);
                if (MainGameManager.instance != null)
                {
                    MainGameManager.instance.UnableToLoadVideo();
                }
                rewardedAd = null;
                SetupRewardedAds();
            }
        }));
    }
Ejemplo n.º 5
0
 public void PlayAD()
 {
     //广告已经准备就绪,直接播放
     //如果因为延迟没有准备就绪,重新加载
     if (rewardedAd != null)
     {
         if (rewardedAd.IsLoaded())
         {
             rewardedAd.Show();
             autoplay = false;
         }
     }
     else
     {
         if (autoplay == false)
         {
             CreateAndLoadAD();
             autoplay = true;
             Debug.Log("广告对象没有生成");
         }
         else
         {
             Debug.Log("广告加载多次失败");
         }
     }
 }
Ejemplo n.º 6
0
 private void HandleRewardedAdLoaded(object sender, EventArgs args)
 {
     if (_rewardedAd.IsLoaded())
     {
         _rewardedAd.Show();
     }
 }
 public void ShowTimeUpRewardAds(string adsId)
 {
     if (_timeUpRewardAd.IsLoaded())
     {
         _timeUpRewardAd.Show();
     }
 }
 public void ShowDieRewardAds(string adsId)
 {
     if (_dieRewardAd.IsLoaded())
     {
         _dieRewardAd.Show();
     }
 }
        public void ShowRewardedVideo()
        {
            if (!CrossAdMob.Current.IsEnabled)
            {
                return;
            }

            var adUnit = AdUnitId_RewardedVideo;

            if (IsInTestMode || String.IsNullOrWhiteSpace(adUnit))
            {
                adUnit = GoogleSamplesAdUnitIds.AndroidSampleAdUnitId_RewardedVideo;
            }

            if (_rewardedVideoAds != null && _rewardedVideoAds.IsLoaded)
            {
                var rewardedCallback = new AdMobRewardedCallback(adUnit);
                rewardedCallback.AdOpened         += RewardedCallback_AdOpened;
                rewardedCallback.AdClosed         += RewardedCallback_AdClosed;
                rewardedCallback.AdFailedToShow   += RewardedCallback_AdFailedToShow;
                rewardedCallback.UserEarnedReward += RewardedCallback_UserEarnedReward;

                _rewardedVideoAds.Show(Xamarin.Essentials.Platform.CurrentActivity, rewardedCallback);
            }
            else
            {
                Console.WriteLine("Rewarded Video not loaded");
            }
        }
Ejemplo n.º 10
0
 private void Update()
 {
     if (interactableButtons == false)
     {
         buttonResurrect.interactable      = false;
         buttonResurrectClose.interactable = false;
     }
     if (Input.GetKeyDown(KeyCode.Escape) && openAds.activeSelf == true)
     {
         rewardedAd.OnAdLoaded -= HandleRewardedAdLoaded;
         DontWaitAds();
     }
     else if (Input.GetKeyDown(KeyCode.Escape) && openAds.activeSelf == false)
     {
         ButtonResurrectClose();
     }
     if (showReward)
     {
         if (rewardedAd.IsLoaded())
         {
             rewardedAd.Show();
             rewardedAd                     = new RewardedAd(inGameRewarded);
             rewardedAd.OnAdClosed         += HandleRewardedAdClosed;
             rewardedAd.OnUserEarnedReward += HandleUserEarnedReward;
             rewardedAd.OnAdLoaded         += HandleRewardedAdLoaded;
             request = null;
             request = new AdRequest.Builder().Build();
             rewardedAd.LoadAd(request);
             showReward = false;
         }
     }
 }
Ejemplo n.º 11
0
 private void Update()
 {
     if (game.ads)
     {
         if (Input.GetKeyDown(KeyCode.Escape))
         {
             rewardedAd.OnAdLoaded -= HandleRewardedAdLoaded;
             DontWaitAds();
         }
         if (showReward)
         {
             if (rewardedAd.IsLoaded())
             {
                 rewardedAd.Show();
                 rewardedAd                     = new RewardedAd(inGameRewarded);
                 rewardedAd.OnAdClosed         += HandleRewardedAdClosed;
                 rewardedAd.OnUserEarnedReward += HandleUserEarnedReward;
                 rewardedAd.OnAdLoaded         += HandleRewardedAdLoaded;
                 request = null;
                 request = new AdRequest.Builder().Build();
                 rewardedAd.LoadAd(request);
                 showReward = false;
             }
         }
     }
 }
Ejemplo n.º 12
0
    IEnumerator WaitForRecovery()
    {
        yield return(new WaitUntil(() => AdReady != null));

        if (AdReady == true)
        {
            rewardedAd.Show();
            yield return(new WaitUntil(() => RecoveryEarned != null));

            if (RecoveryEarned == true)
            {
                DrivingPlayManager.Current.PlayerCarManager.Recover();
            }
            else
            {
                Main.Instance.PopupMsg("You must watch the whole advert");
            }
        }
        else
        {
            Main.Instance.PopupMsg("Sorry no Advert available");
        }

        LoadAd();       //Load the next ad
        yield return(0);
    }
Ejemplo n.º 13
0
 public void ShowRewardAd()
 {
     if (AdReward.IsLoaded())
     {
         AdReward.Show();
     }
 }
Ejemplo n.º 14
0
 //attach to a button that plays ad if ready
 public void ShowRewardedAd()
 {
     if (rewardedAd.IsLoaded())
     {
         rewardedAd.Show();
     }
 }
Ejemplo n.º 15
0
 public void DisplayRewardVideo()
 {
     if (rewardAd.IsLoaded())
     {
         rewardAd.Show();
     }
 }
Ejemplo n.º 16
0
        private void DisplayAd()
        {
            switch (activeAdType)
            {
            case AdsConfiguration.AdType.Banner:
                bannerView[bannerView.Count - 1].view.Show();
                break;

            case AdsConfiguration.AdType.Fullscreen:
                if (this.interstitialAd.IsLoaded())
                {
                    this.interstitialAd.Show();
                }
                else
                {
                    Debug.LogWarning("Fullscreen ad is not loaded");
                }
                break;

            case AdsConfiguration.AdType.Rewarded:
                rewardedAd.Show();
                break;

            case AdsConfiguration.AdType.Native:
                Debug.Log("Native ad has not been implemented yet");
                break;
            }
        }
Ejemplo n.º 17
0
        private void ShowInterstitial()
        {
            //Debug.Log("current interstitial = " + currentInterstitial);
            switch (currentInterstitial)
            {
            case InterstitialType.Default:
                if (interstitialReg.IsLoaded())
                {
                    interstitialReg.Show();
                }
                break;

            case InterstitialType.Video:
                if (interstitialVideo.IsLoaded())
                {
                    interstitialVideo.Show();
                }
                break;

            case InterstitialType.Reward:
                if (interstitialReward.IsLoaded())
                {
                    interstitialReward.Show();
                }
                break;
            }
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Method of show ad as revenue video
 /// </summary>
 public void ShowRevenueVideo()
 {
     if (rewardedVideoAd != null)
     {
         rewardedVideoAd.Show();
     }
 }
Ejemplo n.º 19
0
        public void TryPlayRewardedAd()
        {
            if (CheckInternetConnection())
            {
                return;
            }

            string adId;

            var isDebugBuild = Debug.isDebugBuild;

            if (isDebugBuild)
            {
                adId = Constants.AdMob.TestAd;
            }
            else
            {
                adId = Constants.AdMob.Reward;
            }

            RewardedAd rewardedAd = new RewardedAd(adId);

            var adRequest = new AdRequest.Builder().Build();

            rewardedAd.LoadAd(adRequest);

            rewardedAd.Show();
            rewardedAd.OnAdClosed += OnAdClosed;
        }
Ejemplo n.º 20
0
 public static void DisplayRewardAD()
 {
     if (reward.IsLoaded() && PlayerPrefs.GetInt("Ads", 0) == 0)
     {
         reward.Show();
     }
 }
Ejemplo n.º 21
0
 public void ShowContinueAd()
 {
     if (IsContinueAdLoaded())
     {
         continueAd.Show();
     }
 }
Ejemplo n.º 22
0
 public void Show()
 {
     if (_rewardedAd.IsLoaded())
     {
         _rewardedAd.Show();
     }
 }
Ejemplo n.º 23
0
    public void ShowRewardedAd(RewardedAdType type)
    {
        switch (type)
        {
        case RewardedAdType.EXTRA_ATTEMPT:
            if (extraAttempt == null)
            {
                break;
            }

            if (extraAttempt.IsLoaded())
            {
                extraAttempt.Show();
            }
            break;

        case RewardedAdType.TIMED_REWARD:
            if (timedReward == null)
            {
                break;
            }

            if (timedReward.IsLoaded())
            {
                timedReward.Show();
            }
            break;
        }
    }
Ejemplo n.º 24
0
 // Показываем рекламу
 public void ShowRewardedAd()
 {
     // Вознаграждение
     if (rewardedAd.IsLoaded())
     {
         rewardedAd.Show();
     }
 }
Ejemplo n.º 25
0
    public void ShowAd(string forWhat)
    {
        AdsForWhat = forWhat;
        loadingAd.SetActive(true);


        if (rewardedAd.IsLoaded())
        {
            rewardedAd.Show();
            loadingAd.SetActive(false);
        }

        else
        {
            Retry();
        }
    }
Ejemplo n.º 26
0
 public void Display_Reward()
 {
     if (rewardedAd.IsLoaded())
     {
         rewardedAd.Show();
         Debug.Log("已展示激励广告");
     }
 }
Ejemplo n.º 27
0
 public void ShowAd()
 {
     if (rewardedAd.IsLoaded())
     {
         rewardedAd.Show();
         adNotReady.SetActive(true);
     }
 }
Ejemplo n.º 28
0
 private IEnumerator ShowRewardAd()
 {
     while (!rewardAd.IsLoaded())
     {
         yield return(null);
     }
     rewardAd.Show();
 }
 public IEnumerator ShowRewardedAd()
 {
     if (videoAd.IsLoaded())
     {
         videoAd.Show();
     }
     yield return(null);
 }
Ejemplo n.º 30
0
        /// <summary>
        /// ロックボタン押下
        /// </summary>
        public void OnClick_RewardButton(RewardButton rewardButton)
        {
            _rewardAction = _rewardActionDic[rewardButton];

            // 広告を表示して受取る報酬についての説明処理
            if (_rewardAnnounce)
            {
                if (_rewardedAd.IsLoaded())
                {
                    _rewardedAd.Show();
                }
            }
            else
            {
                rewardMessagebox.SetActive(true);
            }
        }