示例#1
0
文件: Jugar.cs 项目: a52/Dominos
        public void Execute()
        {
            Domain.Model.Player player = new Domain.Model.Player();
            Console.BackgroundColor = ConsoleColor.Blue;
            Console.ForegroundColor = ConsoleColor.Yellow;

            Console.Clear();

            ConsoleKeyInfo cki;
            // Prevent example from ending if CTL+C is pressed.
            Console.TreatControlCAsInput = true;

            // Console.WriteLine("Press any combination of CTL, ALT, and SHIFT, and a console key.");
            Console.WriteLine("Press the Escape (Esc) key to quit: \n");
            do
            {
                ShowMenu();

                cki = Console.ReadKey();
                Console.Clear();

                switch (cki.Key)
                {
                    case ConsoleKey.F1:
                        if (player.IsActive)
                            DibujarMisFichas(player);
                        else Console.WriteLine("Favor seleccionar usuario ");
                        break;

                    case ConsoleKey.F2:
                        if (player.IsActive)
                            DibujarTablero();
                        else Console.WriteLine("Favor seleccionar usuario ");
                        break;

                    case ConsoleKey.F4:
                        player = SelectPlayer();
                        break;

                    default:
                        break;
                }

            } while (cki.Key != ConsoleKey.Escape);
        }
示例#2
0
文件: Jugar.cs 项目: a52/Dominos
        private Domain.Model.Player SelectPlayer()
        {
            Console.WriteLine("Seleccione Usuario: ");
            for (int i = 0; i < game.Players.Count; i++)
                Console.WriteLine("{0} - {1}", i, game.Players[i].PlayerName);

            Domain.Model.Player pl = new Domain.Model.Player();

            do
            {
                ConsoleKeyInfo cki = Console.ReadKey();
                if (char.IsNumber(cki.KeyChar))
                    if (int.Parse(cki.KeyChar.ToString()) < game.Players.Count)
                        pl = game.Players[int.Parse(cki.KeyChar.ToString())];

                if (string.IsNullOrEmpty(pl.PlayerName))
                    Console.WriteLine("Usuario especificado es incorrecto.");

            } while (string.IsNullOrEmpty(pl.PlayerName));

            return pl;
        }