AceField/Scripts/UI/GameOverScreen.cs

30 lines
679 B
C#
Raw Normal View History

2024-08-09 07:45:40 +00:00
using System.Linq;
using AceField.Scripts.Logic;
using Godot;
namespace AceField.Scripts.UI;
public partial class GameOverScreen : Control
{
[Export] public Scoreboard Scoreboard;
public override void _Process(double delta)
{
if (!Visible) return;
var data = Scoreboard.GetData(Multiplayer.GetUniqueId());
if (data == null) return;
var place = 1;
var list = Scoreboard.Players.ToList();
list.Sort((a, b) => b.Value.Score.CompareTo(a.Value.Score));
foreach (var item in list)
{
if (Multiplayer.GetUniqueId() == item.Key) break;
place++;
}
GetNode<Label>("CenterContainer/Panel/VBoxContainer/Caption").Text = $"You're in the {place} place";
}
}