using System.Collections.Generic;
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 Progress 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.Get("minigameIndex"));
thumbnail.sprite = minigame.thumbnail;
title.text = minigame.title;
List highscores = minigameProgress.Get>("highestScores");
int score = highscores.Count > 0 ? highscores[0].scoreValue : 0;
highscore.text = $"Topscore: {score}";
button.onClick.AddListener(selectActivity);
}
}