當前位置: 首頁>>代碼示例>>C#>>正文


C# Chunk.SetAllBlocks方法代碼示例

本文整理匯總了C#中Chunk.SetAllBlocks方法的典型用法代碼示例。如果您正苦於以下問題:C# Chunk.SetAllBlocks方法的具體用法?C# Chunk.SetAllBlocks怎麽用?C# Chunk.SetAllBlocks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Chunk的用法示例。


在下文中一共展示了Chunk.SetAllBlocks方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ProvideChunk

        private Chunk ProvideChunk(int x, int z, Chunk chunk)
        {
            /*Stopwatch watch = new Stopwatch();

            watch.Start();*/
            InitGen();
            byte[] data = new byte[32768];

            double[, ,] density = new double[17, 129, 17];

            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((int)x, (int)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)
                    {
                        if (by <= 55)
                            data[bx << 11 | bz << 7 | by] = (byte)BlockData.Blocks.Stone;
                        else
                        {
                            if (by > 55 && by < 64)
                            {
                                data[bx << 11 | bz << 7 | by] = (byte)BlockData.Blocks.Still_Water;
                                if (by == 63 && type == BIOME_TYPE.SNOW)
                                {
                                    data[bx << 11 | bz << 7 | by] = (byte)BlockData.Blocks.Ice;
                                }
                            }

                            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, data);
                            }
                            else if (dens > 0.02)
                            {
                                // Some block was set...
                                if (firstBlockHeight == -1)
                                    firstBlockHeight = by;
                                GenerateInnerLayer(bx, by, bz, type, data);
                            }
                        }
                    }
                }
            }

            //watch.Stop();

            //Console.WriteLine(watch.ElapsedMilliseconds);

            chunk.SetAllBlocks(data);

            return chunk;
        }
開發者ID:RevolutionSmythe,項目名稱:c-raft,代碼行數:79,代碼來源:CustomGen.cs


注:本文中的Chunk.SetAllBlocks方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。