当前位置: 首页>>代码示例>>C#>>正文


C# Chunk.setBlock方法代码示例

本文整理汇总了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;
    }
开发者ID:Aden-Herold,项目名称:Voxel-RPG,代码行数:32,代码来源:TerrainGen.cs

示例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);
         	}
    }
开发者ID:Aden-Herold,项目名称:AzamRealms,代码行数:11,代码来源:TerrainGen.cs

示例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;
                    }
                }
            }
        }
        */
    }
开发者ID:AlexanderMazaletskiy,项目名称:YetAnotherMinecraftClone,代码行数:86,代码来源:Terragen.cs


注:本文中的Chunk.setBlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。