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