コード例 #1
0
ファイル: HZVideoAd.cs プロジェクト: bigrocketgames/sd-full
 public static void initReceiver()
 {
     if (_instance == null) {
       GameObject receiverObject = new GameObject("HZVideoAd");
       DontDestroyOnLoad(receiverObject);
       _instance = receiverObject.AddComponent<HZVideoAd>();
     }
 }
コード例 #2
0
 public void ReplayLevel()
 {
     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);
 }
コード例 #3
0
    public void ShowButton()
    {
        string tag = this.adTag();

        HZShowOptions showOptions = new HZShowOptions();

        showOptions.Tag = tag;

        HZIncentivizedShowOptions incentivizedOptions = new HZIncentivizedShowOptions();

        incentivizedOptions.Tag = tag;
        incentivizedOptions.IncentivizedInfo = "test app incentivized info!";

        HZBannerShowOptions bannerOptions = new HZBannerShowOptions();

        bannerOptions.Tag      = tag;
        bannerOptions.Position = this.bannerPosition;

        HZOfferWallShowOptions offerwallOptions = new HZOfferWallShowOptions();

        offerwallOptions.ShouldCloseAfterFirstClick = offerwallCloseOnFirstClickToggle.isOn;
        offerwallOptions.Tag = tag;

        this.console.Append("Showing " + this.SelectedAdType.ToString() + " with tag: " + tag);
        switch (this.SelectedAdType)
        {
        case AdType.Interstitial:
            HZInterstitialAd.ShowWithOptions(showOptions);
            break;

        case AdType.Video:
            HZVideoAd.ShowWithOptions(showOptions);
            break;

        case AdType.Incentivized:
            HZIncentivizedAd.ShowWithOptions(incentivizedOptions);
            break;

        case AdType.Banner:
            HZBannerAd.ShowWithOptions(bannerOptions);
            break;

        case AdType.Offerwall:
            HZOfferWallAd.ShowWithOptions(offerwallOptions);
            break;
        }
    }
コード例 #4
0
    public static void start(string publisher_id, int options)
    {
    #if !UNITY_EDITOR
    #if UNITY_ANDROID
        HeyzapAdsAndroid.start(publisher_id, options);
    #endif

    #if UNITY_IPHONE
        HeyzapAdsIOS.start(publisher_id, options);
    #endif

        HeyzapAds.initReceiver();
        HZInterstitialAd.initReceiver();
        HZVideoAd.initReceiver();
        HZIncentivizedAd.initReceiver();
    #endif
    }
コード例 #5
0
ファイル: AdManager.cs プロジェクト: aleknikolov11/Maze-Game
 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);
 }
コード例 #6
0
    public void FetchButton()
    {
        string tag = this.adTag();

        this.console.Append("Fetching " + this.SelectedAdType.ToString() + " with tag: " + tag);
        switch (this.SelectedAdType)
        {
        case AdType.Interstitial:
            HZInterstitialAd.Fetch(tag);
            break;

        case AdType.Video:
            HZVideoAd.Fetch(tag);
            break;

        case AdType.Incentivized:
            HZIncentivizedAd.Fetch(tag);
            break;
        }
    }
コード例 #7
0
ファイル: Game.cs プロジェクト: gbdb71/Unity3D-Soccer-Game
    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));
    }
コード例 #8
0
    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);
    }
コード例 #9
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();
    }
コード例 #10
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);
        }
コード例 #11
0
    public override void FetchAds(AdsElement type)
    {
        if (!AdsController.NoAds)
        {
            switch (type.type)
            {
            case AdsType.Banner:
                break;

            case AdsType.Interstitial:
                HZInterstitialAd.Fetch(type.name);
                break;

            case AdsType.Video:
                HZVideoAd.Fetch(type.name);
                break;

            case AdsType.RewardedVideo:
                HZIncentivizedAd.Fetch(type.name);
                break;
            }
        }
    }
コード例 #12
0
 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);
     }
 }
