Example #1
0
        void SetInterstitialListener()
        {
            HZInterstitialAd.AdDisplayListener listener = delegate(string adState, string adTag)
            {
                //	Debug.Log ("Static Ad ::: adState: " + adState + " , adTag: " + adTag);

                if (adState.Equals("show"))
                {
                    //Ad showing, pause game
                    StartTimer();
                }
                if (adState.Equals("hide"))
                {
                    //Ad gone, unpause game
                }
                if (adState.Equals("click"))
                {
                }
                if (adState.Equals("failed"))
                {
                }
                if (adState.Equals("available"))
                {
                }
                if (adState.Equals("fetch_failed"))
                {
                }
                if (adState.Equals("audio_starting"))
                {
                    //mute game sound
                }
                if (adState.Equals("audio_finished"))
                {
                    //unmute game sound
                }
            };

            HZInterstitialAd.SetDisplayListener(listener);
        }
Example #2
0
        /// <summary>
        /// Ads all Heyzap SDK listeners
        /// </summary>
        private void AdListeners()
        {
            if (debug)
            {
                Debug.Log(this + " add listeners");
                ScreenWriter.Write(this + " add listeners");
            }

            HZInterstitialAd.AdDisplayListener listener = delegate(string adState, string adTag)
            {
                if (adState.Equals("show"))
                {
                    if (debug)
                    {
                        Debug.Log(this + " show event triggered");
                        ScreenWriter.Write(this + " show event triggered interstitial");
                    }
                }
                if (adState.Equals("hide"))
                {
                    if (debug)
                    {
                        Debug.Log(this + " hide event triggered");
                        ScreenWriter.Write(this + " hide event triggered interstitial");
                    }
                    if (OnInterstitialClosed != null)
                    {
                        OnInterstitialClosed();
                        OnInterstitialClosed = null;
                    }
                    if (OnInterstitialClosedWithAdvertiser != null)
                    {
                        OnInterstitialClosedWithAdvertiser(SupportedAdvertisers.Heyzap.ToString());
                        OnInterstitialClosedWithAdvertiser = null;
                    }
                    HZInterstitialAd.Fetch();
                }
                if (adState.Equals("failed"))
                {
                    if (debug)
                    {
                        Debug.Log(this + " failed event triggered");
                        ScreenWriter.Write(this + " failed event triggered interstitial");
                    }
                }
                if (adState.Equals("available"))
                {
                    if (debug)
                    {
                        Debug.Log(this + " available event triggered");
                        ScreenWriter.Write(this + " available event triggered interstitial");
                    }
                }
                if (adState.Equals("fetch_failed"))
                {
                    if (debug)
                    {
                        Debug.Log(this + " fetch_failed event triggered");
                        ScreenWriter.Write(this + " fetch_failed event triggered interstitial");
                    }
                }
            };


            HZIncentivizedAd.AdDisplayListener listenerRewarded = delegate(string adState, string adTag)
            {
                if (adState.Equals("show"))
                {
                    if (debug)
                    {
                        Debug.Log(this + " show event triggered rewarded");
                        ScreenWriter.Write(this + " show event triggered rewarded");
                    }
                }
                if (adState.Equals("hide"))
                {
                    if (debug)
                    {
                        Debug.Log(this + " hide event triggered rewarded");
                        ScreenWriter.Write(this + " hide event triggered rewarded");
                    }
                    HZIncentivizedAd.Fetch();
                }
                if (adState.Equals("failed"))
                {
                    if (debug)
                    {
                        Debug.Log(this + " failed event triggered rewarded");
                        ScreenWriter.Write(this + " failed event triggered rewarded");
                    }
                }
                if (adState.Equals("available"))
                {
                    if (debug)
                    {
                        Debug.Log(this + " available event triggered rewarded");
                        ScreenWriter.Write(this + " available event triggered rewarded");
                    }
                }
                if (adState.Equals("fetch_failed"))
                {
                    if (debug)
                    {
                        Debug.Log(this + " fetch_failed event triggered rewarded");
                        ScreenWriter.Write(this + " fetch_failed event triggered rewarded");
                    }
                }
                if (adState.Equals("incentivized_result_complete"))
                {
                    if (OnCompleteMethod != null)
                    {
                        OnCompleteMethod(true);
                        OnCompleteMethod = null;
                    }
                    if (OnCompleteMethodWithAdvertiser != null)
                    {
                        OnCompleteMethodWithAdvertiser(true, SupportedAdvertisers.Heyzap.ToString());
                        OnCompleteMethodWithAdvertiser = null;
                    }
                }
                if (adState.Equals("incentivized_result_incomplete"))
                {
                    if (OnCompleteMethod != null)
                    {
                        OnCompleteMethod(false);
                        OnCompleteMethod = null;
                    }
                    if (OnCompleteMethodWithAdvertiser != null)
                    {
                        OnCompleteMethodWithAdvertiser(false, SupportedAdvertisers.Heyzap.ToString());
                        OnCompleteMethodWithAdvertiser = null;
                    }
                }
            };


            HZBannerAd.AdDisplayListener listenerBanner = delegate(string adState, string adTag)
            {
                if (debug)
                {
                    Debug.Log(this + " " + adState + " " + adTag);
                    ScreenWriter.Write(this + " " + adState + " " + adTag);
                }

                if (adState == "loaded")
                {
                    if (debug)
                    {
                        Debug.Log(this + " loaded event triggered banner");
                        ScreenWriter.Write(this + " loaded event triggered banner");
                    }
                    if (DisplayResult != null)
                    {
                        DisplayResult(true, position, bannerType);
                        DisplayResult = null;
                    }
                }
                if (adState == "error")
                {
                    if (debug)
                    {
                        Debug.Log(this + " error event triggered banner");
                        ScreenWriter.Write(this + " error event triggered banner");
                    }
                    if (DisplayResult != null)
                    {
                        DisplayResult(false, position, bannerType);
                        DisplayResult = null;
                    }
                }
                if (adState == "click")
                {
                    if (debug)
                    {
                        Debug.Log(this + " click event triggered banner");
                        ScreenWriter.Write(this + " click event triggered banner");
                    }
                }
            };

            HZInterstitialAd.SetDisplayListener(listener);
            HZIncentivizedAd.SetDisplayListener(listenerRewarded);
            HZBannerAd.SetDisplayListener(listenerBanner);
        }
