Example #1
0
    void  FixedUpdate()
    {
        //вывод сообщений
        Gold_txt.text = "Gold :" + PlayerPrefs.GetInt("gold").ToString();
        Score.text    = "Score :" + SCORE.ToString();
        //сохранение в фаил
        if (SCORE > HighScore)
        {
            NewRecord = true;
            HighScore = SCORE;
            PlayerPrefs.SetInt("records", HighScore);
        }
        if (damage == 1 && shield > 0)
        {
            shield = shield - damage;
            damage = 0;
        }
        if (shield == 0 && life > 0 && S > 0)
        {
            GetComponent <SpriteRenderer>().sprite = sprites[0];
            shield_Hp++;

            if (shield_Hp == 1000)
            {
                GetComponent <SpriteRenderer>().sprite = sprites[2];
                shield_Hp = 0;
                shield    = 1;
            }
        }
        if (damage == 1 && shield == 0)
        {
            life   = life - damage;
            damage = 0;
        }
        if (life == 0)
        {
            GetComponent <SpriteRenderer>().sprite = sprites[1];
            lose           = true;
            Time.timeScale = 0f;
            Objects[0].SetActive(true);
            Objects[1].SetActive(false);
            AudioDeath.Play();
        }
    }
Example #2
0
    void Awake()
    {
        if (S == null)
        {
            S = this; // Set the private singleton
        }
        else
        {
            Debug.LogError("ERROR: ScoreManager.Awake(): S is already set!");
        }

        // Check for a high score in PlayerPrefs
        if (PlayerPrefs.HasKey("HeroHighScore"))
        {
            _HIGH_SCORE = PlayerPrefs.GetInt("HeroHighScore");
        }

        scoreText.text     = "Score: " + SCORE.ToString();
        highscoreText.text = "Highscore: " + _HIGH_SCORE.ToString();
    }
Example #3
0
 void AddPoints(int point)
 {
     _score        += point;
     scoreText.text = "Score: " + SCORE.ToString();
 }