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


C# IChunk类代码示例

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


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

示例1: LoadChunk

        public void LoadChunk(IChunk runtimeChunk)
        {
            using (var file = new FileStream(Path.Combine(this.m_Path, this.GetName(runtimeChunk)), FileMode.Open))
            {
                var serializer = new TychaiaDataSerializer();
                var chunk = new Chunk();
                serializer.Deserialize(file, chunk, typeof(Chunk));

                runtimeChunk.Cells = chunk.Cells;

                runtimeChunk.GeneratedIndices = chunk.Indexes;

                if (chunk.Vertexes == null)
                {
                    runtimeChunk.GeneratedVertexes = new VertexPositionTexture[0];
                }
                else
                {
                    runtimeChunk.GeneratedVertexes = new VertexPositionTexture[chunk.Vertexes.Length];
                    for (var i = 0; i < chunk.Vertexes.Length; i++)
                    {
                        runtimeChunk.GeneratedVertexes[i] =
                            new VertexPositionTexture(
                                new Vector3(chunk.Vertexes[i].X, chunk.Vertexes[i].Y, chunk.Vertexes[i].Z),
                                new Vector2(chunk.Vertexes[i].U, chunk.Vertexes[i].V));
                    }
                }

                runtimeChunk.Generated = true;
            }
        }
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:31,代码来源:SimpleLevel.cs

示例2: GenerateChunk

        public IChunk[] GenerateChunk(IPlanet planet, Index2 index)
        {
            IChunk[] result = new IChunk[planet.Size.Z];

            for (int layer = 0; layer < planet.Size.Z; layer++)
                result[layer] = new Chunk(new Index3(index.X, index.Y, layer), planet.Id);

            int part = (planet.Size.Z * Chunk.CHUNKSIZE_Z) / 4;

            for (int y = 0; y < Chunk.CHUNKSIZE_Y; y++)
            {
                float heightY = (float)Math.Sin((float)(y * Math.PI) / 15f);
                for (int x = 0; x < Chunk.CHUNKSIZE_X; x++)
                {
                    float heightX = (float)Math.Sin((float)(x * Math.PI) / 18f);

                    float height = ((heightX + heightY + 2) / 4) * (2 * part);
                    for (int z = 0; z < planet.Size.Z * Chunk.CHUNKSIZE_Z; z++)
                    {
                        if (z < (int)(height + part))
                        {
                            int block = z % (Chunk.CHUNKSIZE_Z);
                            int layer = (int)(z / Chunk.CHUNKSIZE_Z);
                            result[layer].SetBlock(x, y, block, new SandBlock());
                        }
                    }
                }
            }

            return result;
        }
开发者ID:Vengarioth,项目名称:octoawesome,代码行数:31,代码来源:DebugMapGenerator.cs

示例3: GenerateChunk

        public IChunk[] GenerateChunk(IEnumerable<IBlockDefinition> blockDefinitions, IPlanet planet, Index2 index)
        {
            IBlockDefinition sandDefinition = blockDefinitions.FirstOrDefault(d => typeof(SandBlockDefinition) == d.GetType());
            ushort sandIndex = (ushort)(Array.IndexOf(blockDefinitions.ToArray(), sandDefinition) + 1);

            IChunk[] result = new IChunk[planet.Size.Z];

            for (int layer = 0; layer < planet.Size.Z; layer++)
                result[layer] = new Chunk(new Index3(index.X, index.Y, layer), planet.Id);

            int part = (planet.Size.Z * Chunk.CHUNKSIZE_Z) / 4;

            for (int y = 0; y < Chunk.CHUNKSIZE_Y; y++)
            {
                float heightY = (float)Math.Sin((float)(y * Math.PI) / 15f);
                for (int x = 0; x < Chunk.CHUNKSIZE_X; x++)
                {
                    float heightX = (float)Math.Sin((float)(x * Math.PI) / 18f);

                    float height = ((heightX + heightY + 2) / 4) * (2 * part);
                    for (int z = 0; z < planet.Size.Z * Chunk.CHUNKSIZE_Z; z++)
                    {
                        if (z < (int)(height + part))
                        {
                            int block = z % (Chunk.CHUNKSIZE_Z);
                            int layer = (int)(z / Chunk.CHUNKSIZE_Z);
                            result[layer].SetBlock(x, y, block, sandIndex);
                        }
                    }
                }
            }

            return result;
        }
开发者ID:RapidHelmus,项目名称:octoawesome,代码行数:34,代码来源:DebugMapGenerator.cs

