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


C# IChunk.SetBlockID方法代码示例

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


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

示例1: Decorate

 public void Decorate(IWorld world, IChunk chunk, IBiomeRepository biomes)
 {
     for (int x = 0; x < Chunk.Width; x++)
     {
         for (int z = 0; z < Chunk.Depth; z++)
         {
             var biome = biomes.GetBiome(chunk.Biomes[x * Chunk.Width + z]);
             var height = chunk.HeightMap[x * Chunk.Width + z];
             for (int y = height; y <= WaterLevel; y++)
             {
                 var blockLocation = new Coordinates3D(x, y, z);
                 int blockId = chunk.GetBlockID(blockLocation);
                 if (blockId.Equals(AirBlock.BlockID))
                 {
                     chunk.SetBlockID(blockLocation, biome.WaterBlock);
                     var below = blockLocation + Coordinates3D.Down;
                     if (!chunk.GetBlockID(below).Equals(AirBlock.BlockID) && !chunk.GetBlockID(below).Equals(biome.WaterBlock))
                     {
                         if (!biome.WaterBlock.Equals(LavaBlock.BlockID) && !biome.WaterBlock.Equals(StationaryLavaBlock.BlockID))
                         {
                             var random = new Random(world.Seed);
                             if (random.Next(100) < 40)
                             {
                                 chunk.SetBlockID(below, ClayBlock.BlockID);
                             }
                             else
                             {
                                 chunk.SetBlockID(below, SandBlock.BlockID);
                             }
                         }
                     }
                 }
             }
             for (int y = 4; y < height / 8; y++)
             {
                 var blockLocation = new Coordinates3D(x, y, z);
                 int blockId = chunk.GetBlockID(blockLocation);
                 if (blockId.Equals(AirBlock.BlockID))
                 {
                     chunk.SetBlockID(blockLocation, LavaBlock.BlockID);
                 }
             }
         }
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:45,代码来源:LiquidDecorator.cs

示例2: GenerateTopper

 /*
  * Generates the top of the pine/conifer trees.
  * Type:
  * 0x0 - two level topper
  * 0x1 - three level topper
  */
 protected void GenerateTopper(IChunk chunk, Coordinates3D location, byte type = 0x0)
 {
     const int sectionRadius = 1;
     GenerateCircle(chunk, location, sectionRadius, LeavesBlock.BlockID, 0x1);
     var top = location + Coordinates3D.Up;
     chunk.SetBlockID(top, LeavesBlock.BlockID);
     chunk.SetMetadata(top, 0x1);
     if (type == 0x1 && (top + Coordinates3D.Up).Y < Chunk.Height)
         GenerateVanillaCircle(chunk, top + Coordinates3D.Up, sectionRadius, LeavesBlock.BlockID, 0x1); 
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:16,代码来源:PineTree.cs

示例3: GenerateColumn

 public static void GenerateColumn(IChunk chunk, Coordinates3D location, int height, byte block, byte meta = 0x0)
 {
     for (int offset = 0; offset < height; offset++)
     {
         var blockLocation = location + new Coordinates3D(0, offset, 0);
         if (blockLocation.Y >= Chunk.Height)
             return;
         chunk.SetBlockID(blockLocation, block);
         chunk.SetMetadata(blockLocation, meta);
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:11,代码来源:Decoration.cs

示例4: MossFloor

 private void MossFloor(IChunk chunk, Coordinates3D location, Random random)
 {
     for (int x = location.X; x < location.X + Size.X; x++)
     {
         for (int z = location.Z; z < location.Z + Size.Z; z++)
         {
             if (random.Next(0, 3) == 0)
                 chunk.SetBlockID(new Coordinates3D(x, location.Y, z), MossStoneBlock.BlockID);
         }
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:11,代码来源:Dungeon.cs

示例5: Decorate

 public void Decorate(IWorld world, IChunk chunk, IBiomeRepository biomes)
 {
     for (int x = 0; x < 16; x++)
     {
         for (int z = 0; z < 16; z++)
         {
             var biome = biomes.GetBiome(chunk.Biomes[x * Chunk.Width + z]);
             if (biome.Temperature < 0.15)
             {
                 var height = chunk.HeightMap[x * Chunk.Width + z];
                 for (int y = height; y < Chunk.Height; y++)
                 {
                     var location = new Coordinates3D(x, y, z);
                     if (chunk.GetBlockID(location).Equals(StationaryWaterBlock.BlockID) || chunk.GetBlockID(location).Equals(WaterBlock.BlockID))
                         chunk.SetBlockID(location, IceBlock.BlockID);
                     else
                     {
                         var below = chunk.GetBlockID(location);
                         byte[] whitelist =
                         {
                             DirtBlock.BlockID,
                             GrassBlock.BlockID,
                             IceBlock.BlockID,
                             LeavesBlock.BlockID
                         };
                         if (y == height && whitelist.Any(w => w == below))
                         {
                             if (chunk.GetBlockID(location).Equals(IceBlock.BlockID) && CoverIce(chunk, biomes, location))
                                 chunk.SetBlockID((location + Coordinates3D.Up), SnowfallBlock.BlockID);
                             else if (!chunk.GetBlockID(location).Equals(SnowfallBlock.BlockID) && !chunk.GetBlockID(location).Equals(AirBlock.BlockID))
                                 chunk.SetBlockID((location + Coordinates3D.Up), SnowfallBlock.BlockID);
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:38,代码来源:FreezeDecorator.cs

示例6: CreateEntraces

 private void CreateEntraces(IChunk chunk, Coordinates3D location, Random random)
 {
     int entrances = 0;
     var above = location + Coordinates3D.Up;
     for (int X = location.X; X < location.X + Size.X; X++)
     {
         if (entrances >= MaxEntrances)
             break;
         for (int Z = location.Z; Z < location.Z + Size.Z; Z++)
         {
             if (entrances >= MaxEntrances)
                 break;
             if (random.Next(0, 3) == 0 && IsCuboidWall(new Coordinates2D(X, Z), location, Size)
                 && !IsCuboidCorner(new Coordinates2D(X, Z), location, Size))
             {
                 var blockLocation = new Coordinates3D(X, above.Y, Z);
                 chunk.SetBlockID(blockLocation, AirBlock.BlockID);
                 chunk.SetBlockID(blockLocation + Coordinates3D.Up, AirBlock.BlockID);
                 entrances++;
             }
         }
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:23,代码来源:Dungeon.cs

示例7: GenerateAt

        public override bool GenerateAt(IWorld world, IChunk chunk, Coordinates3D location)
        {
            if (!ValidLocation(location))
                return false;

            var random = new Random(world.Seed);

            //Generate room
            GenerateCuboid(chunk, location, Size, CobblestoneBlock.BlockID, 0x0, 0x2);

            //Randomly add mossy cobblestone to floor
            MossFloor(chunk, location, random);

            //Place Spawner
            chunk.SetBlockID(new Coordinates3D((int)(location.X + ((Size.X + 1) / 2)), (int)((location + Coordinates3D.Up).Y), (int)(location.Z + ((Size.Z + 1) / 2))), MonsterSpawnerBlock.BlockID);
            
            //Create entrances
            CreateEntraces(chunk, location, random);

            //Place Chests
            PlaceChests(chunk, location, random);

            return true;
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:24,代码来源:Dungeon.cs

示例8: GenerateDeadBush

 void GenerateDeadBush(IChunk chunk, Coordinates3D location)
 {
     chunk.SetBlockID(location, DeadBushBlock.BlockID);
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:4,代码来源:PlantDecorator.cs

示例9: GenerateTallGrass

 void GenerateTallGrass(IChunk chunk, Coordinates3D location, byte meta)
 {
     chunk.SetBlockID(location, TallGrassBlock.BlockID);
     chunk.SetMetadata(location, meta);
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:5,代码来源:PlantDecorator.cs

示例10: GenerateDandelion

 void GenerateDandelion(IChunk chunk, Coordinates3D location)
 {
     chunk.SetBlockID(location, DandelionBlock.BlockID);
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:4,代码来源:PlantDecorator.cs

示例11: GenerateRose

 void GenerateRose(IChunk chunk, Coordinates3D location)
 {
     chunk.SetBlockID(location, RoseBlock.BlockID);
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:4,代码来源:PlantDecorator.cs

示例12: GenerateCuboid

        /*
         * Cuboid Modes
         * 0x0 - Solid cuboid of the specified block
         * 0x1 - Hollow cuboid of the specified block
         * 0x2 - Outlines the area of the cuboid using the specified block
         */
        public static void GenerateCuboid(IChunk chunk, Coordinates3D location, Vector3 size, byte block, byte meta = 0x0, byte mode = 0x0)
        {
            //If mode is 0x2 offset the size by 2 and change mode to 0x1
            if (mode.Equals(0x2))
            {
                size += new Vector3(2, 2, 2);
                mode = 0x1;
            }

            for (int w = location.X; w < location.X + size.X; w++)
            {
                for (int l = location.Z; l < location.Z + size.Z; l++)
                {
                    for (int h = location.Y; h < location.Y + size.Y; h++)
                    {

                        if (w < 0 || w >= Chunk.Width || l < 0 || l >= Chunk.Depth || h < 0 || h >= Chunk.Height)
                            continue;
                        Coordinates3D BlockLocation = new Coordinates3D(w, h, l);
                        if (!h.Equals(location.Y) && !h.Equals(location.Y + (int)size.Y - 1)
                            && !IsCuboidWall(new Coordinates2D(w, l), location, size)
                            && !IsCuboidCorner(new Coordinates2D(w, l), location, size))
                            continue;

                        chunk.SetBlockID(BlockLocation, block);
                        if (meta != 0x0)
                            chunk.SetMetadata(BlockLocation, meta);
                    }
                }
            }
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:37,代码来源:Decoration.cs

示例13: GenerateSphere

        protected static void GenerateSphere(IChunk chunk, Coordinates3D location, int radius, byte block, byte meta = 0x0)
        {
            for (int i = -radius; i <= radius; i = (i + 1))
            {
                for (int j = -radius; j <= radius; j = (j + 1))
                {
                    for (int k = -radius; k <= radius; k = (k + 1))
                    {
                        int max = (int)Math.Sqrt((i * i) + (j * j) + (k * k));
                        if (max <= radius)
                        {
                            int x = location.X + i;
                            int y = location.Y + k;
                            int z = location.Z + j;

                            if (x < 0 || x >= Chunk.Width || z < 0 || z >= Chunk.Depth || y < 0 || y >= Chunk.Height)
                                continue;

                            var currentBlock = new Coordinates3D(x, y, z);
                            if (chunk.GetBlockID(currentBlock).Equals(0))
                            {
                                chunk.SetBlockID(currentBlock, block);
                                chunk.SetMetadata(currentBlock, meta);
                            }
                        }
                    }
                }
            }
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:29,代码来源:Decoration.cs

示例14: GenerateVanillaCircle

 protected void GenerateVanillaCircle(IChunk chunk, Coordinates3D location, int radius, byte block, byte meta = 0x0, double corner = 0)
 {
     for (int i = -radius; i <= radius; i = (i + 1))
     {
         for (int j = -radius; j <= radius; j = (j + 1))
         {
             int max = (int)Math.Sqrt((i * i) + (j * j));
             if (max <= radius)
             {
                 if (i.Equals(-radius) && j.Equals(-radius)
                     || i.Equals(-radius) && j.Equals(radius)
                     || i.Equals(radius) && j.Equals(-radius)
                     || i.Equals(radius) && j.Equals(radius))
                 {
                     if (corner + radius * 0.2 < 0.4 || corner + radius * 0.2 > 0.7 || corner.Equals(0))
                         continue;
                 }
                 int x = location.X + i;
                 int z = location.Z + j;
                 var currentBlock = new Coordinates3D(x, location.Y, z);
                 if (chunk.GetBlockID(currentBlock).Equals(0))
                 {
                     chunk.SetBlockID(currentBlock, block);
                     chunk.SetMetadata(currentBlock, meta);
                 }
             }
         }
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:29,代码来源:Decoration.cs

示例15: PlaceChests

 private void PlaceChests(IChunk chunk, Coordinates3D location, Random random)
 {
     var above = location + Coordinates3D.Up;
     var chests = random.Next(0, 2);
     for (int i = 0; i < chests; i++)
     {
         for (int attempts = 0; attempts < 10; attempts++)
         {
             var x = random.Next(location.X, location.X + (int)Size.X);
             var z = random.Next(location.Z, location.Z + (int)Size.Z);
             if (!IsCuboidWall(new Coordinates2D(x, z), location, Size) && !IsCuboidCorner(new Coordinates2D(x, z), location, Size))
             {
                 if (NeighboursBlock(chunk, new Coordinates3D(x, above.Y, z), CobblestoneBlock.BlockID))
                 {
                     chunk.SetBlockID(new Coordinates3D(x, above.Y, z), ChestBlock.BlockID);
                     break;
                 }
             }
         }
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:21,代码来源:Dungeon.cs


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