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


C# Chunk.SetData方法代码示例

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


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

示例1: Grow

        public void Grow(StructBlock block, Chunk chunk)
        {
            if (!CanGrow(block, chunk))
                return;

            UniversalCoords blockUp = UniversalCoords.FromWorld(block.Coords.WorldX, block.Coords.WorldY + 1, block.Coords.WorldZ);
            if (block.World.GetEffectiveLight(blockUp) < 9)
                return;

            // TODO: Check if the blocks nearby are hydrated and grow faster
            if (block.World.Server.Rand.Next(10) == 0)
                chunk.SetData(block.Coords, ++block.MetaData);
        }
开发者ID:dekema2,项目名称:c-raft,代码行数:13,代码来源:BlockCrops.cs

示例2: Grow

        public void Grow(StructBlock block, Chunk chunk)
        {
            if (!CanGrow(block, chunk))
                return;

            UniversalCoords blockUp = UniversalCoords.FromWorld(block.Coords.WorldX, block.Coords.WorldY + 1, block.Coords.WorldZ);
            if (block.World.GetEffectiveLight(blockUp) < 9)
                return;

            if (block.World.Server.Rand.Next(29) != 0)
                return;

            if ((block.MetaData & 8) == 0)
            {
                chunk.SetData(block.Coords, (byte)(block.MetaData | 8));
                return;
            }

            for (int i = block.Coords.WorldY; i < block.Coords.WorldY + 4; i++)
            {
                chunk.SetBlockAndData(block.Coords.BlockX, i, block.Coords.BlockZ, (byte)BlockData.Blocks.Log, block.MetaData);
                if(chunk.GetType(block.Coords.BlockX, i + 1, block.Coords.BlockZ) != BlockData.Blocks.Air)
                    break;
            }

            // Grow leaves
            for (int i = block.Coords.WorldY + 2; i < block.Coords.WorldY + 5; i++)
                for (int j = block.Coords.WorldX - 2; j <= block.Coords.WorldX + 2; j++)
                    for (int k = block.Coords.WorldZ - 2; k <= block.Coords.WorldZ + 2; k++)
                    {
                        Chunk nearbyChunk = block.World.GetChunkFromWorld(i, k, false, false);
                        if (nearbyChunk == null || (nearbyChunk.GetType(j & 0xF, i, k & 0xF) != BlockData.Blocks.Air))
                            continue;

                        nearbyChunk.SetBlockAndData(j & 0xF, i, k & 0xF, (byte)BlockData.Blocks.Leaves,
                                                        block.MetaData);
                    }

            for (int i = block.Coords.WorldX - 1; i <= block.Coords.WorldX + 1; i++)
                for (int j = block.Coords.WorldZ - 1; j <= block.Coords.WorldZ + 1; j++)
                {
                    Chunk nearbyChunk = block.World.GetChunkFromWorld(i, j, false, false);
                    if (nearbyChunk == null || nearbyChunk.GetType(i & 0xF, block.Coords.WorldY + 5, j & 0xF) != BlockData.Blocks.Air)
                        continue;

                    nearbyChunk.SetBlockAndData(i & 0xF, block.Coords.WorldY + 5, j & 0xF, (byte)BlockData.Blocks.Leaves,
                                                    block.MetaData);
                }
        }
开发者ID:IdentErr,项目名称:c-raft,代码行数:49,代码来源:BlockSapling.cs

示例3: Grow

        public void Grow(StructBlock block, Chunk chunk)
        {
            if (!CanGrow(block, chunk))
                return;

            if (block.MetaData < 0xe) // 14
            {
                chunk.SetData(block.Coords, ++block.MetaData);
                return;
            }

            chunk.SetData(block.Coords, 0);
            UniversalCoords blockAbove = UniversalCoords.FromWorld(block.Coords.WorldX, block.Coords.WorldY + 1,
                                                                   block.Coords.WorldZ);
            chunk.SetBlockAndData(blockAbove, (byte)BlockData.Blocks.Reed, 0x0);
        }
开发者ID:IdentErr,项目名称:c-raft,代码行数:16,代码来源:BlockReed.cs

示例4: Grow

        public void Grow(StructBlock block, Chunk chunk)
        {
            if (!CanGrow(block, chunk))
                return;

            UniversalCoords oneUp = UniversalCoords.FromWorld(block.Coords.WorldX, block.Coords.WorldY + 1, block.Coords.WorldZ);

            if (block.MetaData < 0xe) // 14
            {

                chunk.SetData(block.Coords, ++block.MetaData, false);
                return;
            }

            chunk.SetData(block.Coords, 0);
            chunk.SetBlockAndData(oneUp, (byte)BlockData.Blocks.Cactus, 0x0);
        }
开发者ID:IdentErr,项目名称:c-raft,代码行数:17,代码来源:BlockCactus.cs

示例5: Grow

        public void Grow(StructBlock block, Chunk chunk)
        {
            if (!CanGrow(block, chunk))
                return;

            UniversalCoords oneUp = UniversalCoords.FromWorld(block.Coords.WorldX, block.Coords.WorldY + 1, block.Coords.WorldZ);

            if (block.MetaData < 0xe) // 14
            {
                chunk.SetData(block.Coords, ++block.MetaData, false);
                return;
            }

            chunk.SetData(block.Coords, 0);
            StructBlock newCactus = new StructBlock(oneUp, (byte)Type, 0, block.World);
            Spawn(newCactus);
        }
开发者ID:dekema2,项目名称:c-raft,代码行数:17,代码来源:BlockCactus.cs

示例6: Grow

        public void Grow(StructBlock block, Chunk chunk)
        {
            if (!CanGrow(block, chunk))
                return;

            if (block.MetaData < 0xe) // 14
            {
                chunk.SetData(block.Coords, ++block.MetaData);
                return;
            }

            chunk.SetData(block.Coords, 0);
            UniversalCoords blockAbove = UniversalCoords.FromWorld(block.Coords.WorldX, block.Coords.WorldY + 1,
                                                                   block.Coords.WorldZ);
            StructBlock newReed = new StructBlock(blockAbove, (byte)Type, 0, block.World);
            BlockHelper.Instance((byte)Type).Spawn(newReed);
        }
开发者ID:dekema2,项目名称:c-raft,代码行数:17,代码来源:BlockReed.cs


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