コード例 #13
0
ファイル: Maze56.cs プロジェクト: aleknikolov11/Maze-Game
    void Start()
    {
        mapButtonClicked = false;
        bestTimeVariable = "bestTimeLevel56";
        currentShardsForLevelVariable = "currentShardsForLevel56";
        currentMapVariable            = "mapLevel56";
        currentLevel = 56;
        localLevel   = 6;
        HeyzapAds.Start("3a045a04722e168baefdd3eeff198305", HeyzapAds.FLAG_NO_OPTIONS);
        HZVideoAd.Fetch();
        HZIncentivizedAd.Fetch();
        map = new int[11, 11] {
            { 2, 3, 3, 3, 2, 4, 1, 3, 3, 3, 2 }, { 3, 2, 3, 2, 2, 2, 3, 4, 3, 1, 2 }, { 3, 2, 2, 2, 2, 3, 3, 2, 2, 3, 4 }, { 1, 4, 3, 2, 2, 3, 3, 3, 3, 2, 1 },
            { 3, 2, 2, 2, 2, 3, 2, 2, 3, 4, 3 }, { 3, 2, 2, 2, 2, 3, 2, 3, 2, 1, 2 }, { 3, 2, 2, 3, 4, 1, 2, 4, 2, 2, 4 }, { 3, 3, 4, 2, 3, 3, 2, 3, 3, 2, 1 },
            { 1, 2, 3, 2, 3, 3, 2, 3, 3, 3, 3 }, { 2, 3, 1, 2, 3, 2, 2, 1, 2, 2, 3 }, { 4, 3, 1, 3, 4, 4, 4, 2, 3, 3, 2 }
        };
        rotations = new int[11, 11] {
            { 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1 }, { 1, 0, 0, 1, 3, 1, 1, 1, 0, 1, 2 }, { 1, 3, 1, 3, 1, 1, 1, 0, 1, 1, 2 }, { 0, 3, 1, 0, 2, 1, 1, 1, 1, 3, 2 },
            { 1, 0, 2, 3, 1, 1, 3, 2, 1, 2, 1 }, { 1, 3, 1, 0, 2, 1, 0, 0, 2, 0, 2 }, { 1, 0, 2, 1, 1, 3, 2, 2, 0, 2, 2 }, { 1, 1, 2, 3, 0, 0, 1, 1, 1, 0, 2 },
            { 0, 2, 1, 0, 0, 0, 2, 1, 1, 1, 1 }, { 3, 0, 2, 3, 0, 1, 0, 2, 3, 2, 1 }, { 1, 0, 3, 0, 3, 0, 0, 3, 0, 0, 2 }
        };
        MazeGenerator.instance.mazeGenerator(map, rotations, 11);
        Ball.transform.position   = start;
        Ball.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
        Ball.SetActive(true);
        Instantiate(FinishParticleSystem, finish, Quaternion.identity);
        if (!PlayerPrefs.HasKey(currentShardsForLevelVariable))
        {
            PlayerPrefs.SetInt(currentShardsForLevelVariable, 0);
        }

        currentSpawnsLeft = 3 - PlayerPrefs.GetInt(currentShardsForLevelVariable);
        firstX            = secondX = firstY = secondY = 100f;
        while (currentSpawnsLeft > 0)
        {
            int   randX  = Random.Range(0, 11);
            int   randZ  = Random.Range(0, 11);
            float Shardx = (float)randX + 0.05f;
            float Shardy = (float)randZ + 0.05f;
            if (Shardx != start.x && Shardx != finish.x && Shardy != start.z && Shardy != finish.z && Shardx != (firstX + 0.05f) && Shardx != (secondX + 0.05f) && Shardy != (firstY + 0.05f) && Shardy != (secondY + 0.05f))
            {
                Instantiate(Shard, new Vector3((float)randX, 0.15f, (float)randZ), Quaternion.identity);
                currentSpawnsLeft--;
                if (currentSpawnsLeft == 2)
                {
                    firstX = Shardx;
                    firstY = Shardy;
                }
                if (currentSpawnsLeft == 1)
                {
                    secondX = Shardx;
                    secondY = Shardy;
                }
            }
        }
        if (!PlayerPrefs.HasKey(bestTimeVariable))
        {
            bestTimeScore.text = "00:00";
        }
        else
        {
            bestTimeScore.text = ((int)(PlayerPrefs.GetFloat(bestTimeVariable) / 60f)).ToString("00") + ":" + ((int)(PlayerPrefs.GetFloat(bestTimeVariable) % 60f)).ToString("00");
        }
        currentTime           = 0f;
        shardsText.text       = PlayerPrefs.GetInt("currentShards").ToString();
        currentTimeText.text  = "";
        currentTimeScore.text = "";
        bestTimeScore.text    = "";
        timeString            = "";
        gameOver = false;
    }
