private void ChangeProjectionState(CPieceProjection projection, Point cursorCoordinates)
        {
            CTile cursorTile = new CTile(cursorCoordinates);

            projection.Margin       = new Thickness(cursorTile.X * CPiece.PieceSize, cursorTile.Y * CPiece.PieceSize, 0, 0);
            projection.IsValidState = IsCursorOverBoard(cursorCoordinates) &&
                                      !_attachedTiles.Contains(cursorTile) &&
                                      projection.Root.IsMoveValid(_boardStates, cursorTile);
        }
Exemple #2
0
 private static Image CreatePieceImage(EPieceColor color, EPieceType type, CTile tile)
 {
     return(new Image
     {
         Source = new BitmapImage(new Uri($"/Images/{color}/{type}.png", UriKind.RelativeOrAbsolute)),
         Width = CPiece.PieceSize,
         Height = CPiece.PieceSize,
         Margin = new Thickness(tile.X * CPiece.PieceSize, tile.Y * CPiece.PieceSize, 0, 0)
     });
 }
Exemple #3
0
 public Boolean CheckAll(CBoardOccupancy boardStates, CTile currentTile, CTile proposedTile)
 {
     return(_rules.Any(rule =>
     {
         try
         {
             return rule(boardStates, currentTile, proposedTile);
         }
         catch
         {
             return false;
         }
     }));
 }
Exemple #4
0
 public CTileVector(CTile beginning, CTile end) : this(end.X - beginning.X, end.Y - beginning.Y)
 {
 }
Exemple #5
0
 public Boolean IsMoveValid(CBoardOccupancy boardStates, CTile proposedTile)
 {
     return(_movementValidator.CheckAll(boardStates, new CTile(Margin), proposedTile));
 }
Exemple #6
0
 private CPiece(Int32 id, ImageSource source, CMovementValidator movementValidator, EPieceColor pieceColor, CTile tile)
 {
     Source             = source;
     _movementValidator = movementValidator;
     Color     = pieceColor;
     IsActive  = true;
     Id        = id;
     Width     = PieceSize;
     Height    = PieceSize;
     Margin    = new Thickness(tile.X * PieceSize, tile.Y * PieceSize, 0, 0);
     AllowDrop = true;
 }
Exemple #7
0
 public static CPiece Create(Int32 id, EPieceType pieceType, EPieceColor pieceColor, CTile tile)
 {
     return(new CPiece(
                id,
                new BitmapImage(new Uri($"/Images/{pieceColor}/{pieceType}.png", UriKind.RelativeOrAbsolute)),
                SMovementValidatorFactory.GetMovementValidator(pieceType),
                pieceColor,
                tile));
 }
Exemple #8
0
 public CTile(CTile tile)
 {
     X = tile.X;
     Y = tile.Y;
 }