Exemplo n.º 1
0
 public CheckerBoard(int rows, int cols, int tileScale = 80)
 {
     Rows = rows;
     Cols = cols;
     TileScale = tileScale;
     Board = new Board(rows, cols, tileScale);
     Reset(rows, cols);
 }
Exemplo n.º 2
0
 //public Dictionary<Point, CheckerPiece> CheckerPieceMap { get; set; }
 //copy constructor
 public CheckerBoard(CheckerBoard other)
 {
     Board = other.Board;
     MustJump = new[] { other.MustJump[0], other.MustJump[1] };
     SelectedPiece = null;
     JumpMade = null;
     AllPieces = new List<CheckerPiece>(other.AllPieces.Count());
     for (var i = 0; i < other.AllPieces.Count(); i++)
     {
         AllPieces.Add(new CheckerPiece(other.AllPieces[i].Row, other.AllPieces[i].Col, other.AllPieces[i].Color, other.AllPieces[i].Status));
         if (other.JumpMade == null) continue;
         if (other.AllPieces[i] == other.JumpMade)
         {
             JumpMade = AllPieces[i];
         }
     }
 }
Exemplo n.º 3
0
        public void Reset(int rows, int cols)
        {
            Rows = rows;
            Cols = cols;
            //Place the pieces
            bool black = true;
            Board = new Board(rows, cols, TileScale);
            AllPieces = new List<CheckerPiece>();

            for (int row = 0; row < Rows; row++)    //top to down
            {
                for (int col = Cols - 1; col >= 0; col--) // right to left
                {
                    if (black)
                    {
                        var numPieceRows = Math.Floor((Rows - 2) / 2.0);
                        if (row < numPieceRows)
                        {
                            var tempPiece = new CheckerPiece(row, col, 0);
                            AllPieces.Add(tempPiece);
                        }
                        else if (row >= Rows - numPieceRows)
                        {
                            var tempPiece = new CheckerPiece(row, col, 1);
                            AllPieces.Add(tempPiece);
                        }
                    }

                    if (col != 0 || Cols % 2 != 0) black = !black;
                }
            }
            MustJump = new[]{false,false};
            CheckAllAvailableMoves();
        }