コード例 #1
0
ファイル: Program.cs プロジェクト: Iouie/CMDPromptGame
        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
ファイル: House.cs プロジェクト: Iouie/CMDPromptGame
        // continue the story and asking user which door to choose
        public Boolean ChooseDoor()
        {
            Boolean choosetheDoor = true;

            //setupobj.UserFoodInput();
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Blue;

            Console.WriteLine("There are 5 doors in front of you. One of them has a sign saying UP and the other is saying DOWN and the other 3 are LEFT, RIGHT, and CHINA.");
            Console.ResetColor();
            Console.Write("Which door will you choose?  (U)Heaven (D)Hell (L)Left (R)Right (C) China (O) Outside (Q)Quit to quit: ");
            string whichDoor = Console.ReadLine().ToUpper();
            string something = setupobj.GetFood[randomfood.Next(0, setupobj.GetFood.Count)];

            // while loop if player chooses <ENTER> for value
            while (whichDoor == "")
            {
                Console.Write("Which door will you choose?  (U)Heaven (D)Hell (L)Left (R)Right (C) China (O) Outside (Q)Quit to quit: ");
                whichDoor = Console.ReadLine().ToUpper();
            }
            // while loop if user enters anything else other than correct value and <ENTER>
            while (whichDoor != "D" && whichDoor != "Q" && whichDoor != "U" && whichDoor != "L" && whichDoor != "R" && whichDoor != "C" && whichDoor != "O")
            {
                Console.Write("Which door will you choose?  (U)Heaven (D)Hell (L)Left (R)Right (C) China (O) Outside (Q)Quit to quit: ");
                whichDoor = Console.ReadLine().ToUpper();
            }
            // do while loop which allows player to explore each door
            do
            {
                switch (whichDoor)
                {
                case "U":
                    Console.BackgroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.WriteLine("You chose to go " + whichDoor + "." + "\nThe door leads you up and up and finally stops. You entered the room. The room is filled with disney posters on the walls and figurines of the floor and some food on the floor. \nThere is also a large screen TV with the movie UP being played. You see nothing else and decided to leave the door. \nAs you leave the door you see " + something + " lying on the floor.");
                    Console.ResetColor();
                    return(ChooseDoor());

                case "D":
                    Console.BackgroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.WriteLine("You chose to go " + whichDoor + "." + "\nThe door is locked and it requires a key. There is a sign to the left saying roll 2 dies and get a 4 or higher to unlock the door. \nSuddenly 2 dies dropped on the ground. You picked them up and rolled them. ");
                    Console.ResetColor();
                    choosetheDoor = false;
                    break;

                case "L":
                    Console.BackgroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.WriteLine("You chose to go " + whichDoor + "." + "\nYou opened the door which said LEFT. Inside, you see an empty classroom with a lot of tables and chairs. In each table, there were malfunctioned robots sitting on a chair. \nAs you look around, you see a chalkboard and lots of souvenirs stuck on the board. You wanted to pick one but somewhere in your mind you felt it was dangerous so you leave the souvenirs on the board and eventually leave the room. \n You accidently stepped on " + something + " before you left the room.");
                    Console.ResetColor();
                    return(ChooseDoor());

                case "R":
                    Console.BackgroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.WriteLine("You chose to go " + whichDoor + "." + "\nYou opened the door which said RIGHT. The roof is lit up with bright colors which made it look the sun. On the ground you see a massive civilization of what seems to be of elves. \nYou took a step forward and you heard a crack sound. You look below your shoes and saw hundreds of dead elves stuck on it. \nWithout hesitation, the entire population of elves threw" + something + " on you. You couldn't take it anymore and had to leave the room.");
                    Console.ResetColor();
                    return(ChooseDoor());

                case "C":
                    Console.BackgroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.WriteLine("You chose to go " + whichDoor + "." + "\nYou opened the door which said CHINA. The door magically teleports you to the middle of somewhere which looks like a battlefield. On one side, you see chinese people which were wearing red and on the other blue. This looks like some type of war. \nYou see both sides charging at each other and you had nowhere else to go. Suddenly the sky rains down the light upon you and teleported you back to the doors.");
                    Console.ResetColor();
                    return(ChooseDoor());

                case "Q":
                    Console.BackgroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.WriteLine("You decided to quit the game.");
                    Environment.Exit(0);
                    break;

                case "O":                          // if player wanted to go outside
                    Console.BackgroundColor = ConsoleColor.White;
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.WriteLine("You decided to go back outside.");
                    outsideobj.DifferentDoors();
                    ChooseDoor();

                    break;
                }
            }while (choosetheDoor == true);

            // player chooses the right door and enters level1
            do
            {
                Level1.Basement();
            }while (whichDoor == "D");


            return(choosetheDoor);
        }
コード例 #3
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);
        }