示例4: Decorate

 public void Decorate(IWorld world, IChunk chunk, IBiomeRepository biomes)
 {
     var noise = new Perlin();
     noise.Seed = world.Seed;
     var chanceNoise = new ClampNoise(noise);
     chanceNoise.MaxValue = 2;
     for (int x = 0; x < 16; x++)
     {
         for (int z = 0; z < 16; z++)
         {
             var biome = biomes.GetBiome(chunk.Biomes[x * Chunk.Width + z]);
             var blockX = MathHelper.ChunkToBlockX(x, chunk.Coordinates.X);
             var blockZ = MathHelper.ChunkToBlockZ(z, chunk.Coordinates.Z);
             var height = chunk.HeightMap[x * Chunk.Width + z];
             if (biome.Plants.Contains(PlantSpecies.Cactus) && chanceNoise.Value2D(blockX, blockZ) > 1.7)
             {
                 var blockLocation = new Coordinates3D(x, height, z);
                 var cactiPosition = blockLocation + Coordinates3D.Up;
                 if (chunk.GetBlockID(blockLocation).Equals(SandBlock.BlockID))
                 {
                     var HeightChance = chanceNoise.Value2D(blockX, blockZ);
                     var CactusHeight = (HeightChance < 1.4) ? 2 : 3;
                     Decoration.GenerateColumn(chunk, cactiPosition, CactusHeight, CactusBlock.BlockID);
                 }
             }
         }
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:28,代码来源:CactusDecorator.cs

示例5: 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

示例6: ChunkColumn

 /// <summary>
 /// Erzeugt eine neue Instanz einer ChunkColumn.
 /// </summary>
 /// <param name="chunks">Die Chunks für die Säule</param>
 /// <param name="planet">Der Index des Planeten</param>
 /// <param name="columnIndex">Die Position der Säule</param>
 public ChunkColumn(IChunk[] chunks, int planet, Index2 columnIndex)
     : this()
 {
     Planet = planet;
     Chunks = chunks;
     Index = columnIndex;
 }
开发者ID:reicheltp,项目名称:octoawesome,代码行数:13,代码来源:ChunkColumn.cs

示例7: Chunk2D

 public Chunk2D(IChunk[] chunks)
 {
     ushort[] blocks = new ushort[Chunk.CHUNKSIZE_X*Chunk.CHUNKSIZE_Y];
     float[] heights = new float[Chunk.CHUNKSIZE_X * Chunk.CHUNKSIZE_Y];
     int maxHeight = Chunk.CHUNKSIZE_Z*chunks.Length;
     int index = 0;
     for (int y = 0; y < Chunk.CHUNKSIZE_Y; y++) {
         for (int x = 0; x < Chunk.CHUNKSIZE_X; x++,index++) {
             bool found=false;
             for (int i=chunks.Length-1;i>=0;i--)
             {
                 IChunk current = chunks [i];
                 for (int z = Chunk.CHUNKSIZE_Z - 1; z >= 0; z--) {
                     if ((blocks [index] = current.GetBlock (x, y, z)) != 0) {
                         float percent = (float)(i * Chunk.CHUNKSIZE_Z + z) / maxHeight;
                         heights[index] = percent - 0.5f;
                         found = true;
                         break;
                     }
                 }
                 if (found)
                     break;
             }
         }
     }
     CreateBitmap(blocks,heights);
 }
开发者ID:jvbsl,项目名称:OctoAwesome-MapViewer,代码行数:27,代码来源:Chunk2D.cs

示例8: Decorate

        public void Decorate(IWorld world, IChunk chunk, IBiomeRepository biomes)
        {
            for (int attempts = 0; attempts < 8; attempts++)
            {
                var noise = new Perlin();
                noise.Seed = world.Seed - (chunk.Coordinates.X + chunk.Coordinates.Z);
                var offsetNoise = new ClampNoise(noise);
                offsetNoise.MaxValue = 3;
                var x = 0;
                var z = 0;
                var offset = 0.0;
                offset += offsetNoise.Value2D(x, z);
                int finalX = (int)Math.Floor(x + offset);
                int finalZ = (int)Math.Floor(z + offset);
                var y = (int)(10 + offset);

                var blockX = MathHelper.ChunkToBlockX(finalX, chunk.Coordinates.X);
                var blockZ = MathHelper.ChunkToBlockZ(finalZ, chunk.Coordinates.Z);
                var spawnValue = offsetNoise.Value2D(blockX, blockZ);
                if (spawnValue > 1.95 && spawnValue < 2.09)
                {
                    var generated = new Dungeon().GenerateAt(world, chunk, new Coordinates3D(blockX, y, blockZ));
                    if (generated)
                        break;
                }
            }
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:27,代码来源:DungeonDecorator.cs

示例9: GenerateHeightMap

 private void GenerateHeightMap(IChunk chunk)
 {
     Coordinates3D coords;
     var map = new byte[Chunk.Width, Chunk.Depth];
     for (byte x = 0; x < Chunk.Width; x++)
     {
         for (byte z = 0; z < Chunk.Depth; z++)
         {
             for (byte y = (byte)(chunk.GetHeight(x, z) + 2); y > 0; y--)
             {
                 if (y >= Chunk.Height)
                     continue;
                 coords.X = x; coords.Y = y - 1; coords.Z = z;
                 var id = chunk.GetBlockID(coords);
                 if (id == 0)
                     continue;
                 var provider = BlockRepository.GetBlockProvider(id);
                 if (provider.LightOpacity != 0)
                 {
                     map[x, z] = y;
                     break;
                 }
             }
         }
     }
     HeightMaps[chunk.Coordinates] = map;
 }
开发者ID:ricucremop,项目名称:TrueCraft,代码行数:27,代码来源:WorldLighting.cs

示例10: GenerateChunk

        public IChunk GenerateChunk(IChunk chunk, int x, int z, bool external)
        {

            InitGen();
#if PROFILE
            Stopwatch watch = new Stopwatch();
            watch.Start();
#endif
            GenerateTerrain(chunk, x, z);
            GenerateFlora(chunk, x, z);

            if (!external)
            {
                chunk.RecalculateHeight();
                chunk.LightToRecalculate = true;
#if PROFILE
            watch.Stop();

            _World.Logger.Log(Logger.LogLevel.Info, "Chunk {0} {1}, {2}", false, x, z, watch.ElapsedMilliseconds);
#endif


                _World.AddChunk(chunk);
                chunk.MarkToSave();
            }

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

示例11: SaveChunk

        public void SaveChunk(IChunk runtimeChunk)
        {
            using (var file = new FileStream(Path.Combine(this.m_Path, this.GetName(runtimeChunk)), FileMode.Create))
            {
                var size = this.m_ChunkSizePolicy.ChunkCellWidth * this.m_ChunkSizePolicy.ChunkCellHeight
                           * this.m_ChunkSizePolicy.ChunkCellDepth;
                var chunk = new Chunk
                {
                    X = runtimeChunk.X,
                    Y = runtimeChunk.Y,
                    Z = runtimeChunk.Z,
                    Cells = new Cell[size],
                    Indexes = runtimeChunk.GeneratedIndices,
                    Vertexes = new Vertex[runtimeChunk.GeneratedVertexes.Length]
                };

                chunk.Cells = runtimeChunk.Cells;

                for (var i = 0; i < runtimeChunk.GeneratedVertexes.Length; i++)
                {
                    chunk.Vertexes[i] = new Vertex
                    {
                        X = runtimeChunk.GeneratedVertexes[i].Position.X,
                        Y = runtimeChunk.GeneratedVertexes[i].Position.Y,
                        Z = runtimeChunk.GeneratedVertexes[i].Position.Z,
                        U = runtimeChunk.GeneratedVertexes[i].TextureCoordinate.X,
                        V = runtimeChunk.GeneratedVertexes[i].TextureCoordinate.Y,
                    };
                }

                var serializer = new TychaiaDataSerializer();
                serializer.Serialize(file, chunk);
            }
        }
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:34,代码来源:SimpleLevel.cs

示例12: SaveAsync

        /// <inheritdoc/>
        public Task SaveAsync(Point index, IChunk chunk)
        {
            if (!_chunks.ContainsKey(index))
                _chunks[index] = chunk;

            return Task.CompletedTask;
        }
开发者ID:SvenEV,项目名称:OrangeBugReloaded,代码行数:8,代码来源:InMemoryChunkStorage.cs

示例13: SaveChunk

 public async Task SaveChunk(IChunk chunk)
 {
     await ChunkSaver.SaveFile(Destination, chunk.Start, chunk.Data);
     if (ChunkSaved != null)
     {
         ChunkSaved.Invoke(this, chunk);
     }
 }
开发者ID:RichTeaMan,项目名称:Podcatcher,代码行数:8,代码来源:FileDownload.cs

示例14: Request

 public void Request(IChunk chunk)
 {
     lock (_in)
     {
         _in.Enqueue(chunk);
         Monitor.Pulse(_in);
     }
 }
开发者ID:dvdbrink,项目名称:Procedural,代码行数:8,代码来源:ThreadedChunkGenerator.cs

示例15: WriteDataDirectory

		/// <summary>
		/// Writes a data directory
		/// </summary>
		/// <param name="writer">Writer</param>
		/// <param name="chunk">The data</param>
		internal static void WriteDataDirectory(this BinaryWriter writer, IChunk chunk) {
			if (chunk == null || chunk.GetVirtualSize() == 0)
				writer.Write(0UL);
			else {
				writer.Write((uint)chunk.RVA);
				writer.Write(chunk.GetVirtualSize());
			}
		}
开发者ID:EmilZhou,项目名称:dnlib,代码行数:13,代码来源:IChunk.cs


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