Exemplo n.º 1
0
        private void RebuildCell(D2dEdgeColliderCell cell, int x, int y)
        {
            var xMin = CellSize * x;
            var yMin = CellSize * y;
            var xMax = Mathf.Min(CellSize + xMin, destructible.AlphaWidth);
            var yMax = Mathf.Min(CellSize + yMin, destructible.AlphaHeight);

            D2dColliderBuilder.CalculateEdge(destructible.AlphaData, destructible.AlphaWidth, destructible.AlphaHeight, xMin, xMax, yMin, yMax);

            D2dColliderBuilder.BuildEdge(cell, unusedColliders, child, Detail);

            cell.UpdateColliderSettings(IsTrigger, Material);
        }
        private void RebuildCell(ref D2dEdgeColliderCell cell, int cellX, int cellY)
        {
            var xMin = CellSize * cellX;
            var yMin = CellSize * cellY;
            var xMax = Mathf.Min(CellSize + xMin, destructible.AlphaWidth);
            var yMax = Mathf.Min(CellSize + yMin, destructible.AlphaHeight);

            if (xMin > 0)
            {
                xMin += 1;
            }
            if (yMin > 0)
            {
                yMin += 1;
            }
            if (xMax < destructible.AlphaWidth)
            {
                xMax -= 1;
            }
            if (yMax < destructible.AlphaHeight)
            {
                yMax -= 1;
            }

            D2dColliderBuilder.AlphaData   = destructible.AlphaData;
            D2dColliderBuilder.AlphaWidth  = destructible.AlphaWidth;
            D2dColliderBuilder.AlphaHeight = destructible.AlphaHeight;
            D2dColliderBuilder.MinX        = xMin;
            D2dColliderBuilder.MinY        = yMin;
            D2dColliderBuilder.MaxX        = xMax;
            D2dColliderBuilder.MaxY        = yMax;

            D2dColliderBuilder.CalculateEdgeCells();

            if (cell == null)
            {
                cell = D2dEdgeColliderCell.Get();
            }

            cell.Clear(tempColliders);

            D2dColliderBuilder.BuildEdge(cell, tempColliders, child, Weld, Detail);

            cell.UpdateColliderSettings(IsTrigger, Material);
        }