Exemple #1
0
    public void deathCheck()
    {
        if (power <= 0)
        {
            death            = true;
            afterDeathDelay += Time.deltaTime;
            deathEffectParticle.SetActive(true);


            generalMovementScript.speed = 0f;
            pauseButton.SetActive(false);
            //VideoReq = true;

            soundManager soundManagerScript = GetComponent <soundManager>();
            soundManagerScript.openDieSound();

            if (afterDeathDelay >= 2f)
            {
                if (AdManagerScript.rewardBasedVideo.IsLoaded() && VideoReq == true)
                {
                    watchVideoPanel.SetActive(true);
                    IsCountdownStarted = true;
                }
                else//video not loaded or watched once
                {
                    watchVideoPanel.SetActive(false);
                    Debug.Log("Game Over!");
                    //death here & end game menu appears
                    bestScoreText.text = "Best" + "\n" + ((long)PlayerPrefs.GetFloat("highscore")).ToString();
                    //new highscore, show it.
                    powerBarObj.SetActive(false);

                    Color newColor = new Color(scoreBg.color.r, scoreBg.color.g, scoreBg.color.b, 0f);
                    scoreBg.color = newColor;

                    endGamePanelActive = true;
                    endGameMenuPanel.SetActive(true);
                }
            }
        }
    }