示例#1
0
        public override void Render(Camera camera, Color color)
        {
            if (camera == null)
            {
                for (int i = 0; i < CellsX; i++)
                {
                    for (int j = 0; j < CellsY; j++)
                    {
                        if (Data[i, j])
                        {
                            Draw.HollowRect(AbsoluteLeft + i * CellWidth, AbsoluteTop + j * CellHeight, CellWidth, CellHeight, color);
                        }
                    }
                }
            }
            else
            {
                int left   = (int)Math.Max(0, ((camera.Left - AbsoluteLeft) / CellWidth));
                int right  = (int)Math.Min(CellsX - 1, Math.Ceiling((camera.Right - AbsoluteLeft) / CellWidth));
                int top    = (int)Math.Max(0, ((camera.Top - AbsoluteTop) / CellHeight));
                int bottom = (int)Math.Min(CellsY - 1, Math.Ceiling((camera.Bottom - AbsoluteTop) / CellHeight));

                for (int tx = left; tx <= right; tx++)
                {
                    for (int ty = top; ty <= bottom; ty++)
                    {
                        if (Data[tx, ty])
                        {
                            Draw.HollowRect(AbsoluteLeft + tx * CellWidth, AbsoluteTop + ty * CellHeight, CellWidth, CellHeight, color);
                        }
                    }
                }
            }
        }
示例#2
0
 public override void Render(Camera camera, Color color)
 {
     Draw.HollowRect(AbsoluteX, AbsoluteY, Width, Height, color);
 }