示例#1
0
        public void CacheInterstitial(string tag)
        {
                        #if API_ADS_HEYZAP
//			Debug.Log("CacheInterstitial: " + tag);
            HZInterstitialAd.Fetch(tag);
                        #endif
        }
示例#2
0
    public override void Show(AdsElement type)
    {
        if (!AdsController.NoAds)
        {
            switch (type.type)
            {
            case AdsType.Interstitial:
                HZShowOptions showOptions = new HZShowOptions();
                showOptions.Tag = type.name;
                HZInterstitialAd.ShowWithOptions(showOptions);
                break;

            case AdsType.Video:
                HZShowOptions showOptionsVideo = new HZShowOptions();
                showOptionsVideo.Tag = type.name;
                HZVideoAd.ShowWithOptions(showOptionsVideo);
                break;

            case AdsType.RewardedVideo:
                HZIncentivizedShowOptions showOptionsReward = new HZIncentivizedShowOptions();
                showOptionsReward.Tag = type.name;
                HZIncentivizedAd.ShowWithOptions(showOptionsReward);
                break;
            }
        }
    }
示例#3
0
        protected override void InternalInit()
        {
            #if EM_HEYZAP
            // Store a reference to the global settings.
            mGlobalAdSettings = EM_Settings.Advertising.Heyzap;

            // Set GPDR consent (if any) *before* starting the SDK
            // https://developers.heyzap.com/docs/unity_sdk_setup_and_requirements
            var consent = GetApplicableDataPrivacyConsent();
            ApplyDataPrivacyConsent(consent);

            // Start Heyzap with no automatic fetching since we'll handle ad loading.
            HeyzapAds.Start(mGlobalAdSettings.PublisherId, HeyzapAds.FLAG_DISABLE_AUTOMATIC_FETCHING);

            // Add callback handlers
            HZBannerAd.SetDisplayListener(BannerAdCallback);
            HZInterstitialAd.SetDisplayListener(InterstitialAdCallback);
            HZIncentivizedAd.SetDisplayListener(RewardedAdCallback);
            HeyzapAds.SetNetworkCallbackListener(NetworkCallbackListener);

            mIsInitialized = true;
            Debug.Log("Heyzap client has been initialized.");
            #else
            Debug.LogError(NO_SDK_MESSAGE);
            #endif
        }
示例#4
0
        //------------------------------------------------------------
        // Init.
        //------------------------------------------------------------

        public void Init(AdSettings settings)
        {
            #if EM_HEYZAP
            if (isInitialized)
            {
                Debug.Log("Heyzap client is already initialized. Ignoring this call.");
                return;
            }

            // Store a reference to the global settings.
            globalAdSettings = settings;

            // Start Heyzap with no automatic fetching since we'll handle ad loading.
            HeyzapAds.Start(globalAdSettings.HeyzapPublisherId, HeyzapAds.FLAG_DISABLE_AUTOMATIC_FETCHING);

            // Add callback handlers
            HZBannerAd.SetDisplayListener(BannerAdCallback);
            HZInterstitialAd.SetDisplayListener(InterstitialAdCallback);
            HZIncentivizedAd.SetDisplayListener(RewardedAdCallback);

            isInitialized = true;
            Debug.Log("Heyzap client has been initialized.");
            #else
            Debug.LogError(NO_SDK_MESSAGE);
            #endif
        }
示例#5
0
    public void IsAvailableButton()
    {
        string tag       = this.adTag();
        bool   available = false;

        switch (this.SelectedAdType)
        {
        case AdType.Interstitial:
            available = HZInterstitialAd.IsAvailable(tag);
            break;

        case AdType.Video:
            available = HZVideoAd.IsAvailable(tag);
            break;

        case AdType.Incentivized:
            available = HZIncentivizedAd.IsAvailable(tag);
            break;

        case AdType.Banner:
            // Not applicable
            break;

        case AdType.Offerwall:
            available = HZOfferWallAd.IsAvailable(tag);
            break;
        }

        string availabilityMessage = available ? "available" : "not available";

        this.console.Append(this.SelectedAdType.ToString() + " with tag: " + tag + " is " + availabilityMessage);
    }
