Esempio n. 1
0
    public override void Show(string zoneId, string adapterId, ShowOptions options = null) {
      Dictionary<string, object> configuration = _configurations[zoneId + adapterId];
      if(configuration != null && configuration.ContainsKey("network")) {
        UnityAds.setNetwork((string)configuration["network"]);
      }
      string videoZoneId = null;
      string rewardItem = "";
      if(configuration != null && configuration.ContainsKey("zone")) {
        videoZoneId = (string)configuration["zone"];
      }
      if(configuration != null && configuration.ContainsKey("rewardItem")) {
        rewardItem = (string)configuration["rewardItem"];
      }

      UnityAds.OnShow += UnityAdsShow;
      UnityAds.OnHide += UnityAdsHide;
      UnityAds.OnVideoCompleted += UnityAdsVideoCompleted;
      UnityAds.OnVideoStarted += UnityAdsVideoStarted;

      ShowOptionsExtended extendedOptions = options as ShowOptionsExtended;
      if(extendedOptions != null && extendedOptions.gamerSid != null && extendedOptions.gamerSid.Length > 0) {
        UnityAds.show(videoZoneId, rewardItem, new Dictionary<string, string>() {{"sid", extendedOptions.gamerSid}});
      } else {
        UnityAds.show(videoZoneId, rewardItem);
      }
    }
Esempio n. 2
0
    private IEnumerator WaitThenHideCompleteScreen()
    {
        yield return(new WaitForSeconds(1f));

                #if UNITY_ADS
        // If Unity Ads is on and the player completed the proper amount of levels then show an ad
        if (enableAds && LevelsToCompleteBeforeAd <= 0)
        {
            LevelsToCompleteBeforeAd = adLevelCompleteAmount;

            UnityEngine.Advertisements.ShowOptions adShowOptions = new UnityEngine.Advertisements.ShowOptions();

            // Show the ad first and when its done then hide the complete overlay
            adShowOptions.resultCallback = (UnityEngine.Advertisements.ShowResult adShowResult) =>
            {
                UIScreenController.Instance.HideOverlay(UIScreenController.CompleteScreenId, true, Tween.TweenStyle.EaseIn);
            };

            UnityEngine.Advertisements.Advertisement.Show(zoneId, adShowOptions);
        }
        else
        {
            UIScreenController.Instance.HideOverlay(UIScreenController.CompleteScreenId, true, Tween.TweenStyle.EaseIn);
        }
                #else
        UIScreenController.Instance.HideOverlay(UIScreenController.CompleteScreenId, true, Tween.TweenStyle.EaseIn);
                #endif
    }
Esempio n. 3
0
        public override void Show(string zoneId, string adapterId, ShowOptions options = null)
        {
            if (options != null && options.pause == false) {
            Utils.LogWarning ("Video ads will always pause engine, ignoring pause=false in ShowOptions");
              }

              Dictionary<string, object> configuration = _configurations[zoneId + adapterId];
              if(configuration != null && configuration.ContainsKey("network")) {
            UnityAds.setNetwork((string)configuration["network"]);
              }
              string videoZoneId = null;
              string rewardItem = "";
              if(configuration != null && configuration.ContainsKey("zone")) {
            videoZoneId = (string)configuration["zone"];
              }
              if(configuration != null && configuration.ContainsKey("rewardItem")) {
            rewardItem = (string)configuration["rewardItem"];
              }

              UnityAds.OnShow += UnityAdsShow;
              UnityAds.OnHide += UnityAdsHide;
              UnityAds.OnVideoCompleted += UnityAdsVideoCompleted;
              UnityAds.OnVideoStarted += UnityAdsVideoStarted;

              ShowOptionsExtended extendedOptions = options as ShowOptionsExtended;
              if(extendedOptions != null && extendedOptions.gamerSid != null && extendedOptions.gamerSid.Length > 0) {
            if(!UnityAds.show(videoZoneId, rewardItem, new Dictionary<string, string>() {{"sid", extendedOptions.gamerSid}})) {
              triggerEvent(EventType.error, EventArgs.Empty);
            }
              } else {
            if(!UnityAds.show(videoZoneId, rewardItem)) {
              triggerEvent(EventType.error, EventArgs.Empty);
            }
              }
        }
