public static void SavePlayer(PlayerDataOrbs data) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(FilePath, FileMode.Create); formatter.Serialize(stream, data); stream.Close(); }
public static PlayerDataOrbs LoadPlayer() { if (File.Exists(FilePath)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(FilePath, FileMode.Open); PlayerDataOrbs loadedData = formatter.Deserialize(stream) as PlayerDataOrbs; stream.Close(); return(loadedData); } else { SavePlayer(PlayerDataOrbs.DefaultValues); return(PlayerDataOrbs.DefaultValues); } }