Пример #1
0
        public override void Draw(Entity ent, SpriteBatch batch)
        {
            // Debug Drawing
            if (BeyondAge.TheGame.Debugging)
            {
                var rect    = ent.Get <Body>();
                var physics = ent.Get <PhysicsBody>();

                primitives.DrawLineRect(rect.Region, Color.Red);

                var direction = (new Vector2((float)Math.Cos(physics.Direction), (float)Math.Sin(physics.Direction)));
                primitives.DrawLine(
                    rect.Center,
                    rect.Center + direction * 100,
                    Color.LightPink
                    );

                var font = BeyondAge.Assets.GetFont("Font");
                batch.DrawString(
                    font,
                    $"X: {rect.X} Y: {rect.Y}",
                    rect.Position + new Vector2(0, rect.Height + 4),
                    Color.White,
                    0,
                    Vector2.Zero,
                    0.5f,
                    SpriteEffects.None,
                    1);

                foreach (var poly in polygons)
                {
                    var last = poly.Points[0];
                    for (int i = 1; i < poly.Points.Count; i++)
                    {
                        var now = poly.Points[i];
                        primitives.DrawLine(last + poly.Position, now + poly.Position, Color.Red);
                        last = now;
                    }
                }

                foreach (var body in solids)
                {
                    primitives.DrawLineRect(body.Region, Color.Red);
                }
            }
        }
Пример #2
0
        public void UiDraw(SpriteBatch batch, Primitives primitives)
        {
            Showing = currentDialog != null;
            if (currentDialog != null)
            {
                primitives.DrawRect(new Rectangle(0, BeyondAge.Height - 256, BeyondAge.Width, 256), Color.SlateGray);
                var font = BeyondAge.Assets.GetFont("Font");

                var    currentNode = currentDialog[currentIndex] as LuaTable;
                string text        = (currentNode[1] as string);
                if (charIndex < text.Length)
                {
                    text = text.Substring(0, charIndex);
                }

                batch.DrawString(
                    font,
                    text,
                    new Vector2(32, BeyondAge.Height - 256 + 3),
                    Color.White
                    );

                // Show options
                if (currentNode["options"] != null)
                {
                    var options = currentNode["options"] as LuaTable;

                    var index = 0;
                    var xpos  = 32f;
                    foreach (LuaTable option in options.Values)
                    {
                        var otext     = option[1] as string;
                        var nextIndex = (int)(option[2] as Double?);

                        batch.DrawString(
                            font,
                            otext,
                            new Vector2(xpos, BeyondAge.Height - 128 + 3),
                            Color.White
                            );

                        if (selector.X == index)
                        {
                            primitives.DrawLineRect(
                                new Rectangle(
                                    (int)(xpos - 16), (int)(BeyondAge.Height - 128 + 3 - 16),
                                    (int)(font.MeasureString(otext).X + 32), (int)(font.MeasureString(otext).Y + 32)
                                    ), Color.White);
                        }

                        xpos += font.MeasureString(otext).X + 32;
                        index++;
                    }
                }
            }
        }