Resolve WES-117 "Persistent data handling"
This commit is contained in:
@@ -12,12 +12,20 @@ public class BootScreen : MonoBehaviour
|
||||
/// </summary>
|
||||
public TMP_Text errorText;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the list that holds all user avatars
|
||||
/// </summary>
|
||||
public UserAvatarList sprites;
|
||||
|
||||
/// <summary>
|
||||
/// Request authorization and check whether at least 1 webcam is available
|
||||
/// </summary>
|
||||
/// <returns>IEnumerator object</returns>
|
||||
IEnumerator Start()
|
||||
{
|
||||
UserList.AVATARS = sprites.avatars;
|
||||
PersistentDataController.GetInstance().Load();
|
||||
|
||||
yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
|
||||
if (Application.HasUserAuthorization(UserAuthorization.WebCam))
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f",
|
||||
"GUID:63c63e721f65ebb7d871cb9ef49f4752",
|
||||
"GUID:1631ed2680c61245b8211d943c1639a8",
|
||||
"GUID:e83ddf9a537a96b4a804a16bb7872ec1",
|
||||
"GUID:7f2d0ee6dd21e1d4eb25b71b7a749d25"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
|
||||
@@ -17,15 +17,10 @@ public class CourseActivityScreen : MonoBehaviour
|
||||
/// </summary>
|
||||
public CourseList courseList;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the users
|
||||
/// </summary>
|
||||
public UserList userList;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the course progress
|
||||
/// </summary>
|
||||
private Progress progress;
|
||||
private PersistentDataController.SavedCourseProgress progress;
|
||||
|
||||
/// <summary>
|
||||
/// Title Display
|
||||
@@ -66,10 +61,10 @@ public class CourseActivityScreen : MonoBehaviour
|
||||
//slider.value = progressValue;
|
||||
|
||||
// Set progress
|
||||
userList.Load();
|
||||
progress = userList.GetCurrentUser().GetCourseProgress(course.index);
|
||||
PersistentDataController.GetInstance().Load();
|
||||
progress = UserList.GetCurrentUser().GetCourseProgress(course.index);
|
||||
if (progress != null)
|
||||
progressBar.value = progress.Get<float>("courseProgress");
|
||||
progressBar.value = progress.progress;
|
||||
else
|
||||
progressBar.value = 0.0f;
|
||||
}
|
||||
|
||||
@@ -27,11 +27,6 @@ public class CourseMenuScreen : MonoBehaviour
|
||||
/// </summary>
|
||||
public GameObject courseItem;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the users so we can get the current user;
|
||||
/// </summary>
|
||||
public UserList userList;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the courses
|
||||
/// </summary>
|
||||
@@ -42,8 +37,8 @@ public class CourseMenuScreen : MonoBehaviour
|
||||
/// </summary>
|
||||
void Start()
|
||||
{
|
||||
userList.Load();
|
||||
User user = userList.GetCurrentUser();
|
||||
PersistentDataController.GetInstance().Load();
|
||||
User user = UserList.GetCurrentUser();
|
||||
|
||||
// Recent courses
|
||||
List<Tuple<CourseIndex, float>> recentCourses = user.GetRecentCourses();
|
||||
|
||||
@@ -5,11 +5,6 @@ using UnityEngine;
|
||||
/// </summary>
|
||||
public class ListCoursesScreen : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference to the userlist
|
||||
/// </summary>
|
||||
public UserList userList;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the course-list container object
|
||||
/// </summary>
|
||||
@@ -30,8 +25,8 @@ public class ListCoursesScreen : MonoBehaviour
|
||||
/// </summary>
|
||||
void Start()
|
||||
{
|
||||
userList.Load();
|
||||
User user = userList.GetCurrentUser();
|
||||
PersistentDataController.GetInstance().Load();
|
||||
User user = UserList.GetCurrentUser();
|
||||
|
||||
foreach (Course course in courseList.courses)
|
||||
{
|
||||
@@ -42,8 +37,8 @@ public class ListCoursesScreen : MonoBehaviour
|
||||
CourseItem item = instance.GetComponent<CourseItem>();
|
||||
item.course = course;
|
||||
|
||||
Progress progress = user.GetCourseProgress(course.index);
|
||||
item.progress = progress != null ? progress.Get<float>("courseProgress") : 0.0f;
|
||||
var progress = user.GetCourseProgress(course.index);
|
||||
item.progress = progress != null ? progress.progress : 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,19 +6,13 @@ using UnityEngine;
|
||||
/// </summary>
|
||||
public class MainMenuScreen : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Referece to the userlist to check whether an user account is present
|
||||
/// </summary>
|
||||
public UserList userList;
|
||||
|
||||
/// <summary>
|
||||
/// Check on load whether a user is already present,
|
||||
/// if not load the UserCreationScreen scene so the user can create a new account
|
||||
/// </summary>
|
||||
void Awake()
|
||||
{
|
||||
userList.Load();
|
||||
if (!File.Exists(UserList.PATH) || userList.GetUsers().Count <= 0)
|
||||
if (!File.Exists(PersistentDataController.PATH) || UserList.GetUsers().Count <= 0)
|
||||
{
|
||||
SystemController.GetInstance().LoadNextScene("Accounts/Scenes/UserCreationScreen");
|
||||
}
|
||||
|
||||
@@ -40,15 +40,10 @@ public class MinigameActivityScreen : MonoBehaviour
|
||||
/// </summary>
|
||||
public TMP_Text controls;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the users
|
||||
/// </summary>
|
||||
public UserList userList;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the Minigame progress
|
||||
/// </summary>
|
||||
private Progress progress;
|
||||
private PersistentDataController.SavedMinigameProgress progress;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the users-high-scores container object
|
||||
@@ -65,7 +60,7 @@ public class MinigameActivityScreen : MonoBehaviour
|
||||
/// </summary>
|
||||
void Start()
|
||||
{
|
||||
userList.Load();
|
||||
PersistentDataController.GetInstance().Load();
|
||||
GenerateContent();
|
||||
GenerateHighScores();
|
||||
}
|
||||
@@ -109,17 +104,17 @@ public class MinigameActivityScreen : MonoBehaviour
|
||||
Minigame minigame = minigameList.minigames[index];
|
||||
|
||||
List<Tuple<string, Sprite, Score>> allScores = new List<Tuple<string, Sprite, Score>>();
|
||||
foreach (User user in userList.GetUsers())
|
||||
foreach (User user in UserList.GetUsers())
|
||||
{
|
||||
// Get user's progress for this minigame
|
||||
progress = user.GetMinigameProgress(minigame.index);
|
||||
if (progress != null)
|
||||
{
|
||||
// Add scores to dictionary
|
||||
List<Score> scores = progress.Get<List<Score>>("highestScores");
|
||||
List<Score> scores = progress.highestScores;
|
||||
foreach (Score score in scores)
|
||||
{
|
||||
allScores.Add(new Tuple<string, Sprite, Score>(user.username, user.avatar, score));
|
||||
allScores.Add(new Tuple<string, Sprite, Score>(user.GetUsername(), user.GetAvatar(), score));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,6 @@ using UnityEngine.UI;
|
||||
/// </summary>
|
||||
public class UserButton : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference to the user list, so we can extract the current user
|
||||
/// </summary>
|
||||
public UserList userList;
|
||||
|
||||
/// <summary>
|
||||
/// UI reference to the avatar object
|
||||
/// </summary>
|
||||
@@ -32,10 +27,10 @@ public class UserButton : MonoBehaviour
|
||||
/// </summary>
|
||||
void Start()
|
||||
{
|
||||
userList.Load();
|
||||
User user = userList.GetCurrentUser();
|
||||
avatar.sprite = user.avatar;
|
||||
username.text = user.username;
|
||||
PersistentDataController.GetInstance().Load();
|
||||
User user = UserList.GetCurrentUser();
|
||||
avatar.sprite = user.GetAvatar();
|
||||
username.text = user.GetUsername();
|
||||
dropdownBox.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user