Esempio n. 1
0
 public void SelectPiece(GamePoint p)
 {
     ChessPiece piece;
     if (Board.TryPickup(p, out piece))
     {
         Selected = piece;
     }
 }
Esempio n. 2
0
 public void DeselectPiece(GamePoint p)
 {
     if (Selected != null)
     {
         ChessPiece other;
         if (!Board.TryPickup(p, out other))
         {
             Board.Move(Selected, p);
         }
     }
     Selected = null;
 }
Esempio n. 3
0
 public Board(ChessGame game, int sideLength)
 {
     SideLength = sideLength;
     Grid = new ChessPiece[8, 8];
     WhiteTeam = new Team(Color.White, this);
     BlackTeam = new Team(Color.Black, this);
     foreach (var i in Enumerable.Range(0, 7))
     {
         foreach (var j in Enumerable.Range(0, 7))
         {
             Grid[i, j] = null;
         }
     }
     foreach (var piece in WhiteTeam.Pieces)
     {
         Grid[piece.Location.X, piece.Location.Y] = piece;
     }
     foreach (var piece in BlackTeam.Pieces)
     {
         Grid[piece.Location.X, piece.Location.Y] = piece;
     }
 }
Esempio n. 4
0
 public void Move(ChessPiece piece, GamePoint p)
 {
     Grid[p.X, p.Y] = Grid[piece.Location.X, piece.Location.Y];
     Grid[piece.Location.X, piece.Location.Y] = null;
     piece.Location = p;
 }
Esempio n. 5
0
 public bool TryPickup(GamePoint p, out ChessPiece piece)
 {
     piece = Grid[p.X, p.Y];
     return piece != null;
 }