예제 #1
0
    private void SpawnDebris(VoxelObject sourceData, VoxelData data, Vector3 position, Quaternion rotation, Vector3 sprayDirection, int skip)
    {
        int counter = 0;

        for (int x = 0; x < data.Width; ++x)
        {
            for (int y = 0; y < data.Height; ++y)
            {
                for (int z = 0; z < data.Depth; ++z)
                {
                    Voxel voxel = data.GetVoxel(x, y, z);

                    if (!voxel.IsEmpty && ((++counter) % skip) == 0)
                    {
                        Color colour = m_AtlasTexture.GetPixel((int)voxel.m_ColourIndex - 1, 0);

                        VoxelDebris debris = VoxelDebris.NewDebris(m_DebrisType, sourceData, voxel, m_DebrisLifetime, position + rotation * data.GetVoxelPosition(x, y, z, sourceData.m_Scale), rotation);

                        debris.SetColour(colour);
                        debris.ApplyExplostion(m_ExplosiveForce, position, sprayDirection);
                    }
                }
            }
        }
    }
예제 #2
0
    public static VoxelDebris NewDebris(VoxelDebris source, VoxelObject sourceData, Voxel voxel, float lifeTime, Vector3 position, Quaternion rotation)
    {
        VoxelDebris debris = ObjectPooler.Main.GetObject(source.gameObject, position, rotation).GetComponent <VoxelDebris>();

        debris.m_Tracker            = 0.0f;
        debris.m_Lifetime           = lifeTime;
        debris.m_Scale              = sourceData.m_Scale;
        debris.transform.localScale = Vector3.one * sourceData.m_Scale;

        if (debris.m_Body != null)
        {
            debris.m_Body.velocity = Vector3.zero;
        }

        return(debris);
    }