Пример #1
0
        public override void DebugRender(Batcher batcher)
        {
            base.DebugRender(batcher);

            batcher.DrawCircle(this.Position, 50, Color.Green);
            batcher.DrawCircle(this.Position, 75, Color.Green);
            batcher.DrawCircle(this.Position, 150, Color.Green);
        }
Пример #2
0
        public void DebugRender(Batcher batcher)
        {
            if (DrawConstraints)
            {
                for (var i = 0; i < _constraints.Length; i++)
                {
                    _constraints.Buffer[i].DebugRender(batcher);
                }
            }

            if (DrawParticles)
            {
                for (var i = 0; i < Particles.Length; i++)
                {
                    if (Particles.Buffer[i].Radius == 0)
                    {
                        batcher.DrawPixel(Particles.Buffer[i].Position, ECDebug.Colors.VerletParticle, 4);
                    }
                    else
                    {
                        batcher.DrawCircle(Particles.Buffer[i].Position, (int)Particles.Buffer[i].Radius,
                                           ECDebug.Colors.VerletParticle, 1, 4);
                    }
                }
            }
        }
Пример #3
0
        public override void Render(Batcher batcher, Camera camera)
        {
            batcher.DrawCircle(Transform.Position, 2, Color.Red);
            batcher.DrawHollowRect((Transform.Position.RoundToPoint() - new Point(0, height * Constants.pixelsPerTile)).ToVector2(), Width, Height, OutlineColour, 6);
            batcher.DrawRect((Transform.Position.RoundToPoint() - new Point(0, height * Constants.pixelsPerTile)).ToVector2(),
                             Width, Height, BackgroundColour);

            for (int y = 0; y < height + 2; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    DrawGridTile(batcher, new Point(x, y));
                }
            }

            foreach (var player in players)
            {
                var piece = player.piece;
                if (piece != null)
                {
                    var ghost = piece.GetLandedOffset();
                    foreach (Point point in piece.Shape)
                    {
                        DrawOutline(batcher, point + piece.position, player.outlineTint, 6);
                        DrawOutline(batcher, point + piece.position + ghost, player.outlineTint, 6);
                    }
                    foreach (Point point in piece.Shape)
                    {
                        Utilities.DrawTile(batcher, point + piece.position + ghost, Transform.Position.ToPoint(), piece.definition.type, piece.definition.type.ghostColor);
                    }
                    foreach (Point point in piece.Shape)
                    {
                        Utilities.DrawTile(batcher, point + piece.position, Transform.Position.ToPoint(), piece.definition.type);
                    }
                    int temp = 0;
                    foreach (Point point in piece.outline)
                    {
                        Point gridOffset = point + piece.position;
                        Point offset     = new Point(Constants.pixelsPerTile * gridOffset.X, -Constants.pixelsPerTile * gridOffset.Y);
                        batcher.DrawCircle(Transform.Position + offset.ToVector2(), 2, Color.Green);
                        batcher.DrawString(Graphics.Instance.BitmapFont, temp + "", Transform.Position + offset.ToVector2(), Color.White);
                        temp++;
                    }
                }
            }
        }
Пример #4
0
                public virtual void DebugRender(Batcher batcher)
                {
                    if (_context.previousNode != null)
                    {
                        batcher.DrawCircle(_context.previousNode.Position, 100, Color.White, 15);
                    }
                    if (_context.currentNode != null)
                    {
                        batcher.DrawCircle(_context.currentNode.Position, 100, Color.Gray, 15);
                    }
                    if (_context.nextNode != null)
                    {
                        batcher.DrawCircle(_context.nextNode.Position, 100, Color.Black, 15);
                    }

                    batcher.DrawRect(GetCheckRectangle(), Color.Black);
                }
Пример #5
0
        public override void DebugRender(Batcher batcher)
        {
            if (_target != null)
            {
                batcher.DrawCircle(_target.Position, SlowingRadius, Color.Red);
            }

            base.DebugRender(batcher);
        }
