Beispiel #1
0
        // Program Menu Functionality
        public static void MainMenu()
        {
            // Program Menu Dialog
            while (true)
            {
                // Checks state of save file
                FileInfo f  = new FileInfo(path);
                long     s1 = f.Length;

                Console.Clear();
                Console.Write("Welcome to \"Escape of the Mole Men.\"" +
                              "\nWould you like to start a new game or continue from a previous save?\n" +
                              "\n1. New Game" +
                              "\n2. Continue\n\n" +
                              "Type a number to make your decision: ");

                // Saves choice as string variable, normalizes content
                string gameChoice = Console.ReadLine().Replace(" ", "");

                // Starts new game or loads up recent checkpoint using code from Save.txt
                if (gameChoice == "1")
                {
                    Console.Clear();
                    File.WriteAllText(path, String.Empty);
                    Program.Save("1");
                    Intro.IntroMain();
                    break;
                }
                else if (gameChoice == "2" && s1 != 0)
                {
                    Console.Clear();
                    Load(path);
                    break;
                }
                else if (gameChoice == "2" && s1 == 0)
                {
                    Console.Clear();
                    Console.WriteLine("No saved game currently exists.");
                    Cont();
                }
            }
        }
Beispiel #2
0
        // Reads checkpoint code from save file and loads respective scene
        private static void Load(string path)
        {
            string code = File.ReadAllLines(@path).Last();

            // Switch statement contains "table of contents" for story to load from
            switch (code)
            {
            case "1":
                Intro.IntroMain();
                break;

            case "2A":
                Intro.IntroPart2A();
                break;

            case "2B":
                Intro.IntroPart2B();
                break;

            default:
                break;
            }
        }