Пример #1
0
    public void Finish()
    {
        // Player.enabled = false;
        finishScreen.GetComponent <Animator>().SetTrigger(Finish1);
        var lvl        = Global.Level;
        var lvlRating  = GetLevelRating();
        var finishTime = _levelTime;

        sfxManager.PlayFinishSfx();

        if (!PlayerPrefs.HasKey("Level") || PlayerPrefs.GetInt("Level") < lvl || lvl == Global.MaxLevel)
        {
            PlayerPrefs.SetInt("Level", lvl);
        }

        if (!PlayerPrefs.HasKey("Coins" + lvl))
        {
            PlayerPrefs.SetInt("Coins" + lvl, Player.Coins);
        }

        if (!PlayerPrefs.HasKey("CoinsTotal"))
        {
            PlayerPrefs.SetInt("CoinsTotal", Player.Coins);
        }
        else
        {
            PlayerPrefs.SetInt("CoinsTotal", PlayerPrefs.GetInt("CoinsTotal") + Player.Coins);
        }

        if (!PlayerPrefs.HasKey("Time" + lvl))
        {
            PlayerPrefs.SetFloat("Time" + lvl, finishTime);
        }

        if (!PlayerPrefs.HasKey("Rating" + lvl))
        {
            PlayerPrefs.SetInt("Rating" + lvl, lvlRating);
        }

        PlayerPrefs.Save();

        finishCoinsUI.text = Player.Coins.ToString("00");
        finishTimeUI.text  = ShowGameTime(finishTime);
        MakeRatingStars(lvlRating);
    }