Resolve WES-117 "Persistent data handling"
This commit is contained in:
@@ -76,11 +76,6 @@ public partial class SpellingBeeController : AbstractFeedback
|
||||
/// </summary>
|
||||
private DateTime startTime;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the user list to access the current user
|
||||
/// </summary>
|
||||
public UserList userList;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the current user
|
||||
/// </summary>
|
||||
@@ -204,18 +199,15 @@ public partial class SpellingBeeController : AbstractFeedback
|
||||
bonusTimeText.SetActive(false);
|
||||
|
||||
// Create entry in current user for keeping track of progress
|
||||
userList.Load();
|
||||
user = userList.GetCurrentUser();
|
||||
Progress progress = user.GetMinigameProgress(minigame.index);
|
||||
user = UserList.GetCurrentUser();
|
||||
var progress = user.GetMinigameProgress(minigame.index);
|
||||
if (progress == null)
|
||||
{
|
||||
progress = new Progress();
|
||||
progress.AddOrUpdate<MinigameIndex>("minigameIndex", MinigameIndex.SPELLING_BEE);
|
||||
progress.AddOrUpdate<List<Score>>("highestScores", new List<Score>());
|
||||
progress.AddOrUpdate<List<Score>>("latestScores", new List<Score>());
|
||||
user.minigames.Add(progress);
|
||||
progress = new PersistentDataController.SavedMinigameProgress();
|
||||
progress.minigameIndex = MinigameIndex.SPELLING_BEE;
|
||||
user.AddMinigameProgress(progress);
|
||||
}
|
||||
userList.Save();
|
||||
UserList.Save();
|
||||
|
||||
currentTheme = minigame.themeList.themes[minigame.themeList.currentThemeIndex];
|
||||
//feedback.signPredictor.ChangeModel(currentTheme.modelIndex);
|
||||
@@ -337,12 +329,11 @@ public partial class SpellingBeeController : AbstractFeedback
|
||||
score.time = DateTime.Now.ToString();
|
||||
|
||||
// Save the new score
|
||||
user = userList.GetCurrentUser();
|
||||
Progress progress = user.GetMinigameProgress(minigame.index);
|
||||
var progress = user.GetMinigameProgress(minigame.index);
|
||||
|
||||
// Get the current list of scores
|
||||
List<Score> latestScores = progress.Get<List<Score>>("latestScores");
|
||||
List<Score> highestScores = progress.Get<List<Score>>("highestScores");
|
||||
List<Score> latestScores = progress.latestScores;
|
||||
List<Score> highestScores = progress.highestScores;
|
||||
|
||||
// Add the new score
|
||||
latestScores.Add(score);
|
||||
@@ -352,10 +343,10 @@ public partial class SpellingBeeController : AbstractFeedback
|
||||
highestScores.Sort((a, b) => b.scoreValue.CompareTo(a.scoreValue));
|
||||
|
||||
// Only save the top 10 scores, so this list doesn't keep growing endlessly
|
||||
progress.AddOrUpdate<List<Score>>("latestScores", latestScores.Take(10).ToList());
|
||||
progress.AddOrUpdate<List<Score>>("highestScores", highestScores.Take(10).ToList());
|
||||
progress.latestScores = latestScores.Take(10).ToList();
|
||||
progress.highestScores = highestScores.Take(10).ToList();
|
||||
|
||||
userList.Save();
|
||||
UserList.Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user