Resolve WES-117 "Persistent data handling"
This commit is contained in:
@@ -10,11 +10,6 @@ using UnityEngine.UI;
|
||||
/// </summary>
|
||||
public class UserProgressScreen : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference to the userlist
|
||||
/// </summary>
|
||||
public UserList userList;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the current user
|
||||
/// </summary>
|
||||
@@ -112,12 +107,12 @@ public class UserProgressScreen : MonoBehaviour
|
||||
void Start()
|
||||
{
|
||||
// Assign the current user
|
||||
userList.Load();
|
||||
user = userList.GetCurrentUser();
|
||||
PersistentDataController.GetInstance().Load();
|
||||
user = UserList.GetCurrentUser();
|
||||
|
||||
// Set correct displayed items
|
||||
username.text = user.username;
|
||||
avatar.sprite = user.avatar;
|
||||
username.text = user.GetUsername();
|
||||
avatar.sprite = user.GetAvatar();
|
||||
// TODO: implement total playtime
|
||||
//playtime.text = $"Totale speeltijd: {user.playtime.ToString("0.00")}";
|
||||
|
||||
@@ -126,9 +121,10 @@ public class UserProgressScreen : MonoBehaviour
|
||||
|
||||
int i = 0;
|
||||
// Display courses
|
||||
coursesContainer.SetActive(user.courses.Count > 0);
|
||||
emptyCourses.SetActive(user.courses.Count <= 0);
|
||||
foreach (Progress courseProgress in user.courses)
|
||||
var courses = user.GetCourses();
|
||||
coursesContainer.SetActive(courses.Count > 0);
|
||||
emptyCourses.SetActive(courses.Count <= 0);
|
||||
foreach (var courseProgress in courses)
|
||||
{
|
||||
// Create instance of prefab
|
||||
GameObject instance = GameObject.Instantiate(courseCardPrefab, coursesContainer.transform.Find("Viewport").Find("Content").transform);
|
||||
@@ -142,13 +138,14 @@ public class UserProgressScreen : MonoBehaviour
|
||||
// Store reference to background so we can apply fancy coloring
|
||||
Image background = instance.GetComponent<Image>();
|
||||
background.color = Color.gray;
|
||||
activities.Add(Tuple.Create(background, (int)courseProgress.Get<CourseIndex>("courseIndex")));
|
||||
activities.Add(Tuple.Create(background, (int)courseProgress.courseIndex));
|
||||
}
|
||||
|
||||
// Display minigames
|
||||
minigamesContainer.SetActive(user.minigames.Count > 0);
|
||||
emptyMinigames.SetActive(user.minigames.Count <= 0);
|
||||
foreach (Progress minigameProgress in user.minigames)
|
||||
var minigames = user.GetMinigames();
|
||||
minigamesContainer.SetActive(minigames.Count > 0);
|
||||
emptyMinigames.SetActive(minigames.Count <= 0);
|
||||
foreach (var minigameProgress in minigames)
|
||||
{
|
||||
// Create instance of prefab
|
||||
GameObject instance = GameObject.Instantiate(minigameCardPrefab, minigamesContainer.transform.Find("Viewport").Find("Content").transform);
|
||||
@@ -162,7 +159,7 @@ public class UserProgressScreen : MonoBehaviour
|
||||
// Store reference to background so we can apply fancy coloring
|
||||
Image background = instance.GetComponent<Image>();
|
||||
background.color = Color.gray;
|
||||
activities.Add(Tuple.Create(background, (int)minigameProgress.Get<MinigameIndex>("minigameIndex")));
|
||||
activities.Add(Tuple.Create(background, (int)minigameProgress.minigameIndex));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +180,7 @@ public class UserProgressScreen : MonoBehaviour
|
||||
|
||||
selectedActivity = newActivity;
|
||||
activities[selectedActivity].Item1.color = Color.blue;
|
||||
if (selectedActivity < user.courses.Count)
|
||||
if (selectedActivity < user.GetCourses().Count)
|
||||
{
|
||||
// TODO: create a better graph
|
||||
//DisplayCourseGraph((CourseIndex)activities[selectedActivity].Item2);
|
||||
@@ -211,9 +208,9 @@ public class UserProgressScreen : MonoBehaviour
|
||||
/// <param name="minigameIndex">Index of the minigame</param>
|
||||
private void DisplayMinigameGraph(MinigameIndex minigameIndex)
|
||||
{
|
||||
Progress progress = user.GetMinigameProgress(minigameIndex);
|
||||
List<Score> latestScores = progress.Get<List<Score>>("latestScores");
|
||||
List<Score> highestScores = progress.Get<List<Score>>("highestScores");
|
||||
var progress = user.GetMinigameProgress(minigameIndex);
|
||||
List<Score> latestScores = progress.latestScores;
|
||||
List<Score> highestScores = progress.highestScores;
|
||||
if (0 < highestScores.Count)
|
||||
{
|
||||
PlotGraph(latestScores.ConvertAll<double>((s) => (double)s.scoreValue), highestScores[0].scoreValue);
|
||||
|
||||
Reference in New Issue
Block a user