示例#1
0
 public void OnClickedChangeNetwork()
 {
     SelectedAdNetwork++;
     if (SelectedAdNetwork > 5)
     {
         SelectedAdNetwork = 0;
     }
     if (SelectedAdNetwork == 1)
     {
         adPartner = AdsMaster.FindActiveAdProvider(ProviderID.Admob);
     }
     else if (SelectedAdNetwork == 2)
     {
         adPartner = AdsMaster.FindActiveAdProvider(ProviderID.ChartBoost);
     }
     else if (SelectedAdNetwork == 3)
     {
         adPartner = AdsMaster.FindActiveAdProvider(ProviderID.UnityAd);
     }
     else if (SelectedAdNetwork == 4)
     {
         adPartner = AdsMaster.FindActiveAdProvider(ProviderID.Vungle);
     }
     else if (SelectedAdNetwork == 5)
     {
         adPartner = AdsMaster.FindActiveAdProvider(ProviderID.FbAd);
     }
     else
     {
         adPartner = null;
     }
 }
示例#2
0
 public override void ShowInterstitial(string key = null)
 {
     if (IsLoadedInterstitial(key))
     {
         Chartboost.showInterstitial(CBLocation.Default);
         AdsMaster.OnDisplayAd(this, AdType.Interstitial);
     }
 }
示例#3
0
 public override void ShowReward()
 {
     if (IsRewardReady)
     {
         Chartboost.showRewardedVideo(CBLocation.Default);
         AdsMaster.OnDisplayAd(this, AdType.Rewarded);
     }
 }
示例#4
0
        IEnumerator CheckRewardedTimer()
        {
            yield return(checkDelay);

            do
            {
                hasRewarded = AdsMaster.HasReward();
                yield return(checkDelay);
            } while (true);
        }
示例#5
0
 public void Initialize(AdsMaster manager)
 {
     this.manager = manager;
     // Only init if provider is assigned to load any ad.
     if ((IsSupport(AdType.Interstitial) && AdsMaster.IsAllowedInterstitial(ID)) ||
         (IsSupport(AdType.Rewarded) && AdsMaster.IsAllowedReward(ID)) ||
         (IsSupport(AdType.Banner) && AdsMaster.IsAllowedBanner(ID)))
     {
         OnIntialize();
     }
 }
示例#6
0
 public override void ShowInterstitial(string key = null)
 {
     if (IsLoadedInterstitial())
     {
         AdsMaster.OnDisplayAd(this, AdType.Interstitial);
         var options = new ShowOptions {
             resultCallback = HandleShowResultInterstitial
         };
         Advertisement.Show(VideoPlacementId, options);
     }
 }
示例#7
0
 public override void ShowReward()
 {
     if (IsRewardReady)
     {
         var options = new ShowOptions {
             resultCallback = HandleShowResultReward
         };
         AdsMaster.OnDisplayAd(this, AdType.Rewarded);
         Advertisement.Show(RewardedPlacementId, options);
     }
 }
示例#8
0
 void Awake()
 {
     if (!AdsMaster.IsAllowedBanner(this.providerId)) return;
     //CLog.Log(this, "Initializing banners...");
     adUnits = GetAdUnitsFromConfigs();
     loaderDict = new Dictionary<string, Loader>();
     for (int i = 0; i < adUnits.Count; i++)
     {
         var adUnit = adUnits[i];
         InstantiateLoader(adUnit);
     }
 }
 void Init()
 {
     if (!AdsMaster.SupportedAdPlatform)
     {
         return;
     }
     if (!AdsMaster.IsAllowedReward(providerId) || !IsValidConfiguration())
     {
         return;
     }
     resendTime = new WaitForSeconds(AdsMaster.RESEND_FAILED_REQUEST_DELAY);
     OnInitialize();
     SendRequest();
 }
示例#10
0
 public void OnClickedShowInterstitial()
 {
     if (SelectedAdNetwork == 0)
     {
         AdsMaster.ShowInterstitial((result) =>
         {
             CLog.Log("Interstitial result " + result);
         });
     }
     else if (adPartner != null && adPartner.IsSupport(AdType.Interstitial))
     {
         adPartner.ShowInterstitial();
     }
 }
示例#11
0
 public void OnClickedShowRewarded()
 {
     if (SelectedAdNetwork == 0)
     {
         AdsMaster.ShowReward(success => { if (success)
                                           {
                                               coin++;
                                           }
                              });
     }
     else if (adPartner != null && adPartner.IsSupport(AdType.Rewarded))
     {
         adPartner.ShowReward();
     }
 }
示例#12
0
 void HandleClicked()
 {
     if (action == Action.ShowInterstitial)
     {
         AdsMaster.ShowInterstitial(null, key);
     }
     else if (action == Action.ShowBanner)
     {
         AdsMaster.ShowBannerIfLoaded(key);
     }
     else if (action == Action.HideBanner)
     {
         AdsMaster.HideBanner();
     }
 }
示例#13
0
        public AdUnit ShowBanner(string key = null)
        {
            if (!AdsMaster.IsAllowedBanner(this.providerId)) return null;
            Loader loader = FindLoaderByKey(key);

            if (loader != null && loader.IsLoaded)
            {
                // Hiển thị banner mới
                loader.Show();
                return loader.AdUnit;
            }
            else
            {
                return null;
            }
        }
