Пример #1
0
    public void save_score(int level)
    {
        int    score    = timerScript.get_levelTime();
        string levelKey = "";

        if (level == 0)
        {
            levelKey = "L0Score";
        }
        else if (level == 1)
        {
            levelKey = "L1Score";
        }
        else if (level == 2)
        {
            levelKey = "L2Score";
        }

        if (levelKey != "")
        {
            if (PlayerPrefs.HasKey(levelKey))
            {
                if (PlayerPrefs.GetInt(levelKey) > score)
                {
                    PlayerPrefs.SetInt(levelKey, score);
                }
            }
            else
            {
                PlayerPrefs.SetInt(levelKey, score);
            }
        }
    }
Пример #2
0
    // Function that dims the light to show Victory message
    void dimLighting()
    {
        if (dimLights && dimAlpha < 0.5f)
        {
            if (timerScript.triggerStatus()) // Stop timer
            {
                timerScript.triggerTimer(false);
            }
            if (minimap.activeSelf) // Turn off minimap
            {
                minimap.SetActive(false);
            }
            if (!saved)
            {
                scoreScript.save_score(level);
                saved = true;
            }
            dimAlpha         += 0.35f * Time.deltaTime;
            dimRenderer.color = new Color(1f, 1f, 1f, dimAlpha);
        }
        else if (dimAlpha >= 0.5f)
        {
            // Screen is now dark, display level complete, score, and cheese rating
            levelComplete.SetActive(true);

            // Set the time on score
            scoreMenu.GetComponent <Transform>().Find("txt_time").GetComponent <Text>().text
                = timerScript.get_levelTimeMinutes() + ":" + timerScript.get_levelTimeSeconds();

            // Update the saved score if necessary
            string levelKey = returnLevelString(level);
            if ((PlayerPrefs.HasKey(levelKey) && PlayerPrefs.GetInt(levelKey) > timerScript.get_levelTime()) ||
                !PlayerPrefs.HasKey(levelKey))
            {
                scoreMenu.GetComponent <Transform>().Find("txt_newhighscore").GetComponent <GameObject>().SetActive(true);
            }

            // Update cheese rating
            setCheeseImages(returnCheeseRating(level, timerScript.get_levelTime()));

            scoreMenu.SetActive(true);
            scoreShown = true;
        }
    }