本文整理汇总了C#中IChunk.SetData方法的典型用法代码示例。如果您正苦于以下问题:C# IChunk.SetData方法的具体用法?C# IChunk.SetData怎么用?C# IChunk.SetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IChunk
的用法示例。
在下文中一共展示了IChunk.SetData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateTree
private void GenerateTree(IChunk c, int x, int y, int z)
{
// Trees should only be placed in direct sunlight
if (!CanSeeTheSky(x, y + 1, z, c))
return;
double r2 = _FastRandom.standNormalDistrDouble();
/*if (r2 > -2 && r2 < -1)
{*/
// Standard tree
for (int by = y + 4; by < y + 6; by++)
for (int bx = x - 2; bx <= x + 2; bx++)
for (int bz = z - 2; bz <= z + 2; bz++)
{
c.SetType(bx, by, bz, BlockData.Blocks.Leaves, false);
c.SetData(bx, by, bz, 0, false);
}
for (int bx = x - 1; bx <= x + 1; bx++)
for (int bz = z - 1; bz <= z + 1; bz++)
{
c.SetType(bx, y + 6, bz, BlockData.Blocks.Leaves, false);
c.SetData(bx, y + 6, bz, 0, false);
}
for (int by = y + 1; by < y + 6; by++)
{
c.SetType(x, by, z, BlockData.Blocks.Wood, false);
c.SetData(x, by, z, 0, false);
}
//}
// TODO: other tree types
/*else if (r2 > 1 && r2 < 2)
{
c.setBlock(x, y + 1, z, (byte)0x0);
c.getParent().getObjectGenerator("firTree").generate(c.getBlockWorldPosX(x), y + 1, c.getBlockWorldPosZ(z), false);
}
else
{
c.setBlock(x, y + 1, z, (byte)0x0);
c.getParent().getObjectGenerator("tree").generate(c.getBlockWorldPosX(x), y + 1, c.getBlockWorldPosZ(z), false);
}*/
}
示例2: GenerateFlora
private void GenerateFlora(IChunk c, int x, int z)
{
BIOME_TYPE biome = CalcBiomeType(x, z);
for (int bx = 0; bx < 16; ++bx)
{
int worldX = bx + x * 16;
for (int bz = 0; bz < 16; ++bz)
{
int worldZ = bz + z * 16;
for (int by = 64; by < 128; ++by)
{
int worldY = by;
//int index = bx << 11 | bz << 7 | by + 1;
if (c.GetType(bx, by, bz) == BlockData.Blocks.Grass && c.GetType(bx, by + 1, bz) == (byte)BlockData.Blocks.Air)
{
double grassDens = CalcGrassDensity(worldX, worldZ);
if (grassDens > 0.0)
{
// Generate high grass.
double rand = _FastRandom.standNormalDistrDouble();
if (rand > -0.2 && rand < 0.2)
{
c.SetType(bx, by + 1, bz, BlockData.Blocks.TallGrass, false);
c.SetData(bx, by + 1, bz, 1, false);
}
//Generate flowers.
if (_FastRandom.standNormalDistrDouble() < -2)
{
if (_FastRandom.randomBoolean())
c.SetType(bx, by + 1, bz, BlockData.Blocks.Rose, false);
else
c.SetType(bx, by + 1, bz, BlockData.Blocks.Yellow_Flower, false);
}
}
if (by < 110 && bx % 4 == 0 && bz % 4 == 0)
{
double forestDens = CalcForestDensity(worldX, worldZ);
if (forestDens > 0.005)
{
int randX = bx + _FastRandom.randomInt() % 12 + 4;
int randZ = bz + _FastRandom.randomInt() % 12 + 4;
if (randX < 3)
randX = 3;
else if (randX > 12)
randX = 12;
if (randZ < 3)
randZ = 3;
else if (randZ > 15)
randZ = 12;
if (c.GetType(randX, by, randZ) == BlockData.Blocks.Grass)
GenerateTree(c, randX, by, randZ);
else if (biome == BIOME_TYPE.DESERT && c.GetType(randX, by, randZ) == BlockData.Blocks.Sand)
GenerateCactus(c, randX, by, randZ);
}
}
}
}
}
}
}