示例#6
0
    public static IEnumerator AdRoutine()
    {
        // Disable game input
        ButtonController.showingAd = true;
        // Dim the game
        iTween.CameraFadeAdd();
        iTween.CameraFadeTo(1f, 1f);
        // wait a while
        yield return(new WaitForSeconds(1f));

        // Show the ad
        HZInterstitialAd.show();
        // wait a while
        yield return(new WaitForSeconds(3f));

        // Hide the ad
        HZInterstitialAd.hide();
        // Undim the game
        iTween.CameraFadeTo(0f, .5f);
        yield return(new WaitForSeconds(.5f));

        iTween.CameraFadeDestroy();
        // Enable input
        ButtonController.showingAd = false;
    }
示例#7
0
        void FetchAds()
        {
            foreach (string tag in adsSettings.rewardAdTags)
            {
                HZIncentivizedAd.Fetch(tag);
                Toaster.ShowDebugToast("Fetching 'reward' ad for tag; " + tag);
            }

            //Dont fetch interstitials if NoAds is baught
            if (adsRemoved)
            {
                Toaster.ShowDebugToast("Not fetching other ads because 'Remove_ads' is bought.");
                return;
            }

            HZInterstitialAd.ChartboostFetchForLocation("Default");

            foreach (string tag in adsSettings.staticAdTags)
            {
                HZInterstitialAd.Fetch(tag);
                Toaster.ShowDebugToast("Fetching 'static' ad for tag; " + tag);
            }
            foreach (string tag in adsSettings.videoAdTags)
            {
                HZVideoAd.Fetch(tag);
                Toaster.ShowDebugToast("Fetching 'video' ad for tag; " + tag);
            }
        }
示例#8
0
    // Update is called once per frame
    void Update()
    {
        //sideText.text = sideValue.ToString ();
        sideText.text = maxSide.ToString();

        ScoreText.text = Score.ToString();

        for (int i = Life.Length - 1; i >= 0; i--)
        {
            if (lifeCount == i)
            {
                if (Life[i].activeSelf)
                {
                    Life[i].SetActive(false);
                }
            }
        }

        if (lifeCount < 0)
        {
            Time.timeScale = 0;
            gameOverPanel.SetActive(true);
            applyHighScore();

            if (showAd)
            {
                HZInterstitialAd.show();
                showAd = false;
            }
        }
    }
示例#9
0
        //------------------------------------------------------------
        // Interstitial Ads.
        //------------------------------------------------------------

        public void LoadInterstitialAd(AdLocation location)
        {
            #if EM_HEYZAP
            HZInterstitialAd.Fetch();
            #else
            Debug.LogError(NO_SDK_MESSAGE);
            #endif
        }
示例#10
0
 /// <summary>
 /// Show Heyzap interstitial
 /// </summary>
 /// <param name="InterstitialClosed">callback called when user closes interstitial</param>
 public void ShowInterstitial(UnityAction <string> InterstitialClosed)
 {
     if (HZInterstitialAd.IsAvailable())
     {
         OnInterstitialClosedWithAdvertiser = InterstitialClosed;
         HZInterstitialAd.Show();
     }
 }
示例#11
0
 public bool IsInterstitialAdReady(AdLocation location)
 {
     #if EM_HEYZAP
     return(HZInterstitialAd.IsAvailable());
     #else
     return(false);
     #endif
 }
示例#12
0
 /// <summary>
 /// Show Heyzap interstitial
 /// </summary>
 /// <param name="InterstitialClosed">callback called when user closes interstitial</param>
 public void ShowInterstitial(UnityAction InterstitialClosed)
 {
     if (HZInterstitialAd.IsAvailable())
     {
         OnInterstitialClosed = InterstitialClosed;
         HZInterstitialAd.Show();
     }
 }
示例#13
0
 public static void initReceiver()
 {
     if (_instance == null) {
       GameObject receiverObject = new GameObject("HZInterstitialAd");
       DontDestroyOnLoad(receiverObject);
       _instance = receiverObject.AddComponent<HZInterstitialAd>();
     }
 }
