Esempio n. 1
0
 public void SetUpBoard(Board gameBoard)
 {
     foreach (var piece in gameBoard.GameBoard)
     {
         if (piece != null)
         {
             Pieces.Add(new GUIPiece(ToPoint(piece.Position), piece.Owner.Color,
                                     GUIPiece.GetImageSource(piece.Owner.Color, piece.Type)));
         }
     }
 }
Esempio n. 2
0
        public void UpdatePieces(Coordinates from, Coordinates to)
        {
            Point    pointFrom        = ToPoint(from);
            Point    pointTo          = ToPoint(to);
            GUIPiece pieceToBeRemoved = null;

            foreach (var piece in Pieces)
            {
                if (piece.XPosition == pointTo.X && piece.YPosition == pointTo.Y)
                {
                    pieceToBeRemoved = piece;
                }
                else if (piece.XPosition == pointFrom.X && piece.YPosition == pointFrom.Y)
                {
                    piece.XPosition = pointTo.X;
                    piece.YPosition = pointTo.Y;
                }
            }
            if (pieceToBeRemoved != null)
            {
                Pieces.Remove(pieceToBeRemoved);
            }
        }