Пример #6
0
        public override void DebugRender(Batcher batcher)
        {
            base.DebugRender(batcher);

            if (Entity.GetComponent <Collider>() != null)
            {
                batcher.DrawCircle(new Vector2(Entity.Position.X, Entity.GetComponent <Collider>().Bounds.Bottom), 3, Color.White);
            }
        }
Пример #7
0
        public override void DebugRender(Batcher batcher)
        {
            base.DebugRender(batcher);

            if (target != null)
            {
                batcher.DrawLineAngle(Transform.Position, Mathf.AngleBetweenVectors(this.Position, target.Position), 10, Color.Red);
            }

            batcher.DrawCircle(this.Position, 100f, Color.Red);
        }
Пример #8
0
        void RenderCircles(Batcher batcher, SvgCircle[] circles)
        {
            if (circles == null)
            {
                return;
            }

            foreach (var circ in circles)
            {
                batcher.DrawCircle(circ.CenterX, circ.CenterY, circ.Radius, circ.StrokeColor, (int)circ.StrokeWidth);
            }
        }
Пример #9
0
        public void DebugRender(Batcher batcher)
        {
            for (var i = 0; i < _composites.Length; i++)
            {
                _composites.Buffer[i].DebugRender(batcher);
            }

            if (AllowDragging)
            {
                if (_draggedParticle != null)
                {
                    batcher.DrawCircle(_draggedParticle.Position, 8, Color.White);
                }
                else
                {
                    // Highlight the nearest particle within the selection radius
                    var particle = GetNearestParticle(Input.MousePosition);
                    if (particle != null)
                    {
                        batcher.DrawCircle(particle.Position, 8, Color.White * 0.4f);
                    }
                }
            }
        }
Пример #10
0
        public override void Render(Batcher batcher, Camera camera)
        {
            batcher.DrawHollowRect(Transform.Position, Width, Height, OutlineColour, 6);
            batcher.DrawRect(Transform.Position, Width, Height, BackgroundColour);
            Point offset = new Point(0, -2);

            foreach (var pieceDef in queue)
            {
                offset.Y += pieceDef.height + 1;
                foreach (Point point in pieceDef.shape)
                {
                    Utilities.DrawTile(batcher, point - offset, new Point(padding + Constants.pixelsPerTile, padding + Constants.pixelsPerTile) + Transform.Position.ToPoint(), pieceDef.type);
                }
            }
            batcher.DrawCircle(Transform.Position, 3, Color.Red);
        }
Пример #11
0
        public override void Render(Batcher batcher, Camera camera)
        {
            batcher.DrawHollowRect(Transform.Position, Width, Height, OutlineColour, 6);
            batcher.DrawRect(Transform.Position, Width, Height, BackgroundColour);
            Point offset = new Point(0, 1);

            if (heldPiece != null)
            {
                foreach (Point point in heldPiece.shape)
                {
                    Utilities.DrawTile(batcher, point - offset, new Point(padding + Constants.pixelsPerTile, padding + Constants.pixelsPerTile) + Transform.Position.ToPoint(), heldPiece.type);
                }
            }

            batcher.DrawCircle(Transform.Position, 3, Color.Red);
        }
