示例#1
0
        public override void BuildWorldChunk(WorldData world, Chunk chunk)
        {
            IntVec3 size = world.ChunkSizeBlocks;

            for (int x = 0; x < size.x; x++)
            {
                for (int z = 0; z < size.z; z++)
                {
                    int height = Random.Range(1, 10);
                    for (int y = 0; y < height; y++)
                    {
                        world.SetBlock(
                            x + chunk.WorldPos.x,
                            y + chunk.WorldPos.y,
                            z + chunk.WorldPos.z,
                            m_SolidBlock);
                    }
                }
            }
        }
示例#2
0
        private float[,]  m_HeightField;    // heightfield for landscape

        // Initialise the worldbuilder by creating a heightfield
        public override void Init(WorldData world)
        {
            m_HeightField = new float[world.WorldSizeBlocks.x, world.WorldSizeBlocks.z];
            int worldHeightInBlocks = world.WorldSizeBlocks.y;
            int minimumGroundheight = worldHeightInBlocks / 4;
            int groundheightRange   = (int)(worldHeightInBlocks * 0.75f);

            for (int blockX = 0; blockX < world.WorldSizeBlocks.x; blockX++)
            {
                for (int blockZ = 0; blockZ < world.WorldSizeBlocks.z; blockZ++)
                {
                    float octave1           = PerlinSimplexNoise.noise(blockX * 0.0001f, blockZ * 0.0001f) * 0.5f;
                    float octave2           = PerlinSimplexNoise.noise(blockX * 0.0005f, blockZ * 0.0005f) * 0.25f;
                    float octave3           = PerlinSimplexNoise.noise(blockX * 0.005f, blockZ * 0.005f) * 0.12f;
                    float octave4           = PerlinSimplexNoise.noise(blockX * 0.01f, blockZ * 0.01f) * 0.12f;
                    float octave5           = PerlinSimplexNoise.noise(blockX * 0.03f, blockZ * 0.03f) * octave4;
                    float lowerGroundHeight = octave1 + octave2 + octave3 + octave4 + octave5;
                    lowerGroundHeight             = (lowerGroundHeight * groundheightRange) + minimumGroundheight;
                    m_HeightField[blockX, blockZ] = lowerGroundHeight;
                }
            }
        }
示例#3
0
 public virtual void Init(WorldData world)
 {
 }
示例#4
0
 public virtual void BuildWorldChunk(WorldData world, Chunk chunk)
 {
 }
示例#5
0
        private float m_BlockSize;                  // Size of block unit

        public GreedyMeshBuilder(WorldData worldData, float blockSize)
        {
            m_WorldData = worldData;
            m_BlockSize = blockSize;
        }
示例#6
0
 public Chunk(WorldData world, IntVec3 pos)
 {
     // chunk needs to know which world it belongs to and its world position in voxel coords
     m_World    = world;
     m_WorldPos = pos;
 }
 public MarchingCubesMeshBuilder(WorldData worldData, float blockSize)
 {
     m_WorldData = worldData;
     m_BlockSize = blockSize;
 }
示例#8
0
 public override void Init(WorldData world)
 {
 }