Esempio n. 4
0
    static public void Show(string zoneId = null, ShowOptions options = null) {
#if UNITY_ANDROID || UNITY_IOS
      UnityAds.SharedInstance.Show(zoneId, options);
#else
      if(options != null && options.resultCallback != null) {
        options.resultCallback(ShowResult.Failed);
      }
#endif
    }
Esempio n. 5
0
    /// <summary>
    /// Shows the interstital ad but only it it's been loaded. Returns true if the ad is shown, false otherwise.
    /// </summary>
    public bool ShowInterstitialAd(System.Action onAdClosed = null)
    {
        bool adShown = false;

        if (IsInterstitialAdsEnabled)
        {
            switch (interstitialType)
            {
            case InterstitialType.UnityAds:
                                #if UNITY_ADS
            {
                                        #if UNITY_EDITOR
                {
                    if (!enableUnityAdsInEditor)
                    {
                        break;
                    }
                }
                                        #endif

                interstitialAdClosedCallback = onAdClosed;

                UnityEngine.Advertisements.ShowOptions adShowOptions = new UnityEngine.Advertisements.ShowOptions();

                adShowOptions.resultCallback = OnUnityAdsInterstitalClosed;

                UnityEngine.Advertisements.Advertisement.Show(zoneId, adShowOptions);

                adShown = true;
            }
                                #else
                Debug.LogError("[AdsController] Unity Ads are not enabled in services");
                                #endif

                break;

            case InterstitialType.AdMob:
                                #if ADMOB
                if (interstitial != null && isInterstitialAdLoaded)
                {
                    interstitialAdClosedCallback = onAdClosed;

                    interstitial.Show();

                    adShown = true;
                }
                                #endif

                break;
            }
        }

        return(adShown);
    }
Esempio n. 6
0
    public void GoDoubleCoin()
    {
        UnityEngine.Advertisements.ShowOptions so = new UnityEngine.Advertisements.ShowOptions();
        so.resultCallback = ((result) => {
            m_PrizeButton.SetActive(false);

            if (result.Equals(UnityEngine.Advertisements.ShowResult.Finished))
            {
                GameData.Instance.m_Coin += m_GoldEarned;
                SaveDataLoader.SaveGame();

                m_CoinsThisRound.GetComponent <Text>().text = (m_GoldEarned * 2).ToString();
                m_Coins.GetComponent <Text>().text = (m_nShowingCoins + m_GoldEarned * 2).ToString();
            }
        });
        Adverts.Instance.ShowAd(AdVidType.video, so);
    }
        public override void Show(string zoneId, string adapterId, ShowOptions options = null)
        {
            Dictionary <string, object> configuration = _configurations[zoneId + adapterId];

            if (configuration != null && configuration.ContainsKey("network"))
            {
                UnityAds.setNetwork((string)configuration["network"]);
            }
            string videoZoneId = null;
            string rewardItem  = "";

            if (configuration != null && configuration.ContainsKey("zone"))
            {
                videoZoneId = (string)configuration["zone"];
            }
            if (configuration != null && configuration.ContainsKey("rewardItem"))
            {
                rewardItem = (string)configuration["rewardItem"];
            }

            UnityAds.OnShow           += UnityAdsShow;
            UnityAds.OnHide           += UnityAdsHide;
            UnityAds.OnVideoCompleted += UnityAdsVideoCompleted;
            UnityAds.OnVideoStarted   += UnityAdsVideoStarted;

            ShowOptionsExtended extendedOptions = options as ShowOptionsExtended;

            if (extendedOptions != null && extendedOptions.gamerSid != null && extendedOptions.gamerSid.Length > 0)
            {
                UnityAds.show(videoZoneId, rewardItem, new Dictionary <string, string>()
                {
                    { "sid", extendedOptions.gamerSid }
                });
            }
            else
            {
                UnityAds.show(videoZoneId, rewardItem);
            }
        }