Example #3
0
 // Token: 0x060000D6 RID: 214 RVA: 0x0000394D File Offset: 0x00001B4D
 public static void SetDisplayListener(HZInterstitialAd.AdDisplayListener listener)
 {
     HZInterstitialAd.adDisplayListener = listener;
 }
Example #4
0
 public static void setDisplayListener(HZInterstitialAd.AdDisplayListener listener)
 {
     HZInterstitialAd.SetDisplayListener(listener);
 }
    // Update is called once per frame
    void Update()
    {
        //You can set a listener on HZInterstitialAd, HZVideoAd, HZIncentivizedAd, and HZOfferWallAd.

        HZIncentivizedAd.AdDisplayListener listenerReward = delegate(string adState, string adTag) {
            if (adState.Equals("incentivized_result_complete"))
            {
                // The user has watched the entire video and should be given a reward.
            }
            if (adState.Equals("incentivized_result_incomplete"))
            {
                // The user did not watch the entire video and should not be given a   reward.
            }
        };

        HZIncentivizedAd.SetDisplayListener(listenerReward);

        HZInterstitialAd.AdDisplayListener listenerInterstitial = delegate(string adState, string adTag) {
            if (adState.Equals("show"))
            {
                // Sent when an ad has been displayed.
                // This is a good place to pause your app, if applicable.
            }
            if (adState.Equals("hide"))
            {
                // Sent when an ad has been removed from view.
                // This is a good place to unpause your app, if applicable.
            }
            if (adState.Equals("click"))
            {
                // Sent when an ad has been clicked by the user.
            }
            if (adState.Equals("failed"))
            {
                // Sent when you call `show`, but there isn't an ad to be shown.
                // Some of the possible reasons for show errors:
                //    - `HeyzapAds.PauseExpensiveWork()` was called, which pauses
                //      expensive operations like SDK initializations and ad
                //      fetches, andand `HeyzapAds.ResumeExpensiveWork()` has not
                //      yet been called
                //    - The given ad tag is disabled (see your app's Publisher
                //      Settings dashboard)
                //    - An ad is already showing
                //    - A recent IAP is blocking ads from being shown (see your
                //      app's Publisher Settings dashboard)
                //    - One or more of the segments the user falls into are
                //      preventing an ad from being shown (see your Segmentation
                //      Settings dashboard)
                //    - Incentivized ad rate limiting (see your app's Publisher
                //      Settings dashboard)
                //    - One of the mediated SDKs reported it had an ad to show
                //      but did not display one when asked (a rare case)
                //    - The SDK is waiting for a network request to return before an
                //      ad can show
            }
            if (adState.Equals("available"))
            {
                // Sent when an ad has been loaded and is ready to be displayed,
                //   either because we autofetched an ad or because you called
                //   `Fetch`.
            }
            if (adState.Equals("fetch_failed"))
            {
                // Sent when an ad has failed to load.
                // This is sent with when we try to autofetch an ad and fail, and also
                //    as a response to calls you make to `Fetch` that fail.
                // Some of the possible reasons for fetch failures:
                //    - Incentivized ad rate limiting (see your app's Publisher
                //      Settings dashboard)
                //    - None of the available ad networks had any fill
                //    - Network connectivity
                //    - The given ad tag is disabled (see your app's Publisher
                //      Settings dashboard)
                //    - One or more of the segments the user falls into are
                //      preventing an ad from being fetched (see your
                //      Segmentation Settings dashboard)
            }
            if (adState.Equals("audio_starting"))
            {
                // The ad about to be shown will need audio.
                // Mute any background music.
            }
            if (adState.Equals("audio_finished"))
            {
                // The ad being shown no longer needs audio.
                // Any background music can be resumed.
            }
        };

        HZInterstitialAd.SetDisplayListener(listenerInterstitial);

        if (GameController.adCount == 3)
        {
            if (!HZVideoAd.IsAvailable())
            {
                FetchVideoAd();
            }
        }

        if (GameController.adCount >= 5)
        {
            GameController.adCount = 0;
            int rand = Random.Range(0, 2);
            if (rand == 0)
            {
                ShowInterstitialAd();
            }
            else
            {
                ShowVideoAd();
            }
        }
    }
