private void MakeLayeredSurface()
        {
            layeredSurface = new LayeredConsole(35, 15, 3);

            CellSurfaceLayer layer = layeredSurface.GetLayer(0);

            layer.Fill(StarterProject.Theme.Gray, StarterProject.Theme.GrayDark, 0);
            layer.Print(14, 4, "Layer 0");

            layer = layeredSurface.GetLayer(1);
            layer.Fill(StarterProject.Theme.Green, StarterProject.Theme.GreenDark, 0);
            layer.Fill(new Rectangle(10, 4, 34 - 20, 15 - 8), Color.White, Color.Transparent, 0);
            layer.Print(14, 2, "Layer 1");

            layer = layeredSurface.GetLayer(2);
            layer.Fill(StarterProject.Theme.Brown, StarterProject.Theme.BrownDark, 0);
            layer.Fill(new Rectangle(5, 2, 34 - 10, 15 - 4), Color.White, Color.Transparent, 0);
            layer.Print(14, 0, "Layer 2");
        }
Beispiel #2
0
        /// <summary>
        /// Renders a layer on top of a console.
        /// </summary>
        /// <param name="layer">The layer to render.</param>
        /// <param name="drawingHost">The console that will be drawn on.</param>
        /// <param name="draw">If <see langword="false"/>, skips rendering.</param>
        public void RenderLayer(CellSurfaceLayer layer, SadConsole.Console drawingHost, bool draw = true)
        {
            if (!draw)
            {
                return;
            }

            if (drawingHost.Tint.A != 255)
            {
                for (var i = 0; i < layer.Cells.Length; i++)
                {
                    ref var cell = ref layer.Cells[i];

                    if (!cell.IsVisible)
                    {
                        continue;
                    }

                    if (cell.Background != Color.Transparent)
                    {
                        Global.SpriteBatch.Draw(drawingHost.Font.FontImage, drawingHost.RenderRects[i], drawingHost.Font.GlyphRects[drawingHost.Font.SolidGlyphIndex], cell.Background, 0f, Vector2.Zero, SpriteEffects.None, 0.3f);
                    }

                    if (cell.Foreground != Color.Transparent)
                    {
                        Global.SpriteBatch.Draw(drawingHost.Font.FontImage, drawingHost.RenderRects[i], drawingHost.Font.GlyphRects[cell.Glyph], cell.Foreground, 0f, Vector2.Zero, cell.Mirror, 0.4f);
                    }

                    foreach (var decorator in cell.Decorators)
                    {
                        if (decorator.Color != Color.Transparent)
                        {
                            Global.SpriteBatch.Draw(drawingHost.Font.FontImage, drawingHost.RenderRects[i], drawingHost.Font.GlyphRects[decorator.Glyph], decorator.Color, 0f, Vector2.Zero, decorator.Mirror, 0.5f);
                        }
                    }
                }
            }