60 lines
1.5 KiB
C#
60 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
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 Progress 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.Get<MinigameIndex>("minigameIndex"));
|
|
|
|
thumbnail.sprite = minigame.thumbnail;
|
|
title.text = minigame.title;
|
|
highscore.text = $"Topscore: {minigameProgress.Get<List<Score>>("highestScores")[0].scoreValue}";
|
|
button.onClick.AddListener(selectActivity);
|
|
}
|
|
}
|