Resolve WES-95 "User progress"
This commit is contained in:
59
Assets/Accounts/Scripts/MinigameProgressCard.cs
Normal file
59
Assets/Accounts/Scripts/MinigameProgressCard.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user