ARCed.Controls.MapEditorXnaPanel.Draw C# (CSharp) Метод

Draw() защищенный Метод

Performs painting of the control
protected Draw ( ) : void
Результат void
        protected override void Draw()
        {
            GraphicsDevice.Clear(_backColor);
            const float mod = Constants.MAP_LAYERS + Constants.PRIORITIES;
            if (_map == null) return;
            _batch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend);
            int tileId;
            float depth;
            Rectangle srcRect, destRect;
            for (int z = 0; z < Constants.MAP_LAYERS; z++)
            {
                for (int y = 0; y < _map.height; y++)
                {
                    for (int x = 0; x < _map.width; x++)
                    {
                        tileId = _map.data[x, y, z];
                        depth = (_tileset.priorities[tileId] + z) / mod;
                        destRect = new Rectangle
                        {
                            X = x * Constants.TILESIZE,
                            Y = y * Constants.TILESIZE,
                            Width = Constants.TILESIZE,
                            Height = Constants.TILESIZE
                        };
                        if (tileId >= Constants.AUTO_IDS)
                        {
                            srcRect = new Rectangle
                            {
                                X = ((tileId - Constants.AUTO_IDS) % 8) * Constants.TILESIZE,
                                Y = ((tileId - Constants.AUTO_IDS) / 8) * Constants.TILESIZE,
                                Width = Constants.TILESIZE,
                                Height = Constants.TILESIZE
                            };
                            _batch.Draw(_srcTexture, destRect, srcRect, Color.White, 0.0f, Vector2.Zero,
                                SpriteEffects.None, depth);
                        }
                        else
                        {
                            int index = tileId / 48;
                            if (index == 0) continue;
                            Texture2D src = _autotiles[index][tileId % 48];
                            if (src != null)
                                _batch.Draw(src, destRect, src.Bounds, Color.White, 0.0f, Vector2.Zero,
                                SpriteEffects.None, depth);
                        }
                    }
                }
            }
            _batch.End();
            if (SelectionEnabled && _originPoint != _endPoint)
            {
                _batch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
                _batch.DrawSelectionRect(SelectionRectangle, Color.White, 2);
                _batch.End();
            }
        }