Ejemplo n.º 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);
                    }
                }
            }
        }
    }