/// <summary> /// Draw the tile at the given point. /// </summary> /// <param name="point"></param> public void DrawTile(Point point) { if (point.X >= 0 && point.X < BoardSize && point.Y >= 0 && point.Y < BoardSize) { var tile = Tiles[point.Y, point.X]; using (Graphics g = (screenInvalidated ? Graphics.FromImage(container.chessBoardBitmap.Image) : container.chessBoardBitmap.CreateGraphics())) { tile.State = TileState.Normal; if (latestTiles.Contains(tile)) { tile.State |= TileState.Latest; } if (SelectedTile != null && SelectedTile.CanMoveTo(this, tile)) { tile.State |= TileState.Targeted; } if (tile == SelectedTile) { tile.State |= TileState.Selected; } tile.Draw(g, tileWidth, tileHeight); } } }
/// <summary> /// Checks whether the given piece can move to any spot. /// </summary> /// <param name="tile"></param> /// <returns></returns> private bool CanMoveToAnything(BoardTile tile) { for (int y = 0; y < BoardSize; y++) { for (int x = 0; x < BoardSize; x++) { if (tile.OccupyingPiece != null && tile.CanMoveTo(this, Tiles[y, x])) { return(true); } } } return(false); }