コード例 #1
0
        private void InitializeGameWithStartMenue()
        {
            while (true)
            {
                int pressedKey = StartMenu.ShowStartMenueAndGetPressedKey();

                switch (pressedKey)
                {
                case 1:
                    AddPlayersToGame(StartMenu.ShowSelectNumberOfPlayersMenuAndGetSelectedNumbersOfPlayers());
                    break;

                case 2:
                    AddTargetsToGame(StartMenu.ShosSelectNumberOfTargetsMenueAndGetSelectedNumberOfTargets());
                    break;

                case 3:
                    Grid = Labyrint.GetGrid(StartMenu.ShosSelectSizeMenueAndGetSelectedSizeAsKordinat());
                    break;

                case 4:
                    return;
                }
            }
        }
コード例 #2
0
        public Player(bool defaultValues)
        {
            Points = 0;

            if (defaultValues)
            {
                Symbol = '@';
                Color  = ConsoleColor.Blue;
            }
            else
            {
                // Sätta Foreground-color i stringen(Console.Foregroundcolor = ConsoleColor.Blue  == ConsoleColor.Blue.ToString();
                var ChoosePlayerColor = new List <string> {
                    "Choose your color", ConsoleColor.White.ToString(), ConsoleColor.Yellow.ToString(), ConsoleColor.Cyan.ToString(), ConsoleColor.Magenta.ToString()
                };
                Console.WriteLine("NEW PLAYER");
                StartMenu.PrintMenue(ChoosePlayerColor);


                ConsoleKeyInfo pressedKey;
                do
                {
                    pressedKey = Console.ReadKey(true);
                } while (!StartMenu.ValidKeys().Exists(k => k == pressedKey.Key));
                int playerColor = int.Parse(pressedKey.KeyChar.ToString());
                Console.WriteLine($"You have chosen the color {ChoosePlayerColor[playerColor]}");

                Console.WriteLine("Choose your character");
                string playerSymbol = Console.ReadLine();
                char   symbol       = playerSymbol[0];
                Console.WriteLine($"You have chosen the character {symbol}");
                Thread.Sleep(1500);

                Color  = Enum.Parse <ConsoleColor>(ChoosePlayerColor[playerColor]);
                Symbol = symbol;
            }
        }