Пример #1
0
        public static List <string> Userfood = new List <string>();  // creating list of food
        static void Main(string[] args)
        {
            // creating objects
            TestGame progobj      = new TestGame();
            Setup    setupobj     = new Setup();
            Outside  outsideobj   = new Outside();
            House    houseobj     = new House();
            Level1   lvl1obj      = new Level1();
            Level2   lvl2obj      = new Level2();
            Creature creatureobj  = new Creature();
            Creature creature2obj = new Creature();
            Config   configobj    = new Config();

            houseobj.randomfood = new Random();
            houseobj.outsideobj = outsideobj;
            CokeMan  cokeobj  = new CokeMan(3);
            PepsiMan pepsiobj = new PepsiMan(5);
            Level3   lvl3obj  = new Level3();


            // calling the methods
            setupobj.GetName();
            setupobj.AskUser();
            setupobj.UserFoodInput();
            setupobj.Intro();
            outsideobj.OutsideHouse();
            creatureobj.feet = setupobj.GetUserNums;
            creatureobj.AnimalGreeting();
            creatureobj.ChooseStatement();
            outsideobj.DifferentDoors();
            houseobj.setupobj = setupobj;
            houseobj.GetLastName();
            houseobj.HouseLevel();

            // create 5 same methods for the 5 different rooms
            houseobj.ChooseDoor();
            if (configobj.DiceMethod() == true)
            {
                Level1.Basement();
            }
            else
            {
                configobj.GameEnd();
            }
            lvl1obj.FirstArea();
            lvl1obj.FirstArea2();
            lvl1obj.FirstArea3();
            lvl2obj.WhichMonster();
            lvl3obj.Lvl3();
        }
Пример #2
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);
        }