示例#14
0
        public static void Initialize(AdsMasterSetting settings)
        {
            if (instance != null || settings == null)
            {
                return;
            }
            // Tạo game object
            var go = new GameObject("AdsMaster");

            instance = go.AddComponent <AdsMaster>();
            DontDestroyOnLoad(go);
            // Assign settings
            AdsMaster.settings = settings;
            // Load remote config if need
            instance.InitRemoteConfig();
            InitAdNetworks();
#if FBAD
            FbNativeAdManager.Initialize();
#endif
        }
示例#15
0
        private void HandleShowResultReward(ShowResult result)
        {
            switch (result)
            {
            case ShowResult.Finished:
                CLog.Log(this, "The ad was successfully shown.");
                AdsMaster.OnCompletedReward(ProviderID.UnityAd, true);
                break;

            case ShowResult.Skipped:
                CLog.Log(this, "The ad was skipped before reaching the end.");
                AdsMaster.OnCompletedReward(ProviderID.UnityAd, false);
                break;

            case ShowResult.Failed:
                CLog.Err(this, "The ad failed to be shown.");
                AdsMaster.OnCompletedReward(ProviderID.UnityAd, false);
                break;
            }
            AdsMaster.OnDimissAd(AdType.Rewarded);
        }
示例#16
0
        IEnumerator CheckInterstititalTimer()
        {
            foreach (var item in interstitialButtons)
            {
                item.interactable = hasInterstitial;
            }
            yield return(checkDelay);

            do
            {
                var isLoaded = AdsMaster.IsLoadedInterstitial();
                if (isLoaded != hasInterstitial)
                {
                    hasInterstitial = isLoaded;
                    foreach (var item in interstitialButtons)
                    {
                        item.interactable = hasInterstitial;
                    }
                }
                yield return(checkDelay);
            } while (true);
        }
示例#17
0
        protected override void OnIntialize()
        {
            Chartboost.didCacheInterstitial      += didCacheInterstitial;
            Chartboost.didFailToLoadInterstitial += didFailToLoadInterstitial;
            Chartboost.didDismissInterstitial    += didDismissInterstitial;
            Chartboost.didCloseInterstitial      += didCloseInterstitial;

            Chartboost.didCacheRewardedVideo      += didCacheRewardedVideo;
            Chartboost.didFailToLoadRewardedVideo += didFailToLoadRewardedVideo;
            Chartboost.didCloseRewardedVideo      += didCloseRewardedVideo;
            Chartboost.didDismissRewardedVideo    += didDismissRewardedVideo;
            Chartboost.didCompleteRewardedVideo   += didCompleteRewardedVideo;

            if (AdsMaster.IsAllowedReward(ProviderID.ChartBoost))
            {
                StartCoroutine(CacheRewardTask(2f));
            }
            if (AdsMaster.IsAllowedInterstitial(ProviderID.ChartBoost))
            {
                StartCoroutine(CacheInterstitialTask(0f));
            }
        }
示例#18
0
 public void OnClickedBottomBanner()
 {
     AdsMaster.ShowBannerIfLoaded("bottom banner");
 }
 /// <summary>
 /// Thông báo kết của của hành động xem video
 /// </summary>
 /// <param name="success"></param>
 protected void DidCompletedVideo(bool success)
 {
     AdsMaster.OnCompletedReward(providerId, success);
 }
 /// <summary>
 /// Thông báo video đã được đóng
 /// </summary>
 protected void DidClosedVideo()
 {
     AdsMaster.OnDimissAd(AdType.Rewarded);
     SendRequest();
 }
示例#21
0
 private void didCloseRewardedVideo(CBLocation location)
 {
     //CLog.Log(this, "didCloseRewardedVideo");
     AdsMaster.OnDimissAd(AdType.Rewarded);
 }
示例#22
0
 public void OnClickedShowBannerSoon()
 {
     AdsMaster.ShowBanner();
 }
示例#23
0
 private void didDismissRewardedVideo(CBLocation location)
 {
     //CLog.Log(this, "didDismissRewardedVideo");
     AdsMaster.OnDimissAd(AdType.Rewarded);
     StartCoroutine(CacheRewardTask(2f));
 }
示例#24
0
 public void OnClickedHideBanner()
 {
     AdsMaster.HideBanner();
 }
示例#25
0
 private void didCompleteRewardedVideo(CBLocation location, int reward)
 {
     //CLog.Log(this, "didCompleteRewardedVideo");
     AdsMaster.OnCompletedReward(ID, true);
 }
示例#26
0
 // Use this for initialization
 void Start()
 {
     AdsMaster.ShowBanner();
 }
示例#27
0
 public void OnClickedTopBanner()
 {
     AdsMaster.ShowBannerIfLoaded("top banner");
 }
示例#28
0
 private void didDismissInterstitial(CBLocation location)
 {
     //CLog.Log(this, "didDismissInterstitial");
     AdsMaster.OnDimissAd(AdType.Interstitial);
 }
示例#29
0
 public void OnClickedShowInterstitialAd2()
 {
     AdsMaster.ShowInterstitial(null, "ad2");
 }
示例#30
0
 public void OnClickedDefaultBanner()
 {
     AdsMaster.ShowBannerIfLoaded();
 }