35 lines
909 B
C#
35 lines
909 B
C#
|
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)
|
||
|
.ToList();
|
||
|
|
||
|
for (int i = 0; i < sortedList.Count; i++)
|
||
|
{
|
||
|
var newEntry = Instantiate(_leaderboardEntryPrefab, _content);
|
||
|
_entries.Add(newEntry);
|
||
|
newEntry.Init(sortedList[i], i);
|
||
|
}
|
||
|
}
|
||
|
}
|