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);
        }
예제 #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)
     });
 }
예제 #3
0
 public Boolean CheckAll(CBoardOccupancy boardStates, CTile currentTile, CTile proposedTile)
 {
     return(_rules.Any(rule =>
     {
         try
         {
             return rule(boardStates, currentTile, proposedTile);
         }
         catch
         {
             return false;
         }
     }));
 }
예제 #4
0
 public CTileVector(CTile beginning, CTile end) : this(end.X - beginning.X, end.Y - beginning.Y)
 {
 }
예제 #5
0
 public Boolean IsMoveValid(CBoardOccupancy boardStates, CTile proposedTile)
 {
     return(_movementValidator.CheckAll(boardStates, new CTile(Margin), proposedTile));
 }
예제 #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;
 }
예제 #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));
 }
예제 #8
0
 public CTile(CTile tile)
 {
     X = tile.X;
     Y = tile.Y;
 }