Пример #1
0
        public static void PrintMenu()
        {
            char choice = '0';

            do
            {
                Console.WriteLine("\n\n\n\n");
                Console.WriteLine("{0,49}", "___________________");
                Console.WriteLine("{0,50}", "|------ Menu -------|");
                Console.WriteLine("{0,50}", "|                   |");
                Console.WriteLine("{0,50}", "|   1. Start Game.  |");
                Console.WriteLine("{0,50}", "|   2. Rules.       |");
                Console.WriteLine("{0,50}", "|   3. Back Story.  |");
                Console.WriteLine("{0,50}", "|   4. About.       |");
                Console.WriteLine("{0,50}", "|   5. Exit.        |");
                Console.WriteLine("{0,50}", "|___________________|");
                Console.WriteLine();
                Console.Write("{0,54}", "Please, enter your choice: ");

                ConsoleKeyInfo keyInfo = Console.ReadKey();
                choice = keyInfo.KeyChar;
                Console.ForegroundColor = ConsoleColor.DarkMagenta;

                switch (choice)
                {
                case '1': Console.Clear(); PrintSubMenu(); break;

                case '2': Console.Clear(); ConsoleRenderer.PrintRules(); break;

                case '3': Console.Clear(); ConsoleRenderer.PrintBackStory(); break;

                case '4': Console.Clear(); ConsoleRenderer.PrintAbout(); break;

                case '5': Console.Clear(); Console.WriteLine("Goodbye!"); break;

                default: Console.Clear(); Console.WriteLine("\nPlease, enter a number between 1 and 5!"); break;
                }
            } while (choice != '5');
        }
Пример #2
0
        private static void StartGame(char[,] body)
        {
            SoundPlayer myPlayer = new SoundPlayer();

            myPlayer.SoundLocation = @"Clip - Star Trek Insurrection OST 4 Not Functioning - Segment1(00_00_01.999-00_00_11.814).wav";
            myPlayer.PlayLooping();

            IRenderer      renderer = new ConsoleRenderer(WorldRows, WorldCols);
            IUserInterface keyboard = Keyboard.Instance();

            Engine gameEngine = new Engine(renderer, keyboard);

            // Events for moving
            keyboard.OnUpPressed += (sender, eventInfo) =>
            {
                gameEngine.MovePlayerShipUp(0);
            };

            keyboard.OnDownPressed += (sender, eventInfo) =>
            {
                gameEngine.MovePlayerShipDown(WorldRows);
            };

            keyboard.OnActionPressed += (sender, eventInfo) =>
            {
                gameEngine.MakePlayerShipFire(gameEngine);
            };

            keyboard.OnMinePressed += (sender, eventInfo) =>
            {
                gameEngine.MakePlayerShipMine(gameEngine);
            };

            Initialize(gameEngine, body);
            gameEngine.Run(WorldCols - 20, WorldRows);
        }