Example #1
0
 protected override void RemoveEventListeners()
 {
                 #if API_ADS_HEYZAP
     HZBannerAd.SetDisplayListener(null);
     HZInterstitialAd.SetDisplayListener(null);
     HZVideoAd.SetDisplayListener(null);
     HZIncentivizedAd.SetDisplayListener(null);
                 #endif
 }
Example #2
0
 protected override void CreateEventListeners()
 {
                 #if API_ADS_HEYZAP
     HZBannerAd.SetDisplayListener(OnBannerStateUpdate);
     HZInterstitialAd.SetDisplayListener(OnInterstitialStateUpdate);
     HZVideoAd.SetDisplayListener(OnInterstitialStateUpdate);
     HZIncentivizedAd.SetDisplayListener(OnIncentivizedStateUpdate);
                 #endif
 }
    // Use this for initialization
    void Start()
    {
        IsRewardedVideoReady = false;
        VideoAdCointer       = 0;
        HeyzapAds.Start("70d6db5109295d28b9ab83165d3fa95c", HeyzapAds.FLAG_NO_OPTIONS);
//		HeyzapAds.ShowMediationTestSuite();

        // Interstitial ads are automatically fetched
        HZInterstitialAd.Fetch("app-launch");
        HZVideoAd.Fetch("video");
        HZIncentivizedAd.Fetch("rewarded");
        HZIncentivizedAd.AdDisplayListener listener = delegate(string adState, string adTag){
            if (adState.Equals("incentivized_result_complete"))
            {
                // The user has watched the entire video and should be given a reward.
                GameEvents.Send(GiveReward);
            }
            if (adState.Equals("incentivized_result_incomplete"))
            {
                // The user did not watch the entire video and should not be given a   reward.
            }
            if (adState.Equals("hide"))
            {
                // Sent when an ad has been removed from view.
                // This is a good place to unpause your app, if applicable.
                Defs.MuteSounds(false);
            }
            if (adState.Equals("available"))
            {
                IsRewardedVideoReady = true;
                // Sent when an ad has been loaded and is ready to be displayed,
                //   either because we autofetched an ad or because you called
                //   `Fetch`.
            }
        };

        HZIncentivizedAd.SetDisplayListener(listener);

        HZVideoAd.AdDisplayListener listenerVideo = delegate(string adState, string adTag){
            if (adState.Equals("hide"))
            {
                // Sent when an ad has been removed from view.
                // This is a good place to unpause your app, if applicable.
                Defs.MuteSounds(false);
            }
        };

        HZVideoAd.SetDisplayListener(listenerVideo);
    }
Example #4
0
        void SetVideoListener()
        {
            HZVideoAd.AdDisplayListener listener = delegate(string adState, string adTag)
            {
                //				Debug.Log ("Video 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
                }
            };

            HZVideoAd.SetDisplayListener(listener);
        }
Example #5
0
    void Start()
    {
        HeyzapAds.NetworkCallbackListener networkCallbackListner = delegate(string network, string callback) {
            this.console.Append("[" + network + "]: " + callback);
        };

        HeyzapAds.SetNetworkCallbackListener(networkCallbackListner);
        HeyzapAds.Start("ENTER_YOUR_PUBLISHER_ID_HERE", HeyzapAds.FLAG_NO_OPTIONS);

        HZBannerAd.SetDisplayListener(delegate(string adState, string adTag) {
            this.console.Append("BANNER: " + adState + " Tag : " + adTag);
            if (adState == "loaded")
            {
                Rect dimensions = new Rect();
                HZBannerAd.GetCurrentBannerDimensions(out dimensions);
                this.console.Append(string.Format("    (x,y): ({0},{1}) - WxH: {2}x{3}", dimensions.x, dimensions.y, dimensions.width, dimensions.height));
            }
        });

        HZInterstitialAd.SetDisplayListener(delegate(string adState, string adTag) {
            this.console.Append("INTERSTITIAL: " + adState + " Tag : " + adTag);
        });

        HZIncentivizedAd.SetDisplayListener(delegate(string adState, string adTag) {
            this.console.Append("INCENTIVIZED: " + adState + " Tag : " + adTag);
        });

        HZVideoAd.SetDisplayListener(delegate(string adState, string adTag) {
            this.console.Append("VIDEO: " + adState + " Tag : " + adTag);
        });

        this.bannerControls.SetActive(false);
        this.nonBannerControls.SetActive(true);

        // UI defaults
        this.bannerPosition = HZBannerShowOptions.POSITION_TOP;
        this.SelectedAdType = AdType.Interstitial;
        HeyzapAds.HideDebugLogs();
    }
