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