public void SelectLevel(int index)
    {
        if (index >= levels.Count)
        {
            index = 0;
        }
        if (index < 0)
        {
            index = levels.Count - 1;
        }

        bool wentDown = index > this.selectedLevelIndex;

        this.selectedLevel = (Level)levels[index];
        selectedLevelIndex = index;

        if (wentDown)
        {
            if (topIndex < selectedLevelIndex - levelListObjects.Length + 1)
            {
                topIndex = selectedLevelIndex - levelListObjects.Length + 1;
                if (topIndex < 0)
                {
                    index = 0;
                }
            }
        }
        else
        {
            if (selectedLevelIndex < topIndex)
            {
                topIndex = selectedLevelIndex;
            }
        }

        for (int i = 0; i < levelListObjects.Length; i++)
        {
            levelListObjects[i].color = unselectedColor;
            if (selectedLevelIndex == i + topIndex)
            {
                levelListObjects[i].color = selectedColor;
            }

            levelListObjects[i].text = ((Level)levels[topIndex + i]).name;
        }

        txtLevelName.text       = selectedLevel.name;
        txtLevelDesc.text       = selectedLevel.description;
        txtLevelDifficulty.text = "Difficulty: " + selectedLevel.difficulty.ToString();

        txtLevelPBScore.text = "Score: " + SaveManagement.GetPersonalBestScore(selectedLevel.sceneName);
        txtLevelPBTime.text  = "Time: " + SaveManagement.GetPersonalBestTime(selectedLevel.sceneName);
    }
Beispiel #2
0
    void ReloadText()
    {
        if (infoWon)
        {
            textStatus.text = "You won.";
        }
        else
        {
            textStatus.text = "You lost.";
        }

        textScore.text = "Score: " + infoScore.ToString();


        string min = ((int)infoTime / (int)60).ToString();
        string sec = ((int)infoTime % (int)60).ToString();

        if (min.Length < 2)
        {
            min = "0" + min;
        }
        if (sec.Length < 2)
        {
            sec = "0" + sec;
        }

        textTime.text = "Time: " + min + ":" + sec;

        textPBScore.text = "Score: " + SaveManagement.GetPersonalBestScore(scene);
        textPBTime.text  = "Time: " + SaveManagement.GetPersonalBestTime(scene);

        if (infoNewBest)
        {
            textPBNewBest.gameObject.SetActive(true);
        }
        else
        {
            textPBNewBest.gameObject.SetActive(false);
        }
    }