public BoardSpace(int x, int y, int size, Color c, Checker checker)
        {
            this.gridx = x;
            this.gridy = y;
            this.color = c;
            this.size = size;
            this.checker = checker;

            space = new Rectangle();
            space.Width = size;
            space.Height = size;
            space.MinWidth = size;
            space.MinHeight = size;
            space.MouseLeftButtonUp += Space_Action;
            space.Fill = new SolidColorBrush(color);
            int lm = (x * size) - 40;
            int tm = (y * size) - 150;
            space.Margin = new Thickness(lm, tm, MainPage.w - lm, MainPage.h - tm);
            if (checker != null)
                this.checker.setMargin(space.Margin);
        }
 public void setChecker(Checker c)
 {
     this.checker = c;
     if (c == null) return;
     checker.setMargin(space.Margin);
 }
 private void createPieces()
 {
     logic = new GameLogic(row_W, row_W, MainPage.FORCE_JUMP);
     int row = 0, col = 0;
     for (int k = 0; k < 24; k++)
     {
         row = (k / 4) + ((k >= 12) ? 2 : 0);
         col = 2 * (k % 4) + (row % 2 == 0 ? 0 : 1);
         Checker c = new Checker(col, row, (k < 12) ? Colors.Red : DarkGrey,
                                         (k < 12) ? DarkRed : Colors.Black);
         Vector vect = new Vector(row, col);
         Piece piece = new Piece((k < 12) ? PieceColor.RED : PieceColor.BLACK, vect, PieceType.REGULAR);
         logic.addPiece(piece);
         spaces[col, row].setChecker(c);
         mainCanvas.Children.Add(spaces[col, row].getChecker().getEl2());
         mainCanvas.Children.Add(spaces[col, row].getChecker().getEl1());
         mainCanvas.Children.Add(spaces[col, row].getChecker().getCrown());
     }
 }
        private static void handleMove(Move move)
        {
            List<Piece> added = move.getAdditions();
            List<Piece> removed = move.getRemovals();

            foreach (Piece p in removed)
            {
                Vector co = p.getCoordinates();
                delete(co.getX(), co.getY());
            }

            foreach (Piece p in added)
            {
                Vector co = p.getCoordinates();

                int col = co.getX();
                int row = co.getY();
                Checker c = new Checker(col, row, p.getColor() == PieceColor.BLACK ? DarkGrey : Colors.Red,
                                                 p.getColor() == PieceColor.BLACK ? Colors.Black : DarkRed);
                spaces[col, row].setChecker(c);
                mainCanvas.Children.Add(spaces[col, row].getChecker().getEl2());
                mainCanvas.Children.Add(spaces[col, row].getChecker().getEl1());
                mainCanvas.Children.Add(spaces[col, row].getChecker().getCrown());

                if (p.getType() == PieceType.KING)
                    c.king();
            }
        }
 public Boolean Equals(Checker c)
 {
     return (c.getX() == this.getX() && c.getY() == this.getY());
 }
Example #6
0
 public Boolean Equals(Checker c)
 {
     return(c.getX() == this.getX() && c.getY() == this.getY());
 }