65 lines
1.7 KiB
C#
65 lines
1.7 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
using UnityEngine.UI;
|
|
|
|
/// <summary>
|
|
/// Class to handle minigame progress card display
|
|
/// </summary>
|
|
public class MinigameProgressCard : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// Callback to the UpdateSelection
|
|
/// </summary>
|
|
public UnityAction selectActivity;
|
|
|
|
/// <summary>
|
|
/// Button to place the callback on
|
|
/// </summary>
|
|
public Button button;
|
|
|
|
/// <summary>
|
|
/// Reference to the minigame progress
|
|
/// </summary>
|
|
public PersistentDataController.SavedMinigameProgress minigameProgress;
|
|
|
|
/// <summary>
|
|
/// Reference to the minigame list
|
|
/// </summary>
|
|
public MinigameList minigameList;
|
|
|
|
/// <summary>
|
|
/// UI reference to the minigame thumbnail
|
|
/// </summary>
|
|
public Image thumbnail;
|
|
|
|
/// <summary>
|
|
/// UI reference to the minigame title
|
|
/// </summary>
|
|
public TMP_Text title;
|
|
|
|
/// <summary>
|
|
/// UI reference to the user's highscore
|
|
/// </summary>
|
|
public TMP_Text highscore;
|
|
|
|
/// <summary>
|
|
/// Start is called before the first frame update
|
|
/// </summary>
|
|
void Start()
|
|
{
|
|
Minigame minigame = minigameList.GetMinigameByIndex(minigameProgress.minigameIndex);
|
|
|
|
thumbnail.sprite = minigame.thumbnail;
|
|
title.text = minigame.title;
|
|
button.onClick.AddListener(selectActivity);
|
|
List<Score> highscores = minigameProgress.highestScores;
|
|
if (0 < highscores.Count)
|
|
highscore.text = $"TOPSCORE: {highscores.Max((s) => s.scoreValue)}";
|
|
else
|
|
highscore.text = "(NOG) GEEN TOPSCORE";
|
|
}
|
|
}
|