This commit is contained in:
Jelle De Geest
2023-04-26 19:04:34 +02:00
parent 172938cec8
commit 47f8b96122
1004 changed files with 60756 additions and 117444 deletions

View File

@@ -40,15 +40,10 @@ public class MinigameActivityScreen : MonoBehaviour
/// </summary>
public TMP_Text controls;
/// <summary>
/// Reference to the users
/// </summary>
public UserList userList;
/// <summary>
/// Reference to the Minigame progress
/// </summary>
private Progress progress;
private PersistentDataController.SavedMinigameProgress progress;
/// <summary>
/// Reference to the users-high-scores container object
@@ -60,12 +55,17 @@ public class MinigameActivityScreen : MonoBehaviour
/// </summary>
public GameObject prefab;
/// <summary>
/// Reference to the ranking title
/// </summary>
public GameObject rankingTitle;
/// <summary>
/// Sets the infopage for a given minigame
/// </summary>
void Start()
{
userList.Load();
PersistentDataController.GetInstance().Load();
GenerateContent();
GenerateHighScores();
}
@@ -109,21 +109,23 @@ public class MinigameActivityScreen : MonoBehaviour
Minigame minigame = minigameList.minigames[index];
List<Tuple<string, Sprite, Score>> allScores = new List<Tuple<string, Sprite, Score>>();
foreach (User user in userList.GetUsers())
foreach (User user in UserList.GetUsers())
{
// Get user's progress for this minigame
progress = user.GetMinigameProgress(minigame.index);
if (progress != null)
{
// Add scores to dictionary
List<Score> scores = progress.Get<List<Score>>("highestScores");
List<Score> scores = progress.highestScores;
foreach (Score score in scores)
{
allScores.Add(new Tuple<string, Sprite, Score>(user.username, user.avatar, score));
allScores.Add(new Tuple<string, Sprite, Score>(user.GetUsername(), user.GetAvatar(), score));
}
}
}
rankingTitle.SetActive(allScores.Count > 0);
// Sort allScores based on Score.scoreValue
allScores.Sort((a, b) => b.Item3.scoreValue.CompareTo(a.Item3.scoreValue));