Пример #1
0
        //Menu Option Desk
        public static void Desk()
        {
            Clear();
            WriteLine("\n There are some things on the desk...a book, a box and some papers.. ");
            WriteLine(" What do you wanna do?\n");
            WriteLine(" 1) Look closer at the book");
            WriteLine(" 2) Look closer at the box");
            WriteLine(" 3) Look closer at the papers");
            WriteLine(" 4) Open the drawer");
            WriteLine(" 5) Go back");
            WriteLine(" 6) Open BackPack\n");

            bool input = true;

            do
            {
                string menuChoice = ReadLine();
                switch (menuChoice)
                {
                case "1":
                    Book();
                    break;

                case "2":
                    SafetyLocker();
                    break;

                case "3":
                    Papers();
                    break;

                case "4":
                    Clear();
                    //Checking for object in both the backpack and the usedObject-file
                    string type = "Light-bulb";
                    if (foundObjects.CheckForObject(type) || foundObjects.CheckForUsedObject(type))
                    {
                        WriteLine("\n The drawer is empty");
                        ReadLine();
                        Desk();
                    }
                    else
                    {
                        //If not found the new object is saved to JSON-file
                        WriteLine("\n There's a light-bulb, could be useful! Let's put it in the backpack.");
                        ReadLine();
                        if (foundObjects.AddObject("Light-bulb", "Gives light when paired together with a lamp", "BathroomLamp"))
                        {
                            Desk();
                        }
                        else
                        {
                            //Handeling error
                            WriteLine(" Couldn't save item to backpack");
                            ReadLine();
                            Desk();
                        }
                    }
                    break;

                case "5":
                    basement.BasementView();
                    break;

                case "6":
                    //Opening Backpack and handeling response
                    string backpackResponse = foundObjects.OpenBackpack();
                    if (backpackResponse == "back")
                    {
                        basement.BasementView();
                    }
                    else
                    {
                        WriteLine("\n Naahh...that didn't work");
                        ReadLine();
                        basement.BasementView();
                    }
                    break;

                default:
                    WriteLine("\n What are you trying to do? That's not a correct input Try again..");
                    input = false;
                    break;
                }
            } while (input == false);
        }
        //Menu Option Bathroom
        public static void BathroomView()
        {
            Clear();
            WriteLine("\n In the light you can have a better look at the bathroom. ");
            WriteLine("\n It's water all over the floor and it seems like it's the tap in the sink that is flushing water. ");
            WriteLine(" ");
            WriteLine(" What do you wanna do?\n");
            WriteLine(" 1) Go to the sink");
            WriteLine(" 2) Check the lamp");
            WriteLine(" 3) Go inside to look at the wall");
            WriteLine(" 4) Look at the floor");
            WriteLine(" 5) Go back to Basement");
            WriteLine(" 6) Open Backpack\n");


            //Looping thru the menu until a valid option in entered and then loading a new function
            bool input = true;

            do
            {
                string menuChoice = ReadLine();
                switch (menuChoice)
                {
                case "1":
                    Sink();
                    break;

                case "2":
                    Clear();
                    WriteLine("\n The lamp gives a good light now.");
                    ReadLine();
                    BathroomView();
                    break;

                case "3":
                    Clear();
                    //Showing diffrent options depending on if wrench is used or not
                    if (!foundObjects.CheckForUsedObject("Wrench"))
                    {
                        WriteLine("\n There is to much water on the floor, need to get rid of that before looking at the wall..");
                        ReadLine();
                        BathroomView();
                    }
                    else
                    {
                        WriteLine("\n Now when the water is gone you can go inside to get a closer look.");
                        WriteLine(" There's something written on the wall in a strange red color..");
                        WriteLine(" It's some numbers..7394..");
                        WriteLine(" The red color...is it..blood?");
                        WriteLine(" Omg...What has happend here?");
                        ReadLine();
                        BathroomView();
                    }
                    break;

                case "4":
                    Clear();
                    //Showing diffrent options depedning on if wrench is used or not
                    if (!foundObjects.CheckForUsedObject("Wrench"))
                    {
                        WriteLine("\n The water is all over the floor...");
                        WriteLine(" When you look down you se a wrench laying beside your feets. Could be useful! It goes in the backpack. ");
                        ReadLine();
                        if (foundObjects.AddObject("Wrench", "A useful tool", "Sink"))
                        {
                            BathroomView();
                        }
                        else
                        {
                            WriteLine("Couldn't save item to backpack.");
                            ReadLine();
                            BathroomView();
                        }
                    }
                    else
                    {
                        WriteLine("\n The water is finnaly gone...there's nothing else on the floor.");
                        ReadLine();
                        BathroomView();
                    }
                    break;

                case "5":
                    basement.BasementView();
                    break;

                case "6":
                    string backpackResponse = foundObjects.OpenBackpack();

                    if (backpackResponse == "back")
                    {
                        BathroomView();
                    }
                    else
                    {
                        Clear();
                        WriteLine("\n Naahh...that didn't work");
                        ReadLine();
                        BathroomView();
                    }
                    break;

                default:
                    WriteLine("\n What are you trying to do? That's not a correct input Try again..");
                    input = false;
                    break;
                }
            } while (input == false);
        }