當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。