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); }
public static bool PlayAd(UnityEngine.Events.UnityAction onAdPlay, UnityEngine.Events.UnityAction adNotAviable) { // fetch the video HZVideoAd.Fetch(); // Check for availability if (HZVideoAd.IsAvailable()) { // Show the ad HZVideoAd.Show(); // Callback if (null != onAdPlay) { onAdPlay.Invoke(); } // E x i t return(true); } // Failed debug it if (null != adNotAviable) { adNotAviable.Invoke(); } return(false); }
public void ShowVideo() { if (HZVideoAd.IsAvailable()) { HZVideoAd.Show(); } }
// Untouched code copied from AdCentral // ------------ private static bool PlayHeyzapVideoAd() { if (HZVideoAd.IsAvailable()) { HZVideoAd.Show(); HZVideoAd.Fetch(); return(true); } return(false); }
public void ShowVideoAd() { if (HZVideoAd.IsAvailable()) { HZVideoAd.Show(); } else { FetchVideoAd(); } }
public void ShowVideoAd() { if (canShowAd && !adsRemoved && HZVideoAd.IsAvailable()) { Toaster.ShowDebugToast("Showing Video ad"); HZVideoAd.Show(); } else { Toaster.ShowDebugToast("Can't show Video ad"); } }
private void ShowVideo() { // Later, such as after a level is completed if (HZVideoAd.IsAvailable("video")) { HZShowOptions showOptions = new HZShowOptions(); showOptions.Tag = "video"; HZVideoAd.ShowWithOptions(showOptions); VideoAdCointer = 0; Defs.MuteSounds(true); } }
public static bool PlayAd() { // fetch the video HZVideoAd.Fetch(); // Check for availability if (HZVideoAd.IsAvailable()) { // Show the ad HZVideoAd.Show(); // E x i t return(true); } return(false); }
public void ShowVideoAd(string tag) { if (HZVideoAd.IsAvailable(tag) && canShowAd && !adsRemoved) { Toaster.ShowDebugToast("Showing Video ad for tag; " + tag); HZShowOptions options = new HZShowOptions(); options.Tag = tag; HZVideoAd.ShowWithOptions(options); } else { Toaster.ShowDebugToast("Can't show Video ad for tag; " + tag); } }
public void NextLevel() { if (PlayerPrefs.GetInt("currentAdIteration") == 2) { PlayerPrefs.SetInt("currentAdIteration", 0); if (HZVideoAd.IsAvailable()) { HZVideoAd.Show(); } } else { PlayerPrefs.SetInt("currentAdIteration", PlayerPrefs.GetInt("currentAdIteration") + 1); } SceneManager.LoadScene(currentLevel + 1); }
IEnumerator End(float waitTime) { gameEnded = true; audioWhistle2.Play(); player.gameEnded = true; opponent.gameEnded = true; data.GetComponent <Data>().playerScore = pScore; data.GetComponent <Data>().oppScore = oScore; yield return(new WaitForSeconds(waitTime)); // // Show AD // if (Random.Range(0, 10) >= 2) { if (HZVideoAd.IsAvailable()) { HZVideoAd.Show(); } else { HZInterstitialAd.Show(); } } else { HZInterstitialAd.Show(); } // Show Menu menuBtn.SetActive(true); rematchBtn.SetActive(true); // // AD cache // StartCoroutine(AdCache(0.1F)); }
public override bool IsAvilable(AdsElement type) { if (!AdsController.NoAds) { switch (type.type) { case AdsType.Interstitial: HZInterstitialAd.IsAvailable(type.name); break; case AdsType.Video: HZVideoAd.IsAvailable(type.name); break; case AdsType.RewardedVideo: HZIncentivizedAd.IsAvailable(type.name); break; } } return(false); }
public void showHeyZapAds() { if (PlayerPrefs.HasKey("HeyZadAdcount")) { if (PlayerPrefs.GetInt("HeyZadAdcount") == 3) { HZInterstitialAd.Show(); PlayerPrefs.SetInt("HeyZadAdcount", 0); } else { if (HZVideoAd.IsAvailable()) { HZVideoAd.Show(); } PlayerPrefs.SetInt("HeyZadAdcount", PlayerPrefs.GetInt("HeyZadAdcount") + 1); } } else { PlayerPrefs.SetInt("HeyZadAdcount", 0); } }
void OnTriggerEnter2D(Collider2D other) { if (!gameEnded) { if (other.gameObject.tag == "Enemy" && !shieldActive) { ShieldPowerup.clip = lost; gameStarted = false; StartCoroutine(GameOverMenuDelay()); gameEnded = true; SpriteRenderer sr = this.GetComponent <SpriteRenderer> (); sr.enabled = false; foreach (GameObject x in arrows) { Arrow arrowScript = x.GetComponent <Arrow> (); arrowScript.gameStarted = false; arrowScript.gameStartedControl = true; x.SetActive(false); } GameObject z = GameObject.Find("EndOfGameScoreText"); Text score1 = z.GetComponent <Text> (); score1.text += scoreF.ToString("0.00"); //isTouched = false; scoreF = Mathf.Round(scoreF * 100f) / 100f; highScore = Mathf.Round(highScore * 100f) / 100f; // round to nearest 100th // Set taunts here Text tauntText = GameObject.Find("TauntText").GetComponent <Text> (); if (scoreF > highScore) { PlayerPrefs.SetFloat("Highscore", scoreF); highScore = scoreF; z = GameObject.Find("HighscoreText"); score1 = z.GetComponent <Text> (); score1.text += highScore.ToString("0.00"); int x = Random.Range(1, 4); // 3 taunts switch (x) { case 1: tauntText.text = "You've outdone yourself!"; tauntText.fontSize = 20; break; case 2: tauntText.text = "New highscore!"; tauntText.fontSize = 22; break; case 3: tauntText.text = "Well done!"; tauntText.fontSize = 22; break; } } else { // no new highscore if (scoreF < 15) { // below 15 seconds int x = Random.Range(1, 5); // 5 taunts switch (x) { case 1: tauntText.text = "Well, this is embarrassing"; tauntText.fontSize = 19; break; case 2: tauntText.text = "That's not all you've got,\nis it?!"; tauntText.transform.localPosition = new Vector3(tauntText.transform.localPosition.x, 18.7f, 0f); tauntText.fontSize = 18; break; case 3: tauntText.text = "Is that your best?"; tauntText.fontSize = 21; break; case 4: tauntText.text = "Uh-Oh"; tauntText.fontSize = 22; break; } } else if (scoreF >= (highScore - 3f) && scoreF < highScore) { // below highscore by 3 int x = Random.Range(1, 3); // 2 taunts switch (x) { case 1: tauntText.text = "So close!"; tauntText.fontSize = 22; break; case 2: tauntText.text = "A new highscore.. almost"; tauntText.fontSize = 20; break; } } else if (scoreF >= 15) { // above or equal to 15 seconds int x = Random.Range(1, 3); // 2 taunts switch (x) { case 1: tauntText.text = "Give it one more go"; tauntText.fontSize = 22; break; case 2: tauntText.text = "You can do better"; tauntText.fontSize = 22; break; } } z = GameObject.Find("HighscoreText"); score1 = z.GetComponent <Text> (); score1.text += highScore.ToString("0.00"); } //Video Ad if (totalPlayTime + Mathf.FloorToInt(scoreF) >= 90) { if (HZVideoAd.IsAvailable()) { PlayerPrefs.SetInt("Total Time Played Since Last ad", 0); HZVideoAd.Show(); } } else { PlayerPrefs.SetInt("Total Time Played Since Last ad", totalPlayTime + Mathf.FloorToInt(scoreF)); } } } }
// 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(); } } }