void loadHighscores()
 {
     StatsFilesManager sfm = new StatsFilesManager();
     SurvivalHsData data = sfm.loadSurvivalHighscores();
     for (int i = 0; i < data.scores.Count; i++)
     {
         transform.GetChild(i).FindChild("score").GetComponent<Text>().text = data.scores[i].first.ToString();
         string time = Formatter.secondsToClockText(data.scores[i].second);
         transform.GetChild(i).FindChild("time").GetComponent<Text>().text = time;
     }
 }
예제 #2
0
    public void addNewHighscore(int score, int timeSurvived)
    {
        StatsFilesManager sfm = new StatsFilesManager();
        SurvivalHsData currentHighscores = sfm.loadSurvivalHighscores();

        int newScoreIndex = findNewScoreIndex(currentHighscores.scores, score, timeSurvived);
        currentHighscores.scores.Insert(newScoreIndex, new Pair(score, timeSurvived));
        if(currentHighscores.scores.Count > HIGHSCORES_COUNT)
            currentHighscores.scores.RemoveAt(currentHighscores.scores.Count - 1);

        sfm.saveSurvivalHighscores(currentHighscores);
    }
예제 #3
0
    public bool checkQualifiedOnList(int score, int timeSurvived)
    {
        StatsFilesManager sfm = new StatsFilesManager();
        SurvivalHsData currentHighscores = sfm.loadSurvivalHighscores();
        if (currentHighscores.scores.Count > HIGHSCORES_COUNT)
            Debug.LogError("SurvivalHighscores : currentHighscores contains more than " + HIGHSCORES_COUNT + " records!");

        foreach(Pair p in currentHighscores.scores)
        {
            if (p.second < timeSurvived || (p.second == timeSurvived && p.first < score))
               return true;
        }
        return currentHighscores.scores.Count < HIGHSCORES_COUNT;
    }