Exemplo n.º 1
0
        public static GameState AskNewOrLoad()
        {
            do
            {
                Console.WriteLine("Start a new game or load a save file:");
                Console.WriteLine("1: Start a new game.");
                Console.WriteLine("2: Load save file.");
                var choice = Console.ReadLine();

                if (choice == "1")
                {
                    Console.WriteLine("Are you sure you want to start a new game? (Previous save files will be deleted)");
                    Console.WriteLine("1: Yes");
                    Console.WriteLine("2: No");
                    string confirmation = Console.ReadLine();
                    switch (confirmation)
                    {
                    case "1":
                        Console.WriteLine("Starting a new game...");
                        Thread.Sleep(1500);
                        Console.WriteLine("Your choices will affect the game's story line, so be careful.");
                        Thread.Sleep(1500);
                        Console.WriteLine("The game will save after each chapter. Do not quit in the middle of the chapter or all of your progress will get deleted. The command prompt will notify you when the game is saved.");
                        Thread.Sleep(1500);
                        Console.WriteLine("Press any key to continue.");
                        Console.ReadKey();
                        SavingAndLoading.ClearSaveFile();
                        return(new GameState());

                    case "2":
                        break;

                    default:
                        Console.WriteLine("Invalid input. Try again.");
                        break;
                    }
                }
                else if (new FileInfo("savestate.json").Length > 0 && choice == "2")
                {
                    return(SavingAndLoading.Load());
                }
                else if (new FileInfo("savestate.json").Length == 0)
                {
                    Console.WriteLine("Save file is empty");
                    Console.WriteLine("Starting a new game...");
                    return(new GameState());
                }
                else
                {
                    Console.WriteLine("Invalid input, try again.");
                }
            } while (true);
        }
Exemplo n.º 2
0
        public void StartGame(GameState data)
        {
            #region Chapter1

            while (Correct == false)
            {
                Correct = true;

                Console.Clear();

                Console.WriteLine("Enter your gender please:");

                CheckSaves(data, 1, ref input);

                switch (input)
                {
                case "MALE":
                    data.Gender     = "Male";
                    data.GenderNoun = "Boy";
                    break;

                case "FEMALE":
                    data.Gender     = "Female";
                    data.GenderNoun = "Girl";
                    break;

                case "I":
                    ShowInventory(data);
                    break;

                default:
                    Console.WriteLine("Invalid input, try again.");
                    Correct = false;
                    Thread.Sleep(2000);
                    break;
                }
            }

            data.Inputs.Add(input);

            Correct = false;

            string name = "";

            if (data.ProtagonistName == null)
            {
                Console.WriteLine("Please enter your name:");
                name = Console.ReadLine();
                data.ProtagonistName = name;
            }
            else
            {
                name = data.ProtagonistName;
            }

            Console.WriteLine($"You're a 16 year old {data.GenderNoun} living in a quiet little town with your family. ");
            Thread.Sleep(500);
            Console.WriteLine("You go to a small high school a couple of minutes far from your house. ");
            Console.WriteLine("Tomorrow is the first day of school. You haven't met your friends for a long time.");
            Console.WriteLine("You're excited to see them and have fun with them. ");
            Thread.Sleep(500);
            Console.WriteLine("But what you don't know is that this year is going to be a lot different from the others...");

            Console.WriteLine("===========================================================================================");
            Thread.Sleep(500);

            Console.WriteLine("You woke up early, took a shower and got dressed then you headed to the living room to have breakfast");
            Thread.Sleep(500);
            Console.WriteLine($"Mom: Good morning {data.ProtagonistName}, I didn't need to come wake you up this time, ");
            Console.WriteLine("it seems like you're quite excited to go back to school huh?");
            Thread.Sleep(500);

            while (Correct == false)
            {
                NoStoryText("1: Yes, I am...");

                NoStoryText("2: Not really...");

                Correct = true;

                CheckSaves(data, 2, ref input);

                switch (input)
                {
                case "1":
                    PlayerText($"{data.ProtagonistName}: Yes! I can't wait to meet my friends again I missed them a lot.");

                    Thread.Sleep(500);
                    Console.WriteLine("Mom: I'm sure they missed you too.");
                    Thread.Sleep(500);
                    break;

                case "2":
                    PlayerText($"{data.ProtagonistName}:Not really, I just got bored sitting home all day for like 5 months because of the virus, so maybe school will be interesting? I don't know.");

                    Thread.Sleep(500);
                    Console.WriteLine("Mom: You will have a blast with your friends, I'm sure they missed you.");
                    Thread.Sleep(500);
                    break;

                case "I":
                    ShowInventory(data);
                    break;

                default:
                    Console.WriteLine("Invalid input, try again.");
                    Correct = false;
                    Thread.Sleep(1000);
                    break;
                }
            }

            data.Inputs.Add(input);

            Correct = false;

            Console.WriteLine("Mom: Now now, it's getting late, you better get going.");

            Console.WriteLine($"{data.ProtagonistName}: Yeah, you're right. Imma just grab my phone and head out.");

            NoStoryText("You picked up your phone.");
            data.Inventory.Add("Phone");
            Thread.Sleep(2000);

            Console.WriteLine("This is the end of chapter 1");

            SavingAndLoading.Save(data);

            Console.WriteLine("============================");

            #endregion Chapter1

            Chapter2(data);
        }