示例#14
0
 protected override void CreateEventListeners()
 {
                 #if API_ADS_HEYZAP
     HZBannerAd.SetDisplayListener(OnBannerStateUpdate);
     HZInterstitialAd.SetDisplayListener(OnInterstitialStateUpdate);
     HZVideoAd.SetDisplayListener(OnInterstitialStateUpdate);
     HZIncentivizedAd.SetDisplayListener(OnIncentivizedStateUpdate);
                 #endif
 }
示例#15
0
 protected override void RemoveEventListeners()
 {
                 #if API_ADS_HEYZAP
     HZBannerAd.SetDisplayListener(null);
     HZInterstitialAd.SetDisplayListener(null);
     HZVideoAd.SetDisplayListener(null);
     HZIncentivizedAd.SetDisplayListener(null);
                 #endif
 }
 public static void initReceiver()
 {
     if (_instance == null)
     {
         GameObject receiverObject = new GameObject("HZInterstitialAd");
         DontDestroyOnLoad(receiverObject);
         _instance = receiverObject.AddComponent <HZInterstitialAd>();
     }
 }
    //heyzap

    public void InitHeyzap()
    {
        if (PlayerPrefs.GetInt("Removeads", 0) == 0)
        {
                #if !UNITY_EDITOR
            HeyzapAds.Start(heyzapAD, HeyzapAds.FLAG_NO_OPTIONS);
            HZInterstitialAd.Fetch();
                #endif
        }
    }
 public void heyzapShow()
 {
     if (PlayerPrefs.GetInt("Removeads", 0) == 0)
     {
             #if !UNITY_EDITOR
         HZInterstitialAd.Show();
         HZInterstitialAd.Fetch();
             #endif
     }
 }
示例#19
0
    IEnumerator AdCache(float waitTime)
    {
        yield return(new WaitForSeconds(waitTime));

        HZInterstitialAd.Fetch();
        if (Random.Range(0, 10) >= 2)
        {
            HZVideoAd.Fetch();
        }
    }
示例#20
0
        public void ShowIntersitital(string tag)
        {
                        #if API_ADS_HEYZAP
            HZShowOptions options = new HZShowOptions();
            options.Tag = tag;

            HZInterstitialAd.ShowWithOptions(options);
            HZInterstitialAd.Fetch(tag);                // TODO: do we really need this?
                        #endif
        }
示例#21
0
 void ShowAdGameOver()
 {
     if (HZInterstitialAd.IsAvailable("GameOver"))
     {
         //HZShowOptions showOptions = new HZShowOptions();
         //showOptions.Tag = "GameOver";
         //HZInterstitialAd.ShowWithOptions(showOptions);
         HZInterstitialAd.Show();
     }
 }
 public void ShowInterstitialAd()
 {
     if (HZInterstitialAd.IsAvailable())
     {
         HZInterstitialAd.Show();
     }
     else
     {
         UnityAdsController.instance.ShowUnityinterstitialAd();
     }
 }
示例#23
0
 public void ShowChartboostInterstitial()
 {
     if (canShowAd && !adsRemoved && HZInterstitialAd.ChartboostIsAvailableForLocation("Default"))
     {
         Toaster.ShowDebugToast("Showing Chartboost Interstitial for location; Default");
         HZInterstitialAd.ChartboostShowForLocation("Default");
     }
     else
     {
         Toaster.ShowDebugToast("Can't show Chartboost Interstitial because not available or Ads are removed");
     }
 }
示例#24
0
 public void ShowInterstitialAd()
 {
     if (canShowAd && !adsRemoved && HZInterstitialAd.IsAvailable())
     {
         Toaster.ShowDebugToast("Showing Interstitial ad");
         HZInterstitialAd.Show();
     }
     else
     {
         Toaster.ShowDebugToast("Cant show Interstitial ad");
     }
 }
 public void Levelquit()
 {
             #if !UNITY_EDITOR
     if (PlayerPrefs.GetInt("Removeads", 0) == 0)
     {
         if (HZInterstitialAd.IsAvailable())
         {
             heyzapShow();
         }
     }
             #endif
 }
