Ejemplo n.º 1
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;
            }
        }