Example #6
0
    public override void SetCallbacks()
    {
        #region banner_callback
        HZBannerAd.AdDisplayListener listener = delegate(string adState, string adTag)
        {
            if (adState == "click")
            {
                ClickAdsEvent(adTag);
                Analytic.Instance.CustomEvent("ADS", "Banner_click", "");
            }
            if (adState == "loaded")
            {
                // Do something when the banner ad is loaded
            }
            if (adState == "error")
            {
                // Do something when the banner ad fails to load (they can fail when refreshing after successfully loading)
            }
        };
        HZBannerAd.SetDisplayListener(listener);
        #endregion

        #region interstitial_callback
        HZInterstitialAd.AdDisplayListener listenerInterstitial = delegate(string adState, string adTag) {
            if (adState.Equals("show"))
            {
                ShowAdsEvent(adTag);
                Analytic.Instance.CustomEvent("ADS", "show", adTag);
            }
            if (adState.Equals("hide"))
            {
                Analytic.Instance.CustomEvent("ADS", "hide", adTag);
            }
            if (adState.Equals("click"))
            {
                ClickAdsEvent(adTag);
                Analytic.Instance.CustomEvent("ADS", "click", adTag);
            }
            if (adState.Equals("failed"))
            {
                Analytic.Instance.CustomEvent("ADS", "failed", adTag);
            }
            if (adState.Equals("available"))
            {
                AvailableAdsEvent(adTag);
                Analytic.Instance.CustomEvent("ADS", "available", adTag);
            }
            if (adState.Equals("fetch_failed"))
            {
                Analytic.Instance.CustomEvent("ADS", "fetch_failed", adTag);
            }
            if (adState.Equals("audio_starting"))
            {
                Analytic.Instance.CustomEvent("ADS", "audio_starting", adTag);
            }
            if (adState.Equals("audio_finished"))
            {
                Analytic.Instance.CustomEvent("ADS", "audio_finished", adTag);
            }
        };

        HZInterstitialAd.SetDisplayListener(listenerInterstitial);
        #endregion

        #region video_callback
        HZVideoAd.AdDisplayListener listenerVideo = delegate(string adState, string adTag) {
            if (adState.Equals("show"))
            {
                ShowAdsEvent(adTag);
                Analytic.Instance.CustomEvent("ADS", "show", adTag);
            }
            if (adState.Equals("hide"))
            {
                Analytic.Instance.CustomEvent("ADS", "hide", adTag);
            }
            if (adState.Equals("click"))
            {
                ClickAdsEvent(adTag);
                Analytic.Instance.CustomEvent("ADS", "click", adTag);
            }
            if (adState.Equals("failed"))
            {
                Analytic.Instance.CustomEvent("ADS", "failed", adTag);
            }
            if (adState.Equals("available"))
            {
                AvailableAdsEvent(adTag);
                Analytic.Instance.CustomEvent("ADS", "available", adTag);
            }
            if (adState.Equals("fetch_failed"))
            {
                Analytic.Instance.CustomEvent("ADS", "fetch_failed", adTag);
            }
            if (adState.Equals("audio_starting"))
            {
                Analytic.Instance.CustomEvent("ADS", "audio_starting", adTag);
            }
            if (adState.Equals("audio_finished"))
            {
                Analytic.Instance.CustomEvent("ADS", "audio_finished", adTag);
            }
        };

        HZVideoAd.SetDisplayListener(listenerVideo);
        #endregion

        #region rewarded_callback
        HZIncentivizedAd.AdDisplayListener listenerRewarded = delegate(string adState, string adTag) {
            if (adState.Equals("show"))
            {
                Analytic.Instance.CustomEvent("ADS", "show", adTag);
            }
            if (adState.Equals("hide"))
            {
                Analytic.Instance.CustomEvent("ADS", "hide", adTag);
            }
            if (adState.Equals("click"))
            {
                ClickAdsEvent(adTag);
                Analytic.Instance.CustomEvent("ADS", "click", adTag);
            }
            if (adState.Equals("failed"))
            {
                Analytic.Instance.CustomEvent("ADS", "failed", adTag);
            }
            if (adState.Equals("available"))
            {
                AvailableAdsEvent(adTag);
                Analytic.Instance.CustomEvent("ADS", "available", adTag);
            }
            if (adState.Equals("fetch_failed"))
            {
                Analytic.Instance.CustomEvent("ADS", "fetch_failed", adTag);
            }
            if (adState.Equals("audio_starting"))
            {
                Analytic.Instance.CustomEvent("ADS", "audio_starting", adTag);
            }
            if (adState.Equals("audio_finished"))
            {
                Analytic.Instance.CustomEvent("ADS", "audio_finished", adTag);
            }
            if (adState.Equals("incentivized_result_complete"))
            {
                ShowAdsEvent(adTag);
                Analytic.Instance.CustomEvent("ADS", "incentivized_result_complete", adTag);
            }
            if (adState.Equals("incentivized_result_incomplete"))
            {
                Analytic.Instance.CustomEvent("ADS", "incentivized_result_incomplete", adTag);
            }
        };

        HZIncentivizedAd.SetDisplayListener(listenerRewarded);
        #endregion
    }