Example #6
0
    void Start()
    {
        HeyzapAds.NetworkCallbackListener networkCallbackListener = delegate(string network, string callback) {
            this.console.Append("[" + network + "]: " + callback);
        };

        // HZDemographics.SetUserGender(HZDemographics.Gender.MALE);
        // HZDemographics.SetUserPostalCode("94103");
        // HZDemographics.SetUserHouseholdIncome(100000);
        // HZDemographics.SetUserMaritalStatus(HZDemographics.MaritalStatus.SINGLE);
        // HZDemographics.SetUserEducationLevel(HZDemographics.EducationLevel.BACHELORS_DEGREE);
        // HZDemographics.SetUserBirthDate("1990-08-05");

        // UnityEngine.Debug.Log ("calling loc service");
        // TestLocationService locServ = new TestLocationService();
        // locServ.Start(this.console);

        HeyzapAds.SetNetworkCallbackListener(networkCallbackListener);
        HeyzapAds.ShowDebugLogs();
        HeyzapAds.Start("ENTER_YOUR_PUBLISHER_ID_HERE", HeyzapAds.FLAG_NO_OPTIONS);

        HZBannerAd.SetDisplayListener(delegate(string adState, string adTag) {
            this.console.Append("BANNER: " + adState + " Tag : " + adTag);
            if (adState == "loaded")
            {
                Rect dimensions = new Rect();
                HZBannerAd.GetCurrentBannerDimensions(out dimensions);
                this.console.Append(string.Format("    (x,y): ({0},{1}) - WxH: {2}x{3}", dimensions.x, dimensions.y, dimensions.width, dimensions.height));
            }
        });

        HZInterstitialAd.SetDisplayListener(delegate(string adState, string adTag) {
            this.console.Append("INTERSTITIAL: " + adState + " Tag : " + adTag);
        });

        HZIncentivizedAd.SetDisplayListener(delegate(string adState, string adTag) {
            this.console.Append("INCENTIVIZED: " + adState + " Tag : " + adTag);
        });

        HZVideoAd.SetDisplayListener(delegate(string adState, string adTag) {
            this.console.Append("VIDEO: " + adState + " Tag : " + adTag);
        });

        HZOfferWallAd.SetDisplayListener(delegate(string adState, string adTag) {
            this.console.Append("OFFERWALL: " + adState + " Tag : " + adTag);
        });

        HZOfferWallAd.SetVirtualCurrencyResponseListener(delegate(VirtualCurrencyResponse response) {
            this.console.Append("OFFERWALL VCS Response: id:" + response.CurrencyID + " name: '" + response.CurrencyName + "' amount : " + response.DeltaOfCurrency + " trans: " + response.LatestTransactionID);
        });

        HZOfferWallAd.SetVirtualCurrencyErrorListener(delegate(string errorMsg) {
            this.console.Append("OFFERWALL VCS Error: " + errorMsg);
        });

        // UI defaults
        this.bannerPosition = HZBannerShowOptions.POSITION_TOP;
        this.SelectedAdType = AdType.Interstitial;

        this.ShowAdTypeControls();
    }
Example #7
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
    }