Esempio n. 1
0
        // nested if statement
        // another while loop if user chooses invalid input
        public static Boolean Basement()
        {
            Level1  lvlobj    = new Level1();
            Boolean lebutton  = true;
            House   houseobj  = new House();
            Config  configobj = new Config();

            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("You have entered the 1st level. \nThere is a sign as you leave the door that says 'Welcome to Sewerville'. Inside Sewerville you see a floating door. You're unable to reach it but on the ground you find 3 different buttons you can press on which can lower the door. Or you can go back to the house for no reason.");
            Console.ResetColor();
            Console.Write("Which button will you press? Button(1), Button(2), Button(3), House(H) (Q)uit: ");
            string choosebutton = Console.ReadLine().ToUpper();

            //  while loop if user enters <ENTER>
            while (choosebutton == "")
            {
                Console.Write("Which button will you press? Button(1), Button(2), Button(3), House(H) (Q)uit: ");
                choosebutton = Console.ReadLine().ToUpper();
            }

            // another while loop if user enters anything else other than the correect values and <ENTER>
            while (choosebutton != "3" && choosebutton != "H" && choosebutton != "Q" && choosebutton != "1" && choosebutton != "2")

            {
                Console.Write("Which button will you press? Button(1), Button(2), Button(3), House(H) (Q)uit: ");
                choosebutton = Console.ReadLine().ToUpper();
            }
            // do while loop if user chooses a valid value
            do
            {
                switch (choosebutton)
                {
                case "1":

                    Console.BackgroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.WriteLine("You pressed on the first button. You then realized that the button has poison in it. The poison is moving through your body as you panic. After a few seconds, you died.");
                    Console.ResetColor();
                    Environment.Exit(0);
                    break;

                case "2":

                    Console.BackgroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.WriteLine("You pressed on the second button. The door lowered but it was still too high to reach. You notice a green laser right beneath the door. Out of curiosity, you decided to step on the green laser. Suddenly the floating door drops down with insane velocity and crushed you. You died.");
                    Console.ResetColor();
                    Environment.Exit(0);
                    break;

                case "3":

                    Console.BackgroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.WriteLine("You pressed on the third button. The door lowered down to the perfect position. You turned the knob and you see something magical happen. You have teleported to Sewerville");
                    Console.ResetColor();
                    lebutton = false;
                    break;

                case "Q":
                    configobj.GameEnd();
                    break;

                case "H":

                    houseobj.ChooseDoor();
                    Console.BackgroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.WriteLine("You have arrived back at the House doors.");
                    Console.ResetColor();
                    lebutton = false;
                    break;
                }
            }while (lebutton == true);
            // do while loop if user wants to go back to house
            do
            {
                lvlobj.FirstArea();
            }while (lebutton == false);
            return(lebutton);
        }