Files
unity-application/Assets/Accounts/Scripts/UserProgressScreen.cs
2023-05-04 09:09:49 +00:00

83 lines
1.9 KiB
C#

using TMPro;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// UserProgressScreen scene manager
/// </summary>
public class UserProgressScreen : MonoBehaviour
{
/// <summary>
/// Reference to the current user
/// </summary>
private User user;
/// <summary>
/// UI reference to the username
/// </summary>
public TMP_Text username;
/// <summary>
/// UI reference to the user's avatar
/// </summary>
public Image avatar;
/// <summary>
/// Reference to the courses panel
/// </summary>
public GameObject coursesPanel;
/// <summary>
/// Reference to the minigame panel
/// </summary>
public GameObject minigamesPanel;
/// <summary>
/// Reference to the courses tab button (to set nice color)
/// </summary>
public Image coursesTabButton;
/// <summary>
/// Reference to the minigames tab button (to set nice color)
/// </summary>
public Image minigamesTabButton;
/// <summary>
/// Start is called before the first frame update
/// </summary>
void Start()
{
// Assign the current user
PersistentDataController.GetInstance().Load();
user = UserList.GetCurrentUser();
// Set correct displayed items
username.text = user.GetUsername();
avatar.sprite = user.GetAvatar();
DisplayCourses();
}
/// <summary>
/// Switch to displaying the courses
/// </summary>
public void DisplayCourses()
{
coursesPanel.SetActive(true);
coursesTabButton.color = Color.blue;
minigamesPanel.SetActive(false);
minigamesTabButton.color = Color.gray;
}
/// <summary>
/// Switch to displaying the minigames
/// </summary>
public void DisplayMinigames()
{
coursesPanel.SetActive(false);
coursesTabButton.color = Color.gray;
minigamesPanel.SetActive(true);
minigamesTabButton.color = Color.blue;
}
}