Hi guys, I’m a bit stuck with my lists and my savings. I want to save the date and time of the first 5 times a player reaches 10/10. After that, they can unlock a new stage in the game. What I have at the moment is this:
void DisplayResults()
{
resultsText.text = "You scored " + numberOfCorrectAnswers + " out 10!";
if (numberOfCorrectAnswers == 10)
{
PlayerData playerData = new PlayerData();
playerData.topScoreDates.Add(DateTime.Now.ToString());
ES2.Save(playerData.topScoreDates, "myFile.txt?tag=myList");
}
}
and this:
public class PlayerData
{
public List<string> topScoreDates;
public PlayerData()
{
topScoreDates = new List<string>();
}
}
And to retrieve the scores I have this:
PlayerData playerData = new PlayerData();
if (ES2.Exists("myFile.txt?tag=myList"))
playerData.topScoreDates = ES2.LoadList<string>("myFile.txt?tag=myList");
foreach (string score in playerData.topScoreDates)
{
print(score);
scoreButton[0].GetComponentInChildren<Text>().text = score;
scoreButton[1].GetComponentInChildren<Text>().text = score;
scoreButton[2].GetComponentInChildren<Text>().text = score;
scoreButton[3].GetComponentInChildren<Text>().text = score;
scoreButton[4].GetComponentInChildren<Text>().text = score;
}
The big problem is that what I am getting on my scoreboard is five times the same date and time. Also, this gets overwritten with each new win.
There is something about the list mechanism that I am obviously not getting. I would be grateful for some pointers. Many thanks!