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


C# IChunk.GetType方法代码示例

本文整理汇总了C#中IChunk.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IChunk.GetType方法的具体用法?C# IChunk.GetType怎么用?C# IChunk.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IChunk的用法示例。


在下文中一共展示了IChunk.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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);
                                    
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:TheaP,项目名称:c-raft,代码行数:70,代码来源:CustomChunkGenerator.cs

示例2: CanSeeTheSky

        private bool CanSeeTheSky(int x, int y, int z, IChunk c)
        {
            int by;
            for (by = y; _blockHelper.Opacity(c.GetType(x, by, z)) == 0 && by < 128; ++by) ;

            return by == 128;
        }
开发者ID:TheaP,项目名称:c-raft,代码行数:7,代码来源:CustomChunkGenerator.cs

示例3: GenerateTerrain

        private void GenerateTerrain(IChunk c, int x, int z)
        {           
            double[, ,] density = new double[17, 129, 17];

            // Build the density map with lower resolution, 4*4*16 instead of 16*16*128
            for (int bx = 0; bx <= 16; bx += 4)
            {
                int worldX = bx + (x * 16);
                for (int bz = 0; bz <= 16; bz += 4)
                {
                    BIOME_TYPE type = CalcBiomeType(x, z);
                    int worldZ = bz + (z * 16);
                    for (int by = 0; by <= 128; by += 8)
                    {
                        density[bx, by, bz] = CalcDensity(worldX, by, worldZ, type);
                    }
                }
            }

            triLerpDensityMap(density);

            for (int bx = 0; bx < 16; bx++)
            {
                int worldX = bx + (x * 16);
                for (int bz = 0; bz < 16; bz++)
                {
                    int worldZ = bz + (z * 16);
                    int firstBlockHeight = -1;

                    BIOME_TYPE type = CalcBiomeType(worldX, worldZ);
                    for (int by = 127; by >= 0; --by)
                    {
                        //int index = bx << 11 | bz << 7 | by;
                        if (by == 0) // First bedrock Layer
                            c.SetType(bx, by, bz, BlockData.Blocks.Bedrock, false);

                        else if (by > 0 && by < 5 && _FastRandom.randomDouble() > 0.3) // Randomly put blocks of the remaining 4 layers of bedrock
                            c.SetType(bx, by, bz, BlockData.Blocks.Bedrock, false);

                        else if (by <= 55)
                            c.SetType(bx, by, bz, BlockData.Blocks.Stone, false);
                        else
                        {
                            if (by > 55 && by < 64)
                            {
                                c.SetType(bx, by, bz, BlockData.Blocks.Still_Water, false);
                                if (by == 63 && type == BIOME_TYPE.SNOW)
                                {
                                    c.SetBiomeColumn(bx, bz, (byte)BIOME_TYPE.SNOW);
                                    c.SetType(bx, by, bz, BlockData.Blocks.Ice, false);
                                }
                            }

                            double dens = density[bx, by, bz];

                            if (dens >= 0.009 && dens <= 0.02)
                            {
                                // Some block was set...
                                if (firstBlockHeight == -1)
                                    firstBlockHeight = by;

                                GenerateOuterLayer(bx, by, bz, firstBlockHeight, type, c);
                            }
                            else if (dens > 0.02)
                            {
                                // Some block was set...
                                if (firstBlockHeight == -1)
                                    firstBlockHeight = by;

                                if (CalcCaveDensity(worldX, by, worldZ) > -0.6)
                                    GenerateInnerLayer(bx, by, bz, type, c);
                            }
                            else
                                firstBlockHeight = -1;
                        }

                        if (c.GetType(bx, by, bz) == BlockData.Blocks.Stone)
                            GenerateResource(bx, by, bz, c);
                    }
                }
            }
        }
开发者ID:TheaP,项目名称:c-raft,代码行数:82,代码来源:CustomChunkGenerator.cs


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