Пример #12
0
        static void Main(string[] args)
        {
            // Create the window and the graphics device
            VeldridInit(out var window, out var graphicsDevice);

            // Create a texture storage that manages textures.
            // Textures in OpenWheels are represented with integer values.
            // A platform-specific ITextureStorageImplementation handles texture creation,
            // destruction and modification.
            var texStorage = new VeldridTextureStorage(graphicsDevice);

            // Create a renderer that implements the OpenWheels.Rendering.IRenderer interface
            // this guy actually draws everything to the backbuffer
            var renderer = new VeldridRenderer(graphicsDevice, texStorage);

            // OpenWheels always requires a texture to render, so renderer implementations only need a single shader
            // Even for untextured primitives we need to have a texture set. So we create a white 1x1 texture for those.
            ReadOnlySpan <Color> blankSpan = stackalloc Color[] { Color.White };
            var blank = texStorage.CreateTexture(1, 1, TextureFormat.Rgba32);

            texStorage.SetData(blank, blankSpan);

            // Our batcher lets use make calls to render lots of different primitive shapes and text.
            // When we're done the batcher can export draw calls so the renderer can use them do the drawing.
            // We won't use text rendering in this sample so we use the dummy text renderer.
            var batcher = new Batcher(NullBitmapFontRenderer.Instance);

            var first = true;

            // We run the game loop here and do our drawing inside of it.
            VeldridRunLoop(window, graphicsDevice, () =>
            {
                renderer.Clear(Color.CornflowerBlue);

                // Start a new batch
                batcher.Start();

                // set the texture to the blank one we registered
                batcher.SetTexture(blank);

                // Let's draw some primitives. The API is very obvious, you can use IntelliSense to find supported shapes.
                batcher.FillRect(new RectangleF(10, 10, 100, 100), Color.LimeGreen);

                // Note that subsequent line segments are connected at their corners
                Span <Vector2> points = stackalloc Vector2[] { new Vector2(140, 20), new Vector2(320, 20), new Vector2(320, 120), new Vector2(420, 120) };
                batcher.DrawLineStrip(points, Color.Red, 20);

                batcher.FillTriangle(new Vector2(500, 20), new Vector2(600, 70), new Vector2(500, 120), Color.White);

                // The tessellation of the circle and corners for the rounded rectangle can be adjusted with the maxError parameter
                batcher.DrawCircle(new Vector2(700, 70), 50, Color.BlueViolet, 2);

                batcher.FillRoundedRect(new RectangleF(790, 10, 100, 100), 10, Color.SandyBrown);

                var pa    = new Vector2(50, 220);
                var pb    = new Vector2(150, 120);
                var pc    = new Vector2(250, 220);
                var curve = new QuadraticBezier(pa, pb, pc);
                // The segmentation for curves can be adjusted with the segmentsPerLength parameter
                // Using that parameter and an (over)estimate of the length of the curve the number of segments
                // is computed
                batcher.DrawCurve(curve, Color.DarkGoldenrod, 2);

                var o      = new Vector2(0, 100);
                var pd     = new Vector2(200, 420);
                var curve2 = new CubicBezier(pa + o, pb + o, pd, pc + o);
                batcher.DrawCurve(curve2, Color.DarkOrchid, 2);

                // Finish the batch and let the renderer draw everything to the back buffer.
                batcher.Render(renderer);

                if (first)
                {
                    Console.WriteLine("Vertices: " + batcher.VerticesSubmitted);
                    Console.WriteLine("Indices: " + batcher.IndicesSubmitted);
                    Console.WriteLine("Batches: " + batcher.BatchCount);
                    first = false;
                }
            });
Пример #13
0
 /// <summary>
 /// renders the bounds only if there is no collider. Always renders a square on the origin.
 /// </summary>
 /// <param name="batcher">Batcher.</param>
 public override void DebugRender(Batcher batcher)
 {
     batcher.DrawCircle(Entity.Transform.Position + _localOffset, Radius * Entity.Transform.Scale.X, Color.DarkOrchid, 2);
 }
Пример #14
0
 public void DebugRender(Batcher batcher)
 {
     batcher.DrawCircle(Target, TargetRadius, Color.Green, 2f);
     batcher.DrawCircle(Target, ArrivalRadius, Color.GreenYellow, 2f);
 }
 public override void DebugRender(Batcher batcher)
 {
     batcher.DrawCircle(_behind, 8f, Color.Green);
 }
Пример #16
0
 public override void DebugRender(Batcher batcher)
 {
     base.DebugRender(batcher);
     batcher.DrawCircle(turnTarget, 20, Color.Red, 15);
 }