Ejemplo n.º 1
0
        public TRect LimitInside(TRect rect)
        {
            TRect _rect = new TRect(x, y, width - rect.width * 0.5f, height - rect.height * 0.5f);
            var   pos   = _rect.LimitInside(new Vector2(rect.x, rect.y));

            return(new TRect(pos, rect.size));
        }
Ejemplo n.º 2
0
 public void Show(TRect rect, Color color)
 {
     m_type  = EGraphType.Rect;
     m_rect  = rect;
     m_color = color;
     isShow  = true;
 }
Ejemplo n.º 3
0
        public TCircle LimitInside(TCircle circle)
        {
            float   newWidth  = Mathf.Max(0, width - circle.radius * 2);
            float   newHeight = Mathf.Max(0, height - circle.radius * 2);
            TRect   newRect   = new TRect(x, y, newWidth, newHeight);
            Vector2 circlePos = newRect.LimitInside(circle.center);

            return(new TCircle(circlePos, circle.radius));
        }
Ejemplo n.º 4
0
        public TRect LimitInside2(TRect rect)
        {
            float   newWidth  = Mathf.Max(0, width - rect.width);
            float   newHeight = Mathf.Max(0, height - rect.height);
            TRect   newRect   = new TRect(x, y, newWidth, newHeight);
            Vector2 circlePos = newRect.LimitInside2(rect.center);

            return(new TRect(circlePos, rect.size));
        }
Ejemplo n.º 5
0
        public static void DrawRect(TRect rect, Color color, string drawOncePerFrameKey = null)
        {
            if (ins == null || !CheckDrawCount(drawOncePerFrameKey))
            {
                return;
            }
            var item = ins.CreateGraph();

            if (item != null)
            {
                item.Show(rect, color);
            }
        }
Ejemplo n.º 6
0
        public bool IsOverLapWith(TRect rect)
        {
            float verticalDistance    = Mathf.Abs(y - rect.y);;     //垂直距离
            float horizontalDistance  = Mathf.Abs(x - rect.x);;     //水平距离
            float verticalThreshold   = (height + rect.height) / 2; //两矩形分离的垂直临界值
            float horizontalThreshold = (width + rect.width) / 2;   //两矩形分离的水平临界值

            if (verticalDistance > verticalThreshold || horizontalDistance > horizontalThreshold)
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 7
0
        public void DrawScreenRect(TRect rect, Color color)
        {
            Begin(color);
            GL.Vertex3(rect.left / Screen.width, rect.top / Screen.height, 0);
            GL.Vertex3(rect.left / Screen.width, rect.bottom / Screen.height, 0);

            GL.Vertex3(rect.left / Screen.width, rect.bottom / Screen.height, 0);
            GL.Vertex3(rect.right / Screen.width, rect.bottom / Screen.height, 0);

            GL.Vertex3(rect.right / Screen.width, rect.bottom / Screen.height, 0);
            GL.Vertex3(rect.right / Screen.width, rect.top / Screen.height, 0);

            GL.Vertex3(rect.right / Screen.width, rect.top / Screen.height, 0);
            GL.Vertex3(rect.left / Screen.width, rect.top / Screen.height, 0);

            End();
        }
Ejemplo n.º 8
0
        public bool IsOverLapWith(TRect rect)
        {
            float halfWidth  = rect.width * 0.5f;
            float halfHeight = rect.height * 0.5f;
            float distanceX  = Mathf.Abs(x - rect.x);
            float distanceY  = Mathf.Abs(y - rect.y);

            if (distanceX > (halfWidth + radius) || distanceY > (halfHeight + radius))
            {
                return(false);
            }
            else if (distanceX <= halfWidth || distanceY <= halfHeight)
            {
                return(true);
            }
            float sq = (distanceX - halfWidth) * (distanceX - halfWidth)
                       + (distanceY - halfHeight) * (distanceY - halfHeight);

            return(sq <= radius * radius);
        }
Ejemplo n.º 9
0
 public static TRect Lerp(TRect a, TRect b, float t)
 {
     return(new TRect(Vector2.Lerp(a.center, b.center, t), Vector2.Lerp(a.size, b.size, t)));
 }
Ejemplo n.º 10
0
        void UpdateDraw()
        {
            foreach (var player in collector.players)
            {
                var model = player.model;
                if (!player.isValid)
                {
                    continue;
                }
                // if (player.isMainPlayer)
                //     continue;
                if (!Settings.isEspFriendly && player.isFriend)
                {
                    continue;
                }
                if (!model.root.gameObject.activeInHierarchy)
                {
                    continue;
                }

                var rect  = model.GetRect();
                var color = player.isFriend ? Color.green : Color.red;

                // NAME
                var tempRect = rect;
                tempRect.y = Screen.height - tempRect.y;
                var nameRect = new Rect(tempRect.center, tempRect.size);
                nameRect.y     -= nameRect.height * 0.5f + 30;
                nameRect.x      = nameRect.x - 100;
                nameRect.height = 20;
                nameRect.width  = 200;
                Color      contentColor   = GUI.contentColor;
                TextAnchor labelAlignment = GUI.skin.label.alignment;
                GUI.contentColor         = Color.black;
                GUI.skin.label.alignment = TextAnchor.MiddleCenter;
                GUI.Label(nameRect, player.name);
                nameRect.position -= Vector2.one;
                GUI.contentColor   = color;
                GUI.Label(nameRect, player.name);
                GUI.contentColor         = contentColor;
                GUI.skin.label.alignment = labelAlignment;

                if (Settings.isEspBox)
                {
                    if (rect.height != 0)
                    {
                        D_R(model.GetRect(), color);
                    }
                }

                if (Settings.isEspBoneLine)
                {
                    foreach (var line in model.GetLines())
                    {
                        D_L(line, color);
                    }
                }

                if (Settings.isEspAirLine)
                {
                    if (rect.height != 0)
                    {
                        var boxTopCenter    = new Vector2(rect.x, rect.top);
                        var screenTopCenter = new Vector2(Screen.width * 0.5f, Screen.height);
                        D_L(new TLine(boxTopCenter, screenTopCenter), color);
                    }
                }

                if (Settings.isEspHp)
                {
                    if (rect.height != 0)
                    {
                        var x  = rect.right + 4;
                        var y  = rect.bottom + 1;
                        var h  = 1f * (rect.height - 2) * player.hpRatio;
                        var p1 = new Vector2(x, y);
                        var p2 = new Vector2(x, y + h);
                        D_L(new TLine(p1, p2), color);
                        p1.x += 1; p2.x += 1;
                        D_L(new TLine(p1, p2), color);
                        p1.x += 1; p2.x += 1;
                        D_L(new TLine(p1, p2), color);
                        var bgRect = new TRect(x + 1, rect.center.y, 5, rect.height);
                        D_R(bgRect, Color.black * 0.7f);
                    }
                }
            }
        }
Ejemplo n.º 11
0
 private void D_R(TRect r, Color color)
 {
     GizmosPro.DrawRect(r, color);
 }
Ejemplo n.º 12
0
 public TEllipse(TRect boundingRect) : this(boundingRect.center, boundingRect.size)
 {
 }