Пример #1
0
        static void Main(string[] args)
        {
            //Loop conditionals
            bool appRunning  = true;
            bool gameRunning = true;
            //Required instances
            GameMenu         gameMenu         = new GameMenu();
            SmileyGrumpyGame smileyGrumpyGame = new SmileyGrumpyGame();

            //Introduce user to game and display instructions
            smileyGrumpyGame.Intro();
            //Application session
            while (appRunning)
            {
                //Set up game for new round
                smileyGrumpyGame.GameSetUp();
                //Game session
                while (gameRunning)
                {
                    smileyGrumpyGame.GameCycle(ref gameRunning);
                }
                //Display game statistics
                smileyGrumpyGame.GameConclusion();
                //Ask user to play another game
                gameMenu.AskUserPlayAgain(ref gameRunning, ref appRunning);
            }
            //Thank user for playing before closing the application.
            smileyGrumpyGame.Outro();
        }
Пример #2
0
        static void Main(string[] args)
        {
            //Loop conditionals
            bool appRunning  = true;
            bool gameRunning = true;
            //Required Instances
            BullsAndCowsGame bullsAndCowsGame = new BullsAndCowsGame();
            GameMenu         gameMenu         = new GameMenu();

            //Intro to the game with instructions on how to play
            bullsAndCowsGame.Intro();
            //Application session
            while (appRunning)
            {
                //Game set up
                bullsAndCowsGame.GameSetUp();
                //Game session
                while (gameRunning)
                {
                    bullsAndCowsGame.GameCycle(ref gameRunning);
                }
                //Display game statistics
                bullsAndCowsGame.GameConclusion();
                //Ask user to play another game
                gameMenu.AskUserPlayAgain(ref gameRunning, ref appRunning);
            }
            //Thank user for playing before closing the application.
            bullsAndCowsGame.Outro();
        }
Пример #3
0
        static void Main(string[] args)
        {
            //Loop Conditionals
            bool appRunning  = true;
            bool gameRunning = true;
            //Required instances
            RandomRacerGame randomRacerGame = new RandomRacerGame();
            GameMenu        gameMenu        = new GameMenu();

            //Introduce user to game
            randomRacerGame.Intro();
            //Application session
            while (appRunning)
            {
                //Set up a new game round.
                randomRacerGame.GameSetUp();
                //Game session
                while (gameRunning)
                {
                    randomRacerGame.GameCycle(ref gameRunning);
                }
                //Display Score
                randomRacerGame.GameConclusion();
                //Ask user to play another game
                gameMenu.AskUserPlayAgain(ref gameRunning, ref appRunning);
            }
            //Thank user for playing before exiting the application.
            randomRacerGame.Outro();
        }
Пример #4
0
        static void Main(string[] args)
        {
            //Loop Conditionals
            bool appRunning  = true;
            bool gameRunning = true;
            //Required Instances
            MadLibsGame madLibsGame = new MadLibsGame();
            GameMenu    gameMenu    = new GameMenu();

            //Intro to game, tell user instructions
            madLibsGame.Intro();
            while (appRunning)
            {
                //Set up new round of game
                madLibsGame.GameSetUp();
                //Game session
                while (gameRunning)
                {
                    madLibsGame.GameCycle(ref gameRunning);
                }
                //Display results from playing the game
                madLibsGame.GameConclusion();
                //Ask user if they want to play another round.
                gameMenu.AskUserPlayAgain(ref gameRunning, ref appRunning);
            }
            //Thank user for playing before closing the application.
            madLibsGame.Outro();
        }
Пример #5
0
        static void Main(string[] args)
        {
            //Loop conditionals
            bool appRunning  = true;
            bool gameRunning = false;
            bool gamePlaying = false;

            //Required instances
            IGameModel[] gameModels = { new MadLibsGame(),
                                        new BullsAndCowsGame(),
                                        new SmileyGrumpyGame(),
                                        new RandomRacerGame(),
                                        new HangManGame() };
            GameMenu     gameMenu = new GameMenu();
            //Set default value to an instance
            IGameModel gameToPlay = gameModels[0];
            GameSelect gameSelect;

            //Application session
            while (appRunning)
            {
                //Introduce user to collection of games and instruct them to pick an option
                Console.Clear();
                Console.WriteLine("Welcome to my selection of awesome games!" +
                                  "\n\nChoose a game to play or quit the application." +
                                  "\n1 = Mad Libs" +
                                  "\n2 = Bulls and cows" +
                                  "\n3 = Smileys and Grumpys" +
                                  "\n4 = Random Racer" +
                                  "\n5 = HangMan" +
                                  "\n6 = Exit ");
                //User's input will be used to return an enum aswell as use that enum to index the gameModels array
                gameSelect = (GameSelect)(InputValidation.ValidateInput(1, 6) - 1);
                //GameSelect.Exit will always cause out of range exception since its enum value is out of the range of the array
                if (gameSelect == GameSelect.Exit)
                {
                    //Closes the app
                    appRunning  = false;
                    gameRunning = false;
                    gamePlaying = false;
                }
                else
                {
                    //Assign the selected game
                    gameToPlay = gameModels[(int)gameSelect];
                    Console.Clear();
                    //Start intro of the chosen game
                    gameToPlay.Intro();
                    gameRunning = true;
                    gamePlaying = true;
                }
                //Session of the current game
                while (gameRunning)
                {
                    //Set up game for new round
                    gameToPlay.GameSetUp();
                    //Session of the game round
                    while (gamePlaying)
                    {
                        //User plays the game round
                        gameToPlay.GameCycle(ref gamePlaying);
                    }
                    //End session of the game round, usually displaying results
                    gameToPlay.GameConclusion();
                    //Ask user to play another round or return to the game selection screen
                    gameMenu.AskUserPlayAgain(ref gamePlaying, ref gameRunning);
                }
            }
            //Thank user for playing before exiting application.
            Console.Clear();
            Console.WriteLine("Thanks for playing!\nPress enter to exit the application");
            Console.ReadLine();
        }