コード例 #14
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();
    }
コード例 #15
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
    }
コード例 #16
0
 public void FetchVideoAd()
 {
     HZVideoAd.Fetch();
 }
コード例 #17
0
    void Start()
    {
        //Exit text not showing
        exitTextRenderer = GameObject.Find("ExitOverlay").GetComponent <CanvasRenderer> ();
        exitTextRenderer.SetAlpha(0f);
        exitTextRenderer.GetComponentInChildren <Text>().GetComponent <CanvasRenderer> ().SetAlpha(0f);

        HeyzapAds.Start("74ffa522d9d72b0bf95f103d3c142b2f", HeyzapAds.FLAG_NO_OPTIONS);
        HZVideoAd.Fetch();
        if (PlayerPrefs.HasKey("First time playing"))
        {
            GameObject.Find("HowToPlayCanvas").GetComponent <Canvas> ().enabled = false;
        }

        //HeyzapAds.ShowMediationTestSuite();// used for test purposes


        if (PlayerPrefs.HasKey("Total Time Played Since Last ad"))
        {
            totalPlayTime = PlayerPrefs.GetInt("Total Time Played Since Last ad");
        }

        GameObject temp = GameObject.Find("SoundToggleButton");

        soundToggleButton = temp.GetComponent <Button> ();
        highScore         = PlayerPrefs.GetFloat("Highscore");
        ShieldPowerup     = GetComponent <AudioSource> ();
        GameObject z = GameObject.Find("HUDCanvas");

        score    = z.GetComponentInChildren <Text>();
        animator = GetComponent <Animator> ();
        //Animation x = animator.GetComponent<Animation> ();
        animator.enabled = false;
        GameObject y = GameObject.Find("GameOverCanvas");

        gameOverCanvas         = y.GetComponent <Canvas> ();
        gameOverCanvas.enabled = false;

        y = GameObject.Find("RemainingFreezesText");
        remainingFreezes      = y.GetComponent <Text> ();
        remainingFreezes.text = freezePowerup.ToString();
        //repulsion powerup
        arrows     = new GameObject[4];
        arrows [0] = GameObject.Find("arrow");
        arrows [1] = GameObject.Find("arrow (1)");
        arrows [2] = GameObject.Find("arrow (2)");
        arrows [3] = GameObject.Find("arrow (3)");

        //disable animation of shield remaining time at first
        GameObject.Find("ShieldCountDownText").GetComponent <Animator> ().enabled = false;
        GameObject.Find("ShieldCountDownText").GetComponent <Text> ().enabled     = false;

        //retrieve last player audio preferences
        int i = PlayerPrefs.GetInt("Audio");

        //1 means it's off, else means it's on
        if (i == 1)
        {
            soundToggleButton.image.sprite = SoundOff;
            soundOn = false;
        }
        else
        {
            soundToggleButton.image.sprite = SoundOn;
            soundOn = true;
        }
    }
コード例 #18
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));
                }
            }
        }
    }
コード例 #19
0
    // 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();
            }
        }
    }
コード例 #20
0
 // Use this for initialization
 void Start()
 {
     HeyzapAds.Start("ecef46611330f64b1c88df6f89c05b63", HeyzapAds.FLAG_NO_OPTIONS);
     HZVideoAd.Fetch();
     HZIncentivizedAd.Fetch();
 }