Пример #1
0
        private void Draw(Graphics graphics)
        {
            if (_battle == null)
            {
                return;
            }

            int battleWidth  = _battle.Width / 8;
            int battleHeight = _battle.Height / 8;

            graphics.TranslateTransform(_translation.X, _translation.Y);
            graphics.ScaleTransform(_zoom, _zoom);

            if (_drawGrid)
            {
                DrawGrid(graphics);
            }

            if (_background != null)
            {
                graphics.DrawImage(_background, new Rectangle(0, 0, battleWidth, battleHeight));
            }

            if (_drawData.DrawRegions)
            {
                foreach (BTBLib.Region region in _drawData.RegionsToDraw)
                {
                    DrawRegion(graphics, Color.White, false, false, region);
                }
                if (_selectedRegion != null && _drawData.ContainsRegion(_selectedRegion))
                {
                    DrawRegion(graphics, Color.FromArgb(200, 0, 0), true, _fillSelectedRegion, _selectedRegion);
                }
                if (_highlightedRegion != null && _highlightedRegion != _selectedRegion && _drawData.ContainsRegion(_highlightedRegion))
                {
                    DrawRegion(graphics, Color.FromArgb(255, 0, 0), false, false, _highlightedRegion);
                }
            }

            if (_drawData.DrawObstacels)
            {
                foreach (BTBLib.Obstacle obstacle in _drawData.ObstacelsToDraw)
                {
                    Color c;
                    if (obstacle.IsMoveBlock && obstacle.IsProjBlock)
                    {
                        c = Color.Purple;
                    }
                    else if (obstacle.IsMoveBlock)
                    {
                        c = Color.Red;
                    }
                    else if (obstacle.IsProjBlock)
                    {
                        c = Color.Blue;
                    }
                    else
                    {
                        c = Color.Black;
                    }
                    DrawObstacle(graphics, c, false, obstacle);
                }
            }

            if (_drawData.DrawObjects)
            {
                foreach (BTBLib.Node node in _drawData.ObjectsToDraw)
                {
                    Color c;
                    if ((node.Usage & Node.USAGE.ISUNIT) == Node.USAGE.ISUNIT)
                    {
                        c = node.ScriptFunc == 100 ? Color.Red : Color.White;
                    }
                    else if ((node.Usage & Node.USAGE.WAYPOINT) == Node.USAGE.WAYPOINT)
                    {
                        c = Color.Blue;
                    }
                    else
                    {
                        c = Color.Yellow;
                    }

                    DrawObject(graphics, c, false, node);
                }
                if (_selectedObject != null && _drawData.ContainsObject(_selectedObject))
                {
                    DrawObject(graphics, Color.FromArgb(200, 0, 0), true, _selectedObject);
                }
                if (_highlightedObject != null && _highlightedObject != _selectedObject && _drawData.ContainsObject(_highlightedObject))
                {
                    DrawObject(graphics, Color.FromArgb(255, 0, 0), true, _highlightedObject);
                }
            }
        }