예제 #1
0
        public static void DrawBounds(Bounds bounds, Color color)
        {
            Vector2 v0 = bounds.min;
            Vector2 v1 = new Vector2(bounds.min.x, bounds.max.y);
            Vector2 v2 = bounds.max;
            Vector2 v3 = new Vector2(bounds.max.x, bounds.min.y);

            DrawUtil.DrawLine(v0, v1, color);
            DrawUtil.DrawLine(v1, v2, color);
            DrawUtil.DrawLine(v2, v3, color);
            DrawUtil.DrawLine(v3, v0, color);
        }
예제 #2
0
        public static void DrawEdge(EdgeCollider2D col, Color color)
        {
            List <Vector2> list = new List <Vector2>();

            foreach (var point in col.points)
            {
                list.Add(col.transform.TransformPoint(point + col.offset));
            }

            for (int i = 1; i < list.Count; i++)
            {
                DrawUtil.DrawLine(list[i - 1], list[i], color);
            }
        }
예제 #3
0
        public static void DrawBox(BoxCollider2D col, Color color)
        {
            float halfSizeX = col.size.x / 2.0f;
            float halfSizeY = col.size.y / 2.0f;

            Vector2 v0 = col.transform.TransformPoint(col.offset.x - halfSizeX, col.offset.y - halfSizeY, 0f);
            Vector2 v1 = col.transform.TransformPoint(col.offset.x + halfSizeX, col.offset.y - halfSizeY, 0f);
            Vector2 v2 = col.transform.TransformPoint(col.offset.x + halfSizeX, col.offset.y + halfSizeY, 0f);
            Vector2 v3 = col.transform.TransformPoint(col.offset.x - halfSizeX, col.offset.y + halfSizeY, 0f);

            DrawUtil.DrawLine(v0, v1, color);
            DrawUtil.DrawLine(v1, v2, color);
            DrawUtil.DrawLine(v2, v3, color);
            DrawUtil.DrawLine(v3, v0, color);
        }
예제 #4
0
        public static void DrawPolygon(PolygonCollider2D col, Color color)
        {
            List <Vector2> list = new List <Vector2>();

            foreach (var point in col.points)
            {
                list.Add(col.transform.TransformPoint(point + col.offset));
            }

            Vector2 last = list[0];
            Vector2 current;

            for (int i = 1; i < list.Count; i++)
            {
                current = list[i];
                DrawUtil.DrawLine(last, current, color);
                last = current;
            }
            DrawUtil.DrawLine(last, list[0], color);
        }
예제 #5
0
        public static void DrawCircle(CircleCollider2D col, Color color)
        {
            Vector2 last = col.transform.TransformPoint(col.radius * new Vector2(1, 0) + col.offset);
            Vector2 current;

            for (int i = 1; i <= circleEdgeCount; i++)
            {
                double rad = i * 2.0 * Math.PI / circleEdgeCount;

                float x = Convert.ToSingle(Math.Cos(rad));
                float y = Convert.ToSingle(Math.Sin(rad));

                Vector2 localPos = col.radius * new Vector2(x, y) + col.offset;

                current = col.transform.TransformPoint(localPos);

                DrawUtil.DrawLine(last, current, color);

                last = current;
            }
        }
예제 #6
0
        public static void OnFixedGUI()
        {
            //Draw ground detection lines
            foreach (DrawUtil.Line line in lineList)
            {
                DrawUtil.DrawLine(line);
            }

            GameManager gm = GameManager.instance;

            if (gm == null)
            {
                return;
            }

            PlayerNew player = gm.Player;

            if (player == null)
            {
                return;
            }

            if (Main.settings.DisplayPlayerPositionAndVelocity)
            {
                DrawPlayerPosition(player);
            }

            if (player.door)
            {
                DrawUtil.DrawText("Door: " + player.door.doorID);
            }
            else
            {
                DrawUtil.DrawText("No door");
            }

            CollisionDrawer.DrawCircle(player.circleCollider, Color.white);
            CollisionDrawer.DrawCircle((CircleCollider2D)player.topCollider, Color.white);
        }