Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        instance = this;

        if (PlayerPrefs.HasKey("countOfLeaders"))
        {
            countOfLeaders = PlayerPrefs.GetInt("countOfLeaders");
            DataFileHandler.ReadHighScores(dataFile, leaderNames, leaderScores);
        }
        else
        {
            countOfLeaders = 0;
        }
    }
Exemplo n.º 2
0
    public void ShowScores()
    {
        if (PlayerPrefs.HasKey("countOfLeaders"))
        {
            countOfLeaders = PlayerPrefs.GetInt("countOfLeaders");

            string[] names  = new string[leaderboardSize];
            int[]    scores = new int[leaderboardSize];
            DataFileHandler.ReadHighScores(dataFile, names, scores);

            for (int i = 0; i < leaderboardSize; i++)
            {
                if (i < countOfLeaders)
                {
                    string numeration;
                    if (i + 1 < 10)
                    {
                        numeration = "  " + (i + 1).ToString() + ".  ";
                    }
                    else
                    {
                        numeration = (i + 1).ToString() + ".  ";
                    }
                    leaderNamesTexts[i].text  = numeration + names[i].ToString();
                    leaderScoresTexts[i].text = scores[i].ToString();
                }
                else
                {
                    leaderNamesTexts[i].text  = "";
                    leaderScoresTexts[i].text = "";
                }
            }
        }
        else
        {
            countOfLeaders = 0;
            for (int i = 0; i < leaderboardSize; i++)
            {
                leaderNamesTexts[i].text  = "";
                leaderScoresTexts[i].text = "";
            }
        }
    }