protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); StartCell = CellAt(e.X, e.Y); ActivePiece = StartCell.Piece; if (ActivePiece?.Player != ActivePlayer) { ActivePiece = null; } Invalidate(); }
public TPiece PieceAtCell(TCell cell) { foreach (var piece in Pieces) { if (piece.Cell == cell) { return(piece); } } return(null); }
public TBoard() { InitializeComponent(); for (int y = 0; y < N; y++) { for (int x = 0; x < N; x++) { var cell = new TCell(); cell.Board = this; cell.X = x; cell.Y = y; Cells[y, x] = cell; } } Reset(); }