コード例 #1
0
        /// <summary>
        /// Dispose checkers on table, white locate down
        /// </summary>
        private static void DisposeNormal(Color color, CheckerGraphicalImplementation[,,] graphicalImplementation)
        {
            switch (color)
            {
            case Color.White:
                for (int i = 0; i < 3; ++i)
                {
                    for (int j = 0; j < 4; ++j)
                    {
                        Cell         wCell    = TableCells.Cell[i % 2 + 2 * j, 7 - i];
                        WhiteChecker wChecker = new WhiteChecker(wCell, PlayerMoveDirection.BottomTop,
                                                                 graphicalImplementation[0, i, j]);
                        GameDataHandler.WhiteCheckers.Add(wChecker);
                        Cell         bCell    = TableCells.Cell[(i + 1) % 2 + 2 * j, i];
                        BlackChecker bChecker = new BlackChecker(bCell, PlayerMoveDirection.TopBottom,
                                                                 graphicalImplementation[1, i, j]);
                        GameDataHandler.BlackCheckers.Add(bChecker);
                    }
                }
                break;

            case Color.Black:
                for (int i = 0; i < 3; ++i)
                {
                    for (int j = 0; j < 4; ++j)
                    {
                        Cell         bCell    = TableCells.Cell[i % 2 + 2 * j, 7 - i];
                        BlackChecker bChecker = new BlackChecker(bCell, PlayerMoveDirection.BottomTop,
                                                                 graphicalImplementation[1, i, j]);
                        GameDataHandler.BlackCheckers.Add(bChecker);
                        Cell         wCell    = TableCells.Cell[(i + 1) % 2 + 2 * j, i];
                        WhiteChecker wChecker = new WhiteChecker(wCell, PlayerMoveDirection.TopBottom,
                                                                 graphicalImplementation[0, i, j]);
                        GameDataHandler.WhiteCheckers.Add(wChecker);
                    }
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #2
0
ファイル: Board.cs プロジェクト: Namolem/checkers
        public static Board GetStartingBoard()
        {
            Piece[] squares = new Piece[64];
            BoardStatus status = new BoardStatus();
            var blackInitial = new List<int>()
            {
                1,3,5,7,8,10,12,14,17,19,21,23
            };
            foreach (var i in blackInitial)
            {
                squares[i] = new BlackChecker();
            }

            var whiteInitial = new List<int>()
            {
                40,
                42,
                44,
                46,
                49,
                51,
                53,
                55,
                56,
                58,
                60,
                62
            };

            foreach (var i in whiteInitial)
            {
                squares[i] = new WhiteCheker();
            }

            status.WhiteTurn = true;
            status.Moves = 1;
            return new Board(squares, status);
        }