public void LoadScores() { //if (firstLoad) FindLastSeed(); Debug.Log("Loading Scores"); Directory.CreateDirectory(Application.persistentDataPath + "/High Scores/"); if (File.Exists(SeedFileName)) { BinaryFormatter binFormatter = new BinaryFormatter(); FileStream file = File.Open(SeedFileName, FileMode.Open); HighScoreSavable data = (HighScoreSavable)binFormatter.Deserialize(file); file.Close(); HighScores = data.highScores; } else { HighScores = new List <HighScore> (); HighScores.Add(new HighScore("Alexis", 20000.0)); HighScores.Add(new HighScore("Khalid", 10000.0)); HighScores.Add(new HighScore("Ryan", 5000.0)); HighScores.Add(new HighScore("Samer", 2500.0)); HighScores.Add(new HighScore("Joe", 1000.0)); SaveScores(); } hasLoaded = true; }
public void SaveScores() { BinaryFormatter binFormatter = new BinaryFormatter(); FileStream file = File.Create(SeedFileName); HighScoreSavable data = new HighScoreSavable(HighScores); binFormatter.Serialize(file, data); file.Close(); }