예제 #1
0
 public void PostProcess(MapRegionLayer layer, Graphics graphics, BlockColumnMeta block)
 {
     DrawShadow(layer, graphics, block,
                Math.Max(GetHeightDiff(layer, block, 0, -1), 0),
                Math.Max(GetHeightDiff(layer, block, -1, 0), 0),
                Math.Max(GetHeightDiff(layer, block, 1, 0), 0),
                Math.Max(GetHeightDiff(layer, block, 0, 1), 0));
 }
예제 #2
0
        public void PostProcess(MapRegionLayer layer, Graphics graphics, BlockColumnMeta block)
        {
            var rect = layer.GetBlockRectangle(block.Position);

            var alpha = (int)MathUtils.Clamp(MaxOverlayAlpha * ((MaxLightLevel - block.LightLevel) / MaxLightLevel), 0f, MaxOverlayAlpha);

            using (var brush = new SolidBrush(Color.FromArgb(alpha, Color.Black)))
            {
                graphics.FillRectangle(brush, rect);
            }
        }
예제 #3
0
        private int GetHeightDiff(MapRegionLayer regionLayer, BlockColumnMeta block, int xOffset, int zOffset)
        {
            var pos = new BlockPosition(block.Position.X + xOffset, block.Position.Z + zOffset);

            BlockColumnMeta targetBlock = regionLayer.Layer.Map.GetRegionLayer(pos.GetRegionPosition()).GetBlockData(pos);

            if (targetBlock != null)
            {
                return(targetBlock.Height - block.Height);
            }

            return(0);
        }
예제 #4
0
        private MapRegionLayer GetRegionLayer(RegionPosition regionPos)
        {
            lock (_cleanupSync)
            {
                MapRegionLayer layer;
                if (!_regions.TryGetValue(regionPos, out layer))
                {
                    layer = new MapRegionLayer(this, regionPos);
                    _regions.Add(regionPos, layer);
                }

                return(layer);
            }
        }
예제 #5
0
        public void PostProcess(MapRegionLayer layer, Graphics graphics, BlockColumnMeta block)
        {
            var rect = layer.GetBlockRectangle(block.Position);

            var chunkPos    = block.Position.GetChunkPosition();
            var chunkBounds = chunkPos.GetBlockBounds();

            var chunkRect = layer.GetChunkRectangle(chunkPos);

            var rX = block.Position.X % 16;
            var rZ = block.Position.Z % 16;


            if (rX == 15 && rZ == 15)
            {
                graphics.DrawRectangle(_chunkPen, chunkRect);
            }

            graphics.DrawRectangle(_gridPen, rect);

            if (rX == 15 && rZ == 15)
            {
                DrawText(graphics, chunkPos.ToString(), chunkRect, _chunkCoordFont);

                var min = chunkBounds.Min;
                var max = chunkBounds.Max;

                var tl = min;
                var tr = new BlockPosition(min.X, max.Z);
                var bl = new BlockPosition(max.X, min.Z);
                var br = max;

                DrawText(graphics, tl.ToString(), chunkRect, _coordFont, StringAlignment.Near, StringAlignment.Near);
                DrawText(graphics, tr.ToString(), chunkRect, _coordFont, StringAlignment.Far, StringAlignment.Near);
                DrawText(graphics, bl.ToString(), chunkRect, _coordFont, StringAlignment.Near, StringAlignment.Far);
                DrawText(graphics, br.ToString(), chunkRect, _coordFont, StringAlignment.Far, StringAlignment.Far);
            }
        }
예제 #6
0
        private void DrawShadow(MapRegionLayer layer, Graphics graphics, BlockColumnMeta column, int sizeTop,
                                int sizeLeft, int sizeRight, int sizeBottom)
        {
            var rect = layer.GetBlockRectangle(column.Position);

            int actSizeTop = 0, actSizeLeft = 0, actSizeRight = 0, actSizeBottom = 0;

            if (sizeTop > 0)
            {
                actSizeTop = (int)MathUtils.Clamp(Math.Round(MaxShadowSize * (MathUtils.Clamp(sizeTop * ShadowSizeMultiplier, 0.25f, 1f))), 1f, MaxShadowSize);
                for (int i = 0; i < actSizeTop; i++)
                {
                    using (var pen = new Pen(Color.FromArgb((int)(MathUtils.Clamp(sizeTop * AlphaMultiplier, 64f, 255f) / actSizeTop) * (i + 1)
                                                            , Color.Black)))
                    {
                        graphics.DrawLine(pen, rect.Left, rect.Top + i, rect.Right, rect.Top + i);
                    }
                }
            }

            if (sizeBottom > 0)
            {
                actSizeBottom = (int)MathUtils.Clamp(Math.Round(MaxShadowSize * (MathUtils.Clamp(sizeBottom * ShadowSizeMultiplier, 0.25f, 1f))), 1f, MaxShadowSize);
                for (int i = 0; i < actSizeBottom; i++)
                {
                    using (var pen =
                               new Pen(Color.FromArgb((int)(MathUtils.Clamp(sizeBottom * AlphaMultiplier, 64f, 255f) / actSizeBottom) * (i + 1),
                                                      Color.Black)))
                    {
                        graphics.DrawLine(pen, rect.Left, rect.Bottom - actSizeBottom + i, rect.Right, rect.Bottom - actSizeBottom + i);
                    }
                }
            }

            if (sizeLeft > 0)
            {
                actSizeLeft = (int)MathUtils.Clamp(Math.Round(MaxShadowSize * (MathUtils.Clamp(sizeLeft * ShadowSizeMultiplier, 0.25f, 1f))), 1f, MaxShadowSize);
                for (int i = 0; i < actSizeLeft; i++)
                {
                    using (var pen = new Pen(Color.FromArgb((int)(MathUtils.Clamp(sizeLeft * AlphaMultiplier, 64f, 255f) / actSizeLeft) * (i + 1),
                                                            Color.Black)))
                    {
                        graphics.DrawLine(pen, rect.Left + i, rect.Top, rect.Left + i, rect.Bottom);
                    }
                }
            }

            if (sizeRight > 0)
            {
                actSizeRight = (int)MathUtils.Clamp(Math.Round(MaxShadowSize * (MathUtils.Clamp(sizeRight * ShadowSizeMultiplier, 0.25f, 1f))), 1f, MaxShadowSize);
                for (int i = 0; i < actSizeRight; i++)
                {
                    using (var pen =
                               new Pen(Color.FromArgb((int)(MathUtils.Clamp(sizeRight * AlphaMultiplier, 64f, 255f) / actSizeRight) * (i + 1),
                                                      Color.Black)))
                    {
                        graphics.DrawLine(pen, rect.Right - actSizeRight + i, rect.Top, rect.Right - actSizeRight + i, rect.Bottom);
                    }
                }
            }
        }