Esempio n. 8
0
 /// <summary>
 /// Displays an ad in the default <a href="../manual/MonetizationPlacements.html">Placement</a> if it is ready, and passes a <a href="..api/UnityEngine.Advertisements.ShowResult.html"><c>ShowResult</c></a> enum to the <a href="../api/UnityEngine.Advertisements.ShowOptions.html"><c>ShowOptions.resultCallback</c></a> callback when the ad finishes.
 /// </summary>
 /// <param name="showOptions">A collection of options, including <c>resultCallback</c>, for modifying ad behavior.</param>
 public static void Show(ShowOptions showOptions)
 {
     Show(null, showOptions);
 }
Esempio n. 9
0
 abstract public void Show(string zoneId, string adapterId, ShowOptions options = null);
Esempio n. 10
0
 public override void Show(string zoneId, string adapterId, ShowOptions options = null)
 {
     _manager.showAd();
 }
Esempio n. 11
0
 static public void Show(string zoneId = null, ShowOptions options = null)
 {
     Engine.Instance.Show(zoneId, options);
 }
Esempio n. 12
0
 static public void Show(string zoneId = null, ShowOptions options = null) {
   Engine.Instance.Show(zoneId, options);
 }
Esempio n. 13
0
        public void Show(string zoneId, ShowOptions options)
        {
            if(!_initialized) {
            if(options.resultCallback != null) {
              options.resultCallback(ShowResult.Failed);
            }
            return;
              }

            if(!ConfigManager.Instance.IsReady()) {
                if (ConfigManager.Instance.globalIntervals != null)
              	Event.EventManager.sendMediationCappedEvent(Engine.Instance.AppId, null, "global", ConfigManager.Instance.globalIntervals.NextAvailable());
              if(options.resultCallback != null) {
            options.resultCallback(ShowResult.Failed);
              }
                    return;
            }

              Zone zone = ZoneManager.Instance.GetZone(zoneId);
              if(zone == null) {
            if(options.resultCallback != null) {
              options.resultCallback(ShowResult.Failed);
            }
            return;
              }

              Adapter adapter = zone.SelectAdapter();
              if(adapter == null) {
            if(options.resultCallback != null) {
              options.resultCallback(ShowResult.Failed);
            }
            return;
              }

              Utils.LogDebug("Consuming global ad slot");
              ConfigManager.Instance.globalIntervals.Consume();

              if(ConfigManager.Instance.globalIntervals.IsEmpty()) {
            Utils.LogDebug("Global ad interval list empty");
            ConfigManager.Instance.RequestAdSources();
              }

              EventHandler finishedHandler = null;
              EventHandler skippedHandler = null;
              EventHandler failedHandler = null;

              EventHandler closeHandler = null;
              closeHandler = (object sender, EventArgs e) => {
            _isShowing = false;
            adapter.Unsubscribe(Adapter.EventType.adDidClose, closeHandler);

            if(finishedHandler != null) {
              adapter.Unsubscribe(Adapter.EventType.adFinished, finishedHandler);
            }
            if(skippedHandler != null) {
              adapter.Unsubscribe(Adapter.EventType.adSkipped, skippedHandler);
            }
            if(failedHandler != null) {
              adapter.Unsubscribe(Adapter.EventType.error, failedHandler);
            }
              };
              adapter.Subscribe(Adapter.EventType.adDidClose, closeHandler);

              if(options != null) {
            if(options.pause) {
              EventHandler showHandler = null;
              showHandler = (object sender, EventArgs e) => {
            PauseGame();
            adapter.Unsubscribe(Adapter.EventType.adWillOpen, showHandler);
              };
              adapter.Subscribe(Adapter.EventType.adWillOpen, showHandler);
            }

            finishedHandler = (object sender, EventArgs e) => {
              _isShowing = false;
                    if(options.resultCallback != null)
              options.resultCallback(ShowResult.Finished);
              if(options.pause) {
            ResumeGame();
              }
              adapter.Unsubscribe(Adapter.EventType.adFinished, finishedHandler);
              finishedHandler = null;
            };
            adapter.Subscribe(Adapter.EventType.adFinished, finishedHandler);

            skippedHandler = (object sender, EventArgs e) => {
              _isShowing = false;
                    if(options.resultCallback != null)
              options.resultCallback(ShowResult.Skipped);
              if(options.pause) {
            ResumeGame();
              }
              adapter.Unsubscribe(Adapter.EventType.adSkipped, skippedHandler);
              skippedHandler = null;
            };
            adapter.Subscribe(Adapter.EventType.adSkipped, skippedHandler);

            failedHandler = (object sender, EventArgs e) => {
              _isShowing = false;
                    if(options.resultCallback != null)
              options.resultCallback(ShowResult.Failed);
              if(options.pause) {
            ResumeGame();
              }
              adapter.Unsubscribe(Adapter.EventType.error, failedHandler);
              failedHandler = null;
            };
            adapter.Subscribe(Adapter.EventType.error, failedHandler);
              }

              Event.EventManager.sendMediationShowEvent(AppId, zone.Id, adapter.Id);
              adapter.Show(zone.Id, adapter.Id, options);
              _isShowing = true;
        }
