예제 #1
0
    private static void CompileTracedEdges(D2D_PolygonSpriteCollider.Cell colliderCell, int pathCount)
    {
        if (colliderCell.Collider.pathCount <= pathCount)
        {
            colliderCell.Collider.pathCount += 1;
        }

        colliderCell.Collider.SetPath(pathCount, ExtractTracedEdges());
    }
예제 #2
0
    public static void Build(GameObject gameObject, D2D_PolygonSpriteCollider.Cell colliderCell, float detail)
    {
        if (gameObject != null && colliderCell != null)
        {
            if (colliderCell.Collider == null)
            {
                colliderCell.Collider = gameObject.AddComponent <PolygonCollider2D>();
            }

            var pathCount = 0;

            for (var i = 0; i < cellCount; i++)
            {
                var cell = cells[i];

                for (var j = 0; j < cell.PointCount; j++)
                {
                    var point = cellPoints[cell.PointIndex + j];

                    if (point.Used == false)
                    {
                        TraceEdges(cell, point);

                        TrimLoop();
                        WeldLines();
                        OptimizeEdges(detail);

                        if (tracedEdges.Count >= 3)
                        {
                            CompileTracedEdges(colliderCell, pathCount); pathCount += 1;
                        }
                    }
                }
            }

            colliderCell.Trim(pathCount);
        }
    }