当前位置: 首页>>代码示例>>C#>>正文


C# Board.DrawBoard方法代码示例

本文整理汇总了C#中Board.DrawBoard方法的典型用法代码示例。如果您正苦于以下问题:C# Board.DrawBoard方法的具体用法?C# Board.DrawBoard怎么用?C# Board.DrawBoard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Board的用法示例。


在下文中一共展示了Board.DrawBoard方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            Match newMatch = new Match();

            Match thisMatch = newMatch.SetupMatch();

            Board gameBoard = new Board();

            Player players = new Player();

            var homeTeamHand = thisMatch.HomeTeam.Hand();
            var awayTeamHand = thisMatch.AwayTeam.Hand();

            gameBoard.DrawBoard(thisMatch);

            //Turn loop
            for (int turn = 1; turn <= 9; turn++)
            {
                Console.WriteLine();
                Console.WriteLine("Start of turn {0}", turn);

                //Assign orders to all players in the Home match
                players.GiveOrders(thisMatch.HomeTeam, homeTeamHand);

                //Assign orders to all players in the away team
                players.GiveOrders(thisMatch.AwayTeam, awayTeamHand);

                //Execute Orders
                players.ExecuteOrders(thisMatch);

                //Find encounters - doesn't seem to work
                List<Coordinate> engagements = thisMatch.CompairePlayersCoordinates(thisMatch);
                Rolls roll = new Rolls();

                //Roll for all engagements
                foreach (Coordinate coordinate in engagements)
                {
                    Console.WriteLine("Engagement at {0},{1}", coordinate.X, coordinate.Y);
                    roll.RollForEngagement(coordinate, thisMatch);
                }

                Console.WriteLine("!-----New Turn------!");

                gameBoard.DrawBoard(thisMatch);
            }
        }
开发者ID:runelippert,项目名称:TestGame,代码行数:46,代码来源:Program.cs

示例2: Main

    static int Main(string[] args)
    {
        Program p = new Program();
        char gameOn = 'y';//keeps track if game is ongoing
        int input;//variable to keep track of players choice of boardsize

        while (gameOn == 'y')
        {
            // get the size of the board that the user wants
            Console.Write("\nWelcome to Tic-Tac-Toe!\n\n");
            Console.Write("1. 3x3 (Standard)\n");
            Console.Write("2. 5x5\n");
            Console.Write("\nWhat size do you want on the board? (3 or 5): ");

            input = Convert.ToInt32(Console.ReadLine());

            // set the board size, based on the user's input
            if (input == 3 || input == 5)
            {
                p.boardWidth = input;
                p.boardSize = p.boardWidth * p.boardWidth;
            }
            else
            {
                Console.WriteLine("\nYou entered an invalid size!Try again! \n\n");
                continue;

            }

            // Array for the board
            char[] board = new char[p.boardSize];

            // Set all of the board items to empty
            for (int i = 0; i < p.boardSize; i++)
                board[i] = empty;

            bool win = false;
            int size = p.boardSize;//Varibles for the boardssize to pass as parameters in methodcallings
            int width = p.boardWidth;//pass as parameters in methodcallings

            Console.WriteLine("\nChoose opponent\n");
            Console.WriteLine("1. Human opponent");
            Console.WriteLine("2. Computer ");
            int chosenOpponent = int.Parse(Console.ReadLine());//Player input if they want to play
                                                                //against another human or the computerplayer

            // Draw the board
            Console.WriteLine();
            Console.Write(@"The board looks like this and you choose your position by entering the number
            representing the position you want:");
            Player play = new Player(size,width);
            Board b = new Board(size, width);
            ComputerPlayer cp = new ComputerPlayer(size,width);
            // reset moveCount
            play.moveCount = 0;
            b.DrawBoard(board, true);
            Console.WriteLine("\n\n");

            while (win == false)//While there is no winner
            {
                // Ask player1 for a move
                play.AskForMove(board,player1);

                // Draw the board
                b.DrawBoard(board, false);

                // Check to see if player 1 has won
                win = false;
                win = play.IsWinner(board, player1, size);
                if (win == true)
                {
                    Console.WriteLine("\n\nPlayer X has won!\n\n");
                    break;
                }

                // Check for a draw
                if (play.IsDraw())
                {
                    Console.WriteLine("\n\nIt's a draw!\n\n");
                    break;
                }

                // Ask player2 for a move
                if (chosenOpponent == 2 && input == 3)//If player wanted computer opponent and a 3x3board
                    cp.AskForComputerMoveThree(board,player2);

                else if (chosenOpponent == 2 && input == 5)//If player wanted computer opponent and a 5x5 board
                    cp.AskForComputerMoveFive(board, player2);

                else
                    play.AskForMove(board, player2);//If player wanted human opponent

                // Draw board again
                b.DrawBoard(board, false);

                // Check to see if player 2 has won
                win = false;
                win = play.IsWinner(board, player2, size);
                if (win == true)
                {
//.........这里部分代码省略.........
开发者ID:Zhytizz,项目名称:TicTac,代码行数:101,代码来源:Program.cs

示例3: Main

    static void Main()
    {
        // Setting the size of the console window
        Console.SetWindowSize(50, 26);
        Console.SetBufferSize(50, 26);

        // Starts off by sending players to UserGreeting.AskNames method, saving playernames in a string array
        string[] Names = UserGreeting.AskNames();

        // Creates a new board
        Board MyBoard = new Board();

        // Creates 2 new players, where we fetch the names from the array,
        // originally inherited from the UserGreeting.AskNames method
        Player Player1 = new Player(Names[0], "X", MyBoard);
        Player Player2 = new Player(Names[1], "O", MyBoard);

        MyBoard.DrawBoard();
        while (MyBoard.SpaceLeft())
        {
            Player1.MakeMove();
            if (!MyBoard.SpaceLeft()) break;
            MyBoard.CheckWinner();
            if (MyBoard.Winner) break;
            Player2.MakeMove();
            if (!MyBoard.SpaceLeft()) break;
            MyBoard.CheckWinner();
            if (MyBoard.Winner) break;

        }
    }
开发者ID:jbrf,项目名称:tictactoe101,代码行数:31,代码来源:Program.cs


注:本文中的Board.DrawBoard方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。