示例#1
0
    public async void Setup()
    {
        Leaderboard = GetNode <LeaderBoard>(leaderboardPath);
        NameField   = GetNode <Label>(namePath);
        TimeField   = GetNode <Label>(timePath);
        BestField   = GetNode <Label>(bestPath);
        RankField   = GetNode <Label>(rankPath);
        // Exact
        GetNode <Label>(chapterNamePath).Text = $"Chapter {(int) Global.Chapter} - {Global.Chapter.ToString()}";
        int centiseconds = (int)(100 * Global.Time);

        InfoHeader.TimeString(centiseconds);
        NameField.Text = Global.PlayerDisplayName;
        TimeField.Text = InfoHeader.TimeString(centiseconds);
        BestField.Text = "?:??.??";
        RankField.Text = "??";
        // Exit early if not online
        if (!Global.Online)
        {
            Leaderboard.ShowNotAllowed();
            return;
        }
        // Optimistic Leaderboard
        Scores.ChapterScore score = Scores.Instance.GetCachedChapterScore(Global.Chapter);
        score?.ForceInsertLine(Global.PlayerDisplayName, centiseconds);
        UpdateScoreBoard(score);
        // Delayed Leaderboard
        if (centiseconds >= 100 && Global.PlayerName != "")
        {
            // No chapter can be finished in less than one second
            // We can assume we are actually debugging, and so it should not be sent
            await Scores.Instance.AddScoreLine(Global.Chapter, Global.PlayerName, centiseconds);
        }
        UpdateScoreBoard(await Scores.Instance.GetChapterScore(Global.Chapter, 0));
    }
示例#2
0
 public void UpdateScoreBoard(Scores.ChapterScore score)
 {
     Scores.ScoreLine line = score?.FindPlayer(Global.PlayerName);
     if (line != null)
     {
         BestField.Text = InfoHeader.TimeString(line.Time);
         RankField.Text = line.Rank.ToString();
     }
     Leaderboard.UpdateLeaderBoard(score);
 }
示例#3
0
    public void UpdateLeaderBoard(Scores.ChapterScore score)
    {
        if (score == null)
        {
            return;
        }
        this.QueueFreeChildren();
        PackedScene template = ResourceLoader.Load <PackedScene>(lineTemplate);

        foreach (Scores.ScoreLine values in score.Scores)
        {
            RankLine line = (RankLine)template.Instance();
            AddChild(line);
            line.SetLine(values.Rank, values.Name, values.Time);
        }
    }