Esempio n. 14
0
        public void Show(string zoneId, ShowOptions options)
        {
            if (!_initialized)
            {
                if (options.resultCallback != null)
                {
                    options.resultCallback(ShowResult.Failed);
                }
                return;
            }

            if (!ConfigManager.Instance.IsReady())
            {
                if (ConfigManager.Instance.globalIntervals != null)
                {
                    Event.EventManager.sendMediationCappedEvent(Engine.Instance.AppId, null, "global", ConfigManager.Instance.globalIntervals.NextAvailable());
                }
                if (options.resultCallback != null)
                {
                    options.resultCallback(ShowResult.Failed);
                }
                return;
            }

            Zone zone = ZoneManager.Instance.GetZone(zoneId);

            if (zone == null)
            {
                if (options.resultCallback != null)
                {
                    options.resultCallback(ShowResult.Failed);
                }
                return;
            }

            Adapter adapter = zone.SelectAdapter();

            if (adapter == null)
            {
                if (options.resultCallback != null)
                {
                    options.resultCallback(ShowResult.Failed);
                }
                return;
            }

            Utils.LogDebug("Consuming global ad slot");
            ConfigManager.Instance.globalIntervals.Consume();

            if (ConfigManager.Instance.globalIntervals.IsEmpty())
            {
                Utils.LogDebug("Global ad interval list empty");
                ConfigManager.Instance.RequestAdSources();
            }

            EventHandler finishedHandler = null;
            EventHandler skippedHandler  = null;
            EventHandler failedHandler   = null;

            EventHandler closeHandler = null;

            closeHandler = (object sender, EventArgs e) => {
                _isShowing = false;
                adapter.Unsubscribe(Adapter.EventType.adDidClose, closeHandler);

                if (finishedHandler != null)
                {
                    adapter.Unsubscribe(Adapter.EventType.adFinished, finishedHandler);
                }
                if (skippedHandler != null)
                {
                    adapter.Unsubscribe(Adapter.EventType.adSkipped, skippedHandler);
                }
                if (failedHandler != null)
                {
                    adapter.Unsubscribe(Adapter.EventType.error, failedHandler);
                }
            };
            adapter.Subscribe(Adapter.EventType.adDidClose, closeHandler);

            if (options != null)
            {
                if (options.pause)
                {
                    EventHandler showHandler = null;
                    showHandler = (object sender, EventArgs e) => {
                        PauseGame();
                        adapter.Unsubscribe(Adapter.EventType.adWillOpen, showHandler);
                    };
                    adapter.Subscribe(Adapter.EventType.adWillOpen, showHandler);
                }

                finishedHandler = (object sender, EventArgs e) => {
                    _isShowing = false;
                    if (options.resultCallback != null)
                    {
                        options.resultCallback(ShowResult.Finished);
                    }
                    if (options.pause)
                    {
                        ResumeGame();
                    }
                    adapter.Unsubscribe(Adapter.EventType.adFinished, finishedHandler);
                    finishedHandler = null;
                };
                adapter.Subscribe(Adapter.EventType.adFinished, finishedHandler);

                skippedHandler = (object sender, EventArgs e) => {
                    _isShowing = false;
                    if (options.resultCallback != null)
                    {
                        options.resultCallback(ShowResult.Skipped);
                    }
                    if (options.pause)
                    {
                        ResumeGame();
                    }
                    adapter.Unsubscribe(Adapter.EventType.adSkipped, skippedHandler);
                    skippedHandler = null;
                };
                adapter.Subscribe(Adapter.EventType.adSkipped, skippedHandler);

                failedHandler = (object sender, EventArgs e) => {
                    _isShowing = false;
                    if (options.resultCallback != null)
                    {
                        options.resultCallback(ShowResult.Failed);
                    }
                    if (options.pause)
                    {
                        ResumeGame();
                    }
                    adapter.Unsubscribe(Adapter.EventType.error, failedHandler);
                    failedHandler = null;
                };
                adapter.Subscribe(Adapter.EventType.error, failedHandler);
            }

            Event.EventManager.sendMediationShowEvent(AppId, zone.Id, adapter.Id);
            adapter.Show(zone.Id, adapter.Id, options);
            _isShowing = true;
        }
