public void SavePlayerScore(int score) { file = File.Create(highestScorePath); HighestScore highestScore = new HighestScore(); highestScore.highestScore = score; binaryFormatter.Serialize(file, highestScore); file.Close(); }
public int LoadPlayerScore() { if (File.Exists(highestScorePath)) { file = File.Open(highestScorePath, FileMode.Open); HighestScore highestScore = binaryFormatter.Deserialize(file) as HighestScore; file.Close(); return(highestScore.highestScore); } else { HighestScore hS = new HighestScore(); hS.highestScore = 0; SavePlayerScore(hS.highestScore); return(0); } }