/// <summary> /// Create a new save file. /// </summary> public static void SaveGame(SaveFile saveFile) { if (!SaveFileDirectory.Exists) { SaveFileDirectory.Create(); } CurrentSaveFile = saveFile; CurrentSaveFile.Save(); SerializeSaveFile(CurrentSaveFile); }
public static FileInfo[] GetSaveFiles() { if (SaveFileDirectory.Exists) { return(SaveFileDirectory.GetFiles("*.sav*")); } else { SaveFileDirectory.Create(); return(GetSaveFiles()); } }
/// <summary> /// Override a save file. /// </summary> public static void SaveGame(FileInfo fileInfo) { if (!SaveFileDirectory.Exists) { SaveFileDirectory.Create(); } //Remove the extension AND the dot: string fileNameWithoutExtension = fileInfo.Name.Substring(0, fileInfo.Name.Length - 4); CurrentSaveFile = new SaveFile(fileNameWithoutExtension, CurrentSaveFile.PlayerName); CurrentSaveFile.Save(); SerializeSaveFile(CurrentSaveFile); }