Ejemplo n.º 1
0
        private static void PlayGame()
        {
            byte gameMode;

            do
            {
                Console.Clear();
                Console.SetCursorPosition(0, 0);
                Console.Write("Press 1 for singleplayer or 2 for multiplayer: ");
            }while (!byte.TryParse(Console.ReadLine(), out gameMode) || (gameMode != 1 && gameMode != 2));

            List <string> playersName = (InputPlayersNames(gameMode));

            // SinglePlayer is started when the name of the 2nd player is 'PC'
            if (gameMode == 1)
            {
                playersName.Add("PC");
                secondPlayer = new Robot(new Piece(), playersName[1]);
            }
            else
            {
                secondPlayer = new RealPlayer(new Piece(), playersName[1], 0);
            }

            gameBoard = new Board();
            gameBoard.DrawBoard();

            firstPlayer = new RealPlayer(new Piece(), playersName[0], 0);

            firstPlayer.piece.LoadPiecesPositionsFromBoard(gameBoard);
            secondPlayer.piece.LoadPiecesPositionsFromBoard(gameBoard);

            firstPlayer.Display  = new Position(35, 11);
            secondPlayer.Display = new Position(47, 17);

            secondPlayer.piece.PiecesColor = ConsoleColor.Red;

            PiecePlacing();
            PieceMoving();
        }
Ejemplo n.º 2
0
        private static void PlayGame()
        {
            byte gameMode;
            do
            {
                Console.Clear();
                Console.SetCursorPosition(0, 0);
                Console.Write("Press 1 for singleplayer or 2 for multiplayer: ");
            }
            while (!byte.TryParse(Console.ReadLine(), out gameMode) || (gameMode != 1 && gameMode != 2));

            List<string> playersName = (InputPlayersNames(gameMode));

            // SinglePlayer is started when the name of the 2nd player is 'PC'
            if (gameMode == 1)
            {
                playersName.Add("PC");
                secondPlayer = new Robot(new Piece(), playersName[1]);
            }
            else
            {
                secondPlayer = new RealPlayer(new Piece(), playersName[1], 0);
            }

            gameBoard = new Board();
            gameBoard.DrawBoard();

            firstPlayer = new RealPlayer(new Piece(), playersName[0], 0);

            firstPlayer.piece.LoadPiecesPositionsFromBoard(gameBoard);
            secondPlayer.piece.LoadPiecesPositionsFromBoard(gameBoard);

            firstPlayer.Display = new Position(35, 11);
            secondPlayer.Display = new Position(47, 17);

            secondPlayer.piece.PiecesColor = ConsoleColor.Red;

            PiecePlacing();
            PieceMoving();
        }