rabidus-test/Assets/Scripts/LeaderboardWithDateControll...

37 lines
920 B
C#
Raw Permalink Normal View History

2023-10-05 17:56:59 +03:00
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class LeaderboardWithDateController : LeaderboardController
{
public int DaysShow = 30;
protected override void Start()
{
base.Start();
}
protected override void UpdateLeaderboard()
{
_entries.ForEach(x => Destroy(x.gameObject));
_entries.Clear();
_entries = new List<LeaderboardEntry>();
var sortedList = PlayerSetup.Instance.AllPlayers
.Where(y => DateTime.Parse(y.DateTime)
.AddDays(DaysShow) >= DateTime.Now)
.OrderByDescending(x => x.Score)
2023-10-06 16:12:39 +03:00
.ToList();
2023-10-05 17:56:59 +03:00
for (int i = 0; i < sortedList.Count; i++)
{
var newEntry = Instantiate(_leaderboardEntryPrefab, _content);
_entries.Add(newEntry);
newEntry.Init(sortedList[i], i);
}
}
}