Beispiel #1
0
    void Update()
    {
        if (Health.Value == 3f)
        {
            Heart3.SetActive(true);
            Heart2.SetActive(true);
            Heart1.SetActive(true);
        }

        if (Health.Value == 2f)
        {
            Heart3.SetActive(false);
            Heart2.SetActive(true);
            Heart1.SetActive(true);
        }

        if (Health.Value == 1f)
        {
            Heart3.SetActive(false);
            Heart2.SetActive(false);
            Heart1.SetActive(true);
        }
        if (Health.Value <= 0f)
        {
            Heart3.SetActive(false);
            Heart2.SetActive(false);
            Heart1.SetActive(false);
        }
    }
    // Update is called once per frame
    void Update()
    {
        //if (scoreIncreasing) {
        //    scoreCounts += pointPerSecond * Time.deltaTime;
        //}
        //extra heart indicator
        if ((heartCounterText != null) && (HeartCount > 3))
        {
            //heartCounterText.GetComponent<Text>().enabled = true;
            heartCounterText.GetComponent <Text>().text = "x" + HeartCount;
        }
        else
        {
            heartCounterText.GetComponent <Text>().text = "";
        }

        if (scoreCounts > highScoreCounts)
        {
            highScoreCounts = scoreCounts;
            PlayerPrefs.SetFloat("HighScores", highScoreCounts);
        }

        scoreText.text     = "Coins: " + Mathf.Round(scoreCounts);
        highScoreText.text = "High Score: " + Mathf.Round(highScoreCounts);
        gameScore.text     = "" + Mathf.Round(gameScoreCounts);

        if (HeartCount == 3)
        {
            Heart3.SetActive(true);
            Heart2.SetActive(false);
            Heart1.SetActive(false);
            Heart0.SetActive(false);
        }
        else if (HeartCount == 2)
        {
            Heart3.SetActive(false);
            Heart2.SetActive(true);
            Heart1.SetActive(false);
            Heart0.SetActive(false);
        }
        else if (HeartCount == 1)
        {
            Heart3.SetActive(false);
            Heart2.SetActive(false);
            Heart1.SetActive(true);
            Heart0.SetActive(false);
        }
        else if (HeartCount == 0)
        {
            HeartCount = 3;
            Heart3.SetActive(false);
            Heart2.SetActive(false);
            Heart1.SetActive(false);
            Heart0.SetActive(true);

            gameManager.RestartGame();
        }
    }