Beispiel #1
0
        private void _frameTimer_OnFrame(FrameTimer timer, D2DDevice device)
        {
            #region non drawing things
            D2DSolidColorBrush GetDXColor(Color color)
            {
                return(device.CreateSolidColorBrush(color.R, color.G, color.B, color.A));
            }

            if (!device.IsDrawing)
            {
                _initializeGraphicObjects = true;
                return;
            }
            device.ClearScene();
            #endregion
            DrawTextWithBackground("ZBase", 0, 0, 16, Color.Blue, Color.DimGray);

            if (Main.S.ESP)
            {
                foreach (Entity Player in Globals.EntityList)
                {
                    if (Player.EntityBase != Globals.LocalPlayer.EntityBase)
                    {
                        Vector2 Player2DPos     = Tools.WorldToScreen(Player.Position);
                        Vector2 Player2DHeadPos = Tools.WorldToScreen(Player.HeadPosition);
                        Vector2 Player2DNeckPos = Tools.WorldToScreen(Player.GetBonePosition(7));
                        if (!Tools.IsNullVector2(Player2DPos) && !Tools.IsNullVector2(Player2DHeadPos) && Player.Valid)
                        {
                            float FromHeadToNeck = (Player2DNeckPos.Y - Player2DHeadPos.Y);
                            Player2DHeadPos.Y -= FromHeadToNeck * 2.3f;
                            Player2DPos.Y     += FromHeadToNeck;
                            float BoxHeight = Player2DPos.Y - Player2DHeadPos.Y;
                            float BoxWidth  = (BoxHeight / 2);
                            //wierd ass calculations for box height, dont judge
                            Color drawcolor;
                            if (Player.IsTeammate)
                            {
                                drawcolor = Color.Blue;
                            }
                            else
                            {
                                drawcolor = Color.Red;
                            }
                            DrawOutlineBox(Player2DPos.X - (BoxWidth / 2), Player2DHeadPos.Y, BoxWidth, BoxHeight, drawcolor);
                            DrawLine(Main.MidScreen.X, Main.MidScreen.Y + Main.MidScreen.Y, Player2DPos.X, Player2DPos.Y, drawcolor);
                        }
                    }
                }
            }

            #region drawing functions
            void DrawBoxEdge(float x, float y, float width, float height, Color color, float thiccness = 2.0f)
            {
                device.DrawRectangleEdges(Rectangle.Create(x, y, width, height), thiccness, GetDXColor(color));
            }

            void DrawText(string text, float x, float y, int size, Color color, bool bold = false, bool italic = false)
            {
                D2DFont f = _device.CreateFont(new FontOptions()
                {
                    Bold           = bold,
                    FontFamilyName = "Arial",
                    FontSize       = size,
                    Italic         = italic,
                    WordWrapping   = true
                });

                device.DrawText(text, new Point(x, y), f, GetDXColor(color));
            }

            void DrawTextWithBackground(string text, float x, float y, int size, Color color, Color backcolor, bool bold = false, bool italic = false)
            {
                D2DFont f = _device.CreateFont(new FontOptions()
                {
                    Bold           = bold,
                    FontFamilyName = "Arial",
                    FontSize       = size,
                    Italic         = italic,
                    WordWrapping   = true
                });

                device.DrawTextWithBackground(text, new Point(x, y), f, GetDXColor(color), GetDXColor(backcolor));
            }

            void DrawLine(float fromx, float fromy, float tox, float toy, Color color, float thiccness = 2.0f)
            {
                device.DrawLine(fromx, fromy, tox, toy, thiccness, GetDXColor(color));
            }

            void DrawFilledRectangle(float x, float y, float width, float height, Color color)
            {
                device.FillRectangle(Rectangle.Create(x, y, width, height), GetDXColor(color));
            }

            void DrawCircle(float x, float y, float radius, Color color)
            {
                device.DrawCircle(new Circle(x, y, radius), 1, GetDXColor(color));
            }

            void DrawCrosshair(CrosshairStyle style, float x, float y, float size, float stroke, Color color)
            {
                device.DrawCrosshair(style, new Point(x, y), size, stroke, GetDXColor(color));
            }

            void DrawBox(float x, float y, float width, float height, Color color, float thiccness = 2.0f)
            {
                device.DrawRectangle(Rectangle.Create(x, y, width, height), thiccness, GetDXColor(color));
            }

            void DrawOutlineBox(float x, float y, float width, float height, Color color, float thiccness = 2.0f)
            {
                device.OutlineRectangle(Rectangle.Create(x, y, width, height), thiccness, GetDXColor(color), GetDXColor(Color.Black));
            }

            void DrawRoundedBox(float x, float y, float width, float height, float radius, Color color, float thiccness = 2.0f)
            {
                device.DrawRoundedRectangle(RoundedRectangle.Create(x, y, width, height, radius), thiccness, GetDXColor(color));
            }

            #endregion
        }
Beispiel #2
0
 /// <summary>
 /// Creates the specified x.
 /// </summary>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 /// <param name="radius">The radius.</param>
 /// <returns></returns>
 public static RoundedRectangle Create(float x, float y, float width, float height, float radius)
 {
     return(new RoundedRectangle(Rectangle.Create(x, y, width, height), radius));
 }