示例#26
0
 public void ShowInterstitialAd()
 {
     if (HZInterstitialAd.IsAvailable() && AdChecker)
     {
         HZInterstitialAd.Show();
         AdChecker = false;
     }
     else if (AdChecker)
     {
         AdChecker = false;
         UnityAdsController.instance.ShowUniytinterstitialAd();
     }
 }
示例#27
0
        //------------------------------------------------------------
        // Interstitial Ads.
        //------------------------------------------------------------

        protected override void InternalLoadInterstitialAd(AdPlacement placement)
        {
            #if EM_HEYZAP
            if (placement == AdPlacement.Default)
            {
                HZInterstitialAd.Fetch();
            }
            else
            {
                HZInterstitialAd.Fetch(ToHeyzapAdTag(placement));
            }
            #endif
        }
示例#28
0
    /* Show ads on awake - currently not working well, too slow to fetch */
    // private void ShowInterstitialOnAwake(){
    //  if(!PlayerPrefs.HasKey("firstload")){
    //      PlayerPrefs.SetString("firstload", "true");
    //  }else{
    //      ShowInterstitial();
    //  }
    // }

    /* Show interstitial ads on game over after set number of games or set score achieved */
    public void ShowInterstitialOnGameOver()
    {
        gamesCompleted++;
        if (gamesCompleted == showAfterNoGames || GameManager.Instance.LatestScore >= showAfterScore)
        {
            HZInterstitialAd.show();
            gamesCompleted = 0;
            // if(HZInterstitialAd.isAvailable("gameover")){
            //  gamesCompleted = 0;
            //  ShowInterstitial("gameover");
            //  FetchInterstitial("gameover");
            // }
        }
    }
示例#29
0
 void ShowAdMenu()
 {
     if (HZInterstitialAd.IsAvailable("MainMenu"))
     {
         if (!showOnce)
         {
             //HZShowOptions showOptions = new HZShowOptions();
             //showOptions.Tag = "MainMenu";
             //HZInterstitialAd.ShowWithOptions(showOptions);
             HZInterstitialAd.Show();
         }
         showOnce = true;
     }
 }
    // 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);
    }
示例#31
0
        /// <summary>
        /// Initializing Heyzap
        /// </summary>
        /// <param name="consent">user consent -> if true show personalized ads</param>
        /// <param name="platformSettings">contains all required settings for this publisher</param>
        public void InitializeAds(GDPRConsent consent, List <PlatformSettings> platformSettings)
        {
            debug = Advertisements.Instance.debug;

            //get settings
#if UNITY_ANDROID
            PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.Android);
#endif
#if UNITY_IOS
            PlatformSettings settings = platformSettings.First(cond => cond.platform == SupportedPlatforms.iOS);
#endif
            //apply settings
            publisherId = settings.appId.id;

            //verify settings
            if (debug)
            {
                Debug.Log(this + " Initialization Started");
                ScreenWriter.Write(this + " Initialization Started");
                Debug.Log(this + " Publisher ID: " + publisherId);
                ScreenWriter.Write(this + " Publisher ID: " + publisherId);
            }

            AdListeners();

            //preparing Heyzap SDK for initialization
            if (consent == GDPRConsent.Accept || consent == GDPRConsent.Unset)
            {
                HeyzapAds.SetGdprConsent(true);
            }
            else
            {
                HeyzapAds.SetGdprConsent(false);
            }

            if (settings.directedForChildren == true)
            {
                HeyzapAds.Start(publisherId, HeyzapAds.FLAG_CHILD_DIRECTED_ADS);
            }
            else
            {
                HeyzapAds.Start(publisherId, HeyzapAds.FLAG_NO_OPTIONS);
            }

            //start loading ads
            HZInterstitialAd.Fetch();
            HZIncentivizedAd.Fetch();
            //HeyzapAds.ShowMediationTestSuite();
        }