本文整理汇总了C#中Chunk.setBlock方法的典型用法代码示例。如果您正苦于以下问题:C# Chunk.setBlock方法的具体用法?C# Chunk.setBlock怎么用?C# Chunk.setBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chunk
的用法示例。
在下文中一共展示了Chunk.setBlock方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChunkColumnGen
public Chunk ChunkColumnGen(Chunk chunk, int x, int z)
{
int stoneHeight = Mathf.FloorToInt(stoneBaseHeight);
stoneHeight += GetNoise(x, 0, z, stoneMountainFrequency, Mathf.FloorToInt(stoneMountainHeight));
if (stoneHeight < stoneMinHeight)
stoneHeight = Mathf.FloorToInt(stoneMinHeight);
stoneHeight += GetNoise(x, 0, z, stoneBaseNoise, Mathf.FloorToInt(stoneBaseNoiseHeight));
int dirtHeight = stoneHeight + Mathf.FloorToInt(dirtBaseHeight);
dirtHeight += GetNoise(x, 100, z, dirtNoise, Mathf.FloorToInt(dirtNoiseHeight));
for (int y = chunk.pos.y; y < chunk.pos.y + Chunk.chunkSize; y++)
{
if (y <= stoneHeight)
{
chunk.setBlock(x - chunk.pos.x, y - chunk.pos.y, z - chunk.pos.z, new Block());
}
else if (y <= dirtHeight)
{
chunk.setBlock(x - chunk.pos.x, y - chunk.pos.y, z - chunk.pos.z, new BlockGrass());
}
else
{
chunk.setBlock(x - chunk.pos.x, y - chunk.pos.y, z - chunk.pos.z, new BlockAir());
}
}
return chunk;
}
示例2: SetBlock
public static void SetBlock(int x, int y, int z, Block block, Chunk chunk, bool replaceBlocks = false)
{
x -= chunk.pos.x;
y -= chunk.pos.y;
z -= chunk.pos.z;
if (Chunk.inRange(x) && Chunk.inRange(y) && Chunk.inRange(z)) {
if (replaceBlocks || chunk.blocks[x, y, z] == null)
chunk.setBlock(x, y, z, block);
}
}
示例3: CreateLandscape
public static void CreateLandscape(Chunk chunk)
{
int chunkX = chunk.chunkPosWorld.x;
int chunkZ = chunk.chunkPosWorld.z;
//Block[, ,] blocks = chunk.blocks;
ChunkNoise noise = new ChunkNoise(seed: CONST.worldSeed);
// Calculate heightmap
float[,] heightmap = new float[chunkSizeX, chunkSizeZ];
noise.FillMap2D(heightmap, chunkX, chunkZ, octaves: 6, startFrequency: .03f, startAmplitude: 5);
// Fill chunk with blocks
for (int localX = 0; localX < CONST.chunkSize.x; localX++)
{
for (int localZ = 0; localZ < CONST.chunkSize.z; localZ++)
{
// Create ground
int height = Mathf.RoundToInt((CONST.worldDepthBlocks / 4) + heightmap[localX, localZ]);
/*
for (int y = 0; y < chunkSizeY; y++)
{
int blockWorldY = (int)chunk.blockOffset.y + y;
}
*/
// Create mountains
int worldX = (int)chunk.blockOffset.x + localX;
int worldZ = (int)chunk.blockOffset.z + localZ;
for (int y = 0; y < chunkSizeY; y++)
{
int blockWorldY = (int)chunk.blockOffset.y + y;
if (blockWorldY < height - 3)
{
//blocks[localX, y, localZ].blockType = BlockType.Air;
chunk.setBlock(localX, y, localZ, BlockType.Air);
}
else if (blockWorldY < height)
{
//blocks[localX, y, localZ].blockType = BlockType.Stone;
chunk.setBlock(localX, y, localZ, BlockType.Stone);
}
//if (blockWorldY >= height && blockWorldY < WorldGameObject.worldDepthBlocks)
else if (blockWorldY >= height)
{
float noiseValue3D = noise.GetValue3D(worldX, blockWorldY, worldZ, octaves: 6, startFrequency: .05f, startAmplitude: 1);
if (noiseValue3D < -0.3)
{
//blocks[localX, y, localZ].blockType = BlockType.Dirt;
chunk.setBlock(localX, y, localZ, BlockType.Dirt);
}
else
{
chunk.setBlock(localX, y, localZ, BlockType.Air);
//blocks[localX, y, localZ].blockType = BlockType.Air;
}
}
}
}
}
//chunk.blocks = blocks;
/*
for(int x = 0; x < chunkSizeX; x++)
{
for (int y = 0; y < chunkSizeY; y++)
{
for (int z = 0; z < chunkSizeZ; z++)
{
if(chunk.getBlock(x,y,z) != BlockType.Air)
{
chunk.anyNonAir = true;
}
}
}
}
*/
}