Пример #1
0
        public void DrawBattleSweeperBoard(Board board, RectangleF bounds, float boardCellSize, int startLine = 0, int lineCount = 0)
        {
            if (board == null)
            {
                return;
            }

            for (int x = startLine; x < (lineCount > 0 ? Math.Min(startLine + lineCount, board.Size) : board.Size); x++)
            {
                for (int y = 0; y < board.Size; y++)
                {
                    Tile         tile     = board.Tiles[board.GetIndex(x, y)];
                    DrawableTile decoTile = tile;

                    if (tile.State != -1)
                    {
                        decoTile = new TileRevealedDecorator(decoTile);

                        if (tile.Mine != null)
                        {
                            decoTile = new TileBombDecorator(decoTile, tile.Mine.ImageName);
                            decoTile = new TileCrossDecorator(decoTile);
                        }
                        else
                        {
                            decoTile = new TileNumberDecorator(decoTile, tile.State);
                        }
                    }
                    else
                    {
                        if (tile.Mine != null)
                        {
                            decoTile = new TileBombDecorator(decoTile, tile.Mine.ImageName);
                        }
                    }

                    this.graphics.DrawImage(decoTile.GetImage(this.textures), new RectangleF(bounds.X + boardCellSize * x, bounds.Y + boardCellSize * y, boardCellSize, boardCellSize));
                }
            }
        }
Пример #2
0
        public void DrawBattleSweeperBoard(Board board, RectangleF bounds, float boardCellSize, List <ChangePoint> RedrawPoints)
        {
            if (board == null)
            {
                return;
            }

            foreach (ChangePoint point in RedrawPoints)
            {
                Tile         tile     = board.Tiles[board.GetIndex(point.X, point.Y)];
                DrawableTile decoTile = tile;

                if (tile.State != -1)
                {
                    decoTile = new TileRevealedDecorator(decoTile);

                    if (tile.Mine != null)
                    {
                        decoTile = new TileBombDecorator(decoTile, tile.Mine.ImageName);
                        decoTile = new TileCrossDecorator(decoTile);
                    }
                    else
                    {
                        decoTile = new TileNumberDecorator(decoTile, tile.State);
                    }
                }
                else
                {
                    if (tile.Mine != null)
                    {
                        decoTile = new TileBombDecorator(decoTile, tile.Mine.ImageName);
                    }
                }

                this.graphics.DrawImage(decoTile.GetImage(this.textures), new RectangleF(bounds.X + boardCellSize * point.X, bounds.Y + boardCellSize * point.Y, boardCellSize, boardCellSize));
            }
        }