Example #1
0
    protected virtual void Update()
    {
        if (destructible == null) destructible = GetComponent<D2D_Destructible>();
        if (splittable   == null) splittable   = GetComponent<D2D_Splittable>();
        if (fracturer    == null) fracturer    = GetComponent<D2D_Fracturer>();

        var splitDepth = destructible.SplitDepth;
        var pixelCount = destructible.SolidPixelCount;

        if (pixelCount < MinPixelsForDestructible || splitDepth > MaxDepthForDestructible)
        {
            destructible.Indestructible = true;
        }

        if (splittable != null)
        {
            if (pixelCount < MinPixelsForSplitting || splitDepth > MaxDepthForSplitting)
            {
                D2D_Helper.Destroy(splittable);
            }
        }

        if (fracturer != null)
        {
            if (pixelCount < MinPixelsForFracturing || splitDepth > MaxDepthForFracturing)
            {
                D2D_Helper.Destroy(fracturer);
            }
        }
    }
Example #2
0
    protected virtual void Update()
    {
        if (destructible == null)
        {
            destructible = GetComponent <D2D_Destructible>();
        }
        if (splittable == null)
        {
            splittable = GetComponent <D2D_Splittable>();
        }
        if (fracturer == null)
        {
            fracturer = GetComponent <D2D_Fracturer>();
        }

        var splitDepth = destructible.SplitDepth;
        var pixelCount = destructible.SolidPixelCount;

        if (pixelCount < MinPixelsForDestructible || splitDepth > MaxDepthForDestructible)
        {
            destructible.Indestructible = true;
        }

        if (splittable != null)
        {
            if (pixelCount < MinPixelsForSplitting || splitDepth > MaxDepthForSplitting)
            {
                D2D_Helper.Destroy(splittable);
            }
        }

        if (fracturer != null)
        {
            if (pixelCount < MinPixelsForFracturing || splitDepth > MaxDepthForFracturing)
            {
                D2D_Helper.Destroy(fracturer);
            }
        }
    }