Esempio n. 15
0
	public void Show(string zoneId = null, ShowOptions options = null) {
		string gamerSid = null;
		_resultDelivered = false;

		if (options != null) {
			if (options.resultCallback != null) {
				resultCallback = options.resultCallback;
			}

			ShowOptionsExtended extendedOptions = options as ShowOptionsExtended;
			if(extendedOptions != null && extendedOptions.gamerSid != null && extendedOptions.gamerSid.Length > 0) {
				gamerSid = extendedOptions.gamerSid;
			}
		}

		if (!isInitialized || isShowing) {
			deliverCallback (ShowResult.Failed);
			return;
		}
		
		if (gamerSid != null) {
			if (!show (zoneId, "", new Dictionary<string,string> {{"sid", gamerSid}})) {
				deliverCallback (ShowResult.Failed);
			}
		} else {
			if (!show (zoneId)) {
				deliverCallback (ShowResult.Failed);
			}
		}
	}
Esempio n. 16
0
	public void Show(string zoneId = null, ShowOptions options = null) {
		string gamerSid = null;
		_resultDelivered = false;

		if (options != null) {
			if (options.resultCallback != null) {
				resultCallback = options.resultCallback;
			}

			// Disable obsolete method warnings for this piece of code because here we need to access legacy ShowOptionsExtended to maintain compability
#pragma warning disable 612, 618
			ShowOptionsExtended extendedOptions = options as ShowOptionsExtended;
			if(extendedOptions != null && extendedOptions.gamerSid != null && extendedOptions.gamerSid.Length > 0) {
				gamerSid = extendedOptions.gamerSid;
			} else {
				gamerSid = options.gamerSid;
			}
#pragma warning restore 612, 618
		}

		if (!isInitialized || isShowing) {
			deliverCallback (ShowResult.Failed);
			return;
		}
		
		if (gamerSid != null) {
			if (!show (zoneId, "", new Dictionary<string,string> {{"sid", gamerSid}})) {
				deliverCallback (ShowResult.Failed);
			}
		} else {
			if (!show (zoneId)) {
				deliverCallback (ShowResult.Failed);
			}
		}
	}
Esempio n. 17
0
 // Token: 0x0600011F RID: 287 RVA: 0x00004054 File Offset: 0x00002254
 public static void Show(string zoneId, ShowOptions options)
 {
     UnityAds.SharedInstance.Show(zoneId, options);
 }
Esempio n. 18
0
 abstract public void Show(string zoneId, string adapterId, ShowOptions options = null);
Esempio n. 19
0
 public override void Show(string zoneId, string adapterId, ShowOptions options = null)
 {
     _manager.showAd();
 }