public static void addSaveFile() { try { Console.WriteLine("\nWelcome, please create a save file."); Console.Write("\nPlease choose your name: "); string SFname = Console.ReadLine(); StreamWriter sw = new StreamWriter($"{AppDomain.CurrentDomain.BaseDirectory}characters\\{SFname}.json"); Console.Write("Please chose your password: "******"\nSave File Loaded:"); Console.WriteLine("Name: " + objcharacter.Name); Console.WriteLine("Level: " + objcharacter.Level); } catch (Exception e) { Console.WriteLine("Exception: " + e.Message); } }
public void StartGame() { MakeTitles.SFcreation(); SaveFileCreation.addSaveFile(); // case "Cavern": // break; // case "Mansion": // default: // break; // } // var initialCharacter = characterService.LoadInitialCharacter(); // Console.WriteLine($"Adventure : {adventure.Title}"); // Console.WriteLine($"Description : {adventure.Description}"); // Console.WriteLine($"Name : {initialCharacter.Name}"); // Console.WriteLine($"Description : {initialCharacter.Description}"); // } // catch (Exception ex) // { // Console.WriteLine($"Oops! Something went wrong! { ex.Message}"); // } }
public static void loadSaveFile() { Console.WriteLine("\nWelcome, please choose a Save File:"); Console.WriteLine(" "); string path = ($"{AppDomain.CurrentDomain.BaseDirectory}characters"); DirectoryInfo dr = new DirectoryInfo(path); FileInfo[] mFile = dr.GetFiles(); foreach (FileInfo fiTemp in mFile) { Console.WriteLine(Path.GetFileNameWithoutExtension(fiTemp.Name)); } Console.WriteLine(" "); string SFname = Console.ReadLine(); try { var Character = new Character(); var directory = new DirectoryInfo($"{AppDomain.CurrentDomain.BaseDirectory}characters"); var JsonFile = directory.GetFiles($"{SFname}.json"); using StreamReader fi = File.OpenText(JsonFile[0].FullName); Character = JsonConvert.DeserializeObject <Character>(fi.ReadToEnd()); Console.Write("\nPlease Enter Your Password: "******"Wrong Password!" + d.Message); } } catch (Exception sfname) { Console.WriteLine("Exception: " + sfname.Message); } }
static void Main(string[] args) { MakeTitles.MenuTitleScreen(); MakeMenu(); }
public void LoadGame() { MakeTitles.SFLoad(); SaveFileCreation.loadSaveFile(); }