Example #1
0
    // Use this for initialization
    void Start()
    {
        StoreEvents.OnMarketPurchase       += onMarketPurchase;
        StoreEvents.OnUnexpectedStoreError += onUnexpectedStoreError;

        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.
                GameData.Instance.multiRemainingGameCount += 5;
                GameData.Instance.rewardedGameCount       += 5;
                GameData.Instance.Save();
            }
            if (adState.Equals("incentivized_result_incomplete"))
            {
                // The user did not watch the entire video and should not be given a   reward.
            }
        };

        HZIncentivizedAd.SetDisplayListener(listener);

        HZIncentivizedAd.Fetch();

//		if (GameData.Instance.multiRemainingGameCount <= 0) {
//			active = true;
////			checkDailyLimitExceed ();
//		} else {
//			active = false;
//		}

//		if (StoreInventory.GetItemBalance (NumberGameAssets.NO_ADS_ITEM_ID) > 0) {
//			noAds.enabled = false;
//			noAds.GetComponentInChildren<Text>().text = "All ads removed";
//		}
    }
    // 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 #3
0
        void SetRewardAdListener()
        {
            HZIncentivizedAd.AdDisplayListener listener = delegate(string adState, string adTag)
            {
                if (adState.Equals("show"))
                {
                    //Ad showing, pause game
                }
                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
                }
                if (adState.Equals("incentivized_result_complete"))
                {
                    //reward player here
                    OnRewardAdCompleted(adTag);
                    Toaster.ShowDebugToast("Reward ad Conpleted for tag; " + adTag);
                }
                if (adState.Equals("incentivized_result_incomplete"))
                {
                    OnRewardAdSkipped(adTag);
                    Toaster.ShowDebugToast("Reward ad 'Skipped' for tag; " + adTag);
                }
            };

            HZIncentivizedAd.SetDisplayListener(listener);
        }
Example #4
0
 void Start()
 {
     HeyzapAds.Start("3a045a04722e168baefdd3eeff198305", HeyzapAds.FLAG_NO_OPTIONS);
     HZVideoAd.Fetch();
     HZIncentivizedAd.Fetch();
     HZIncentivizedAd.AdDisplayListener listener = delegate(string adState, string adTag) {
         if (adState.Equals("incentivized_result_complete"))
         {
             PlayerPrefs.SetInt("currentShards", PlayerPrefs.GetInt("currentShards") + 10);
         }
         if (adState.Equals("incentivized_result_incomplete"))
         {
             //Don give him/her shards
         }
     };
     HZIncentivizedAd.SetDisplayListener(listener);
 }
    private void ShowIncentiveAds()
    {
        HZIncentivizedAd.AdDisplayListener listener = delegate(string adState, string adTag) {
            if (adState.Equals("fetch_failed"))
            {
                //TELL USER TO CHECK CONNECTION
                HZIncentivizedAd.Fetch();
            }
            if (adState.Equals("incentivized_result_complete"))
            {
                // Give reward to the player
                RewardToPlayer();
                HZIncentivizedAd.Fetch();
            }
            if (adState.Equals("incentivized_result_incomplete"))
            {
                // The user did not watch the entire video and should not be given a reward.
                HZIncentivizedAd.Fetch();
            }
        };

        HZIncentivizedAd.SetDisplayListener(listener);
    }
Example #6
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);
        }
    // 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();
            }
        }
    }
 // Token: 0x060000BB RID: 187 RVA: 0x000036D9 File Offset: 0x000018D9
 public static void SetDisplayListener(HZIncentivizedAd.AdDisplayListener listener)
 {
     HZIncentivizedAd.adDisplayListener = listener;
 }
 public static void setDisplayListener(HZIncentivizedAd.AdDisplayListener listener)
 {
     HZIncentivizedAd.SetDisplayListener(listener);
 }
Example #10
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
    }