Exemplo n.º 1
0
    public void UpdateSplit()
    {
        if (destructible == null)
        {
            destructible = GetComponent <D2D_Destructible>();
        }

        BeginSplitting();
        {
            // Find which pixels are solid
            for (var y = 0; y < height; y++)
            {
                for (var x = 0; x < width; x++)
                {
                    cells.Add(alphaTex.GetPixel(x, y).a >= Threshold);
                }
            }

            // Go through all pixels
            for (var i = 0; i < total; i++)
            {
                // First pixel of unclaimed island?
                if (cells[i] == true)
                {
                    splitGroup = D2D_SplitBuilder.CreateGroup();

                    BeginFloodFill(i, i % width, i / width);
                }
            }
        }
        EndSplitting();
    }
Exemplo n.º 2
0
    public void UpdateSplit()
    {
        if (destructible == null) destructible = GetComponent<D2D_Destructible>();

        BeginSplitting();
        {
            // Find which pixels are solid
            for (var y = 0; y < height; y++)
            {
                for (var x = 0; x < width; x++)
                {
                    cells.Add(alphaTex.GetPixel(x, y).a >= Threshold);
                }
            }

            // Go through all pixels
            for (var i = 0; i < total; i++)
            {
                // First pixel of unclaimed island?
                if (cells[i] == true)
                {
                    splitGroup = D2D_SplitBuilder.CreateGroup();

                    BeginFloodFill(i, i % width, i / width);
                }
            }
        }
        EndSplitting();
    }
Exemplo n.º 3
0
    private static void Split(D2D_Destructible destructible, D2D_SplitGroup group, bool isClone)
    {
        var subX      = group.XMin;
        var subY      = group.YMin;
        var subWidth  = group.XMax - group.XMin + 1;
        var subHeight = group.YMax - group.YMin + 1;
        var subTotal  = subWidth * subHeight;
        var subAlpha  = new byte[subTotal];

        for (var i = group.Count - 1; i >= 0; i--)
        {
            var j = group.Indices[i];
            var a = group.Alphas[i];
            var x = (j % AlphaTexWidth) - subX;
            var y = (j / AlphaTexWidth) - subY;
            var s = x + y * subWidth;

            subAlpha[s] = a;
        }

        destructible.SubsetAlphaWith(subAlpha, subWidth, subHeight, subX, subY);

        // Split notification
        D2D_Helper.BroadcastMessage(destructible.transform, "OnDestructibleSplit", splitData, SendMessageOptions.DontRequireReceiver);
    }