• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Coordinates2D类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GenerateChunk

 public IChunk GenerateChunk(IWorld world, Coordinates2D position)
 {
     var chunk = new Chunk(position);
     int y = 0;
     for (int i = 0; i < Layers.Count; i++)
     {
         int height = y + Layers[i].Height;
         while (y < height)
         {
             for (int x = 0; x < 16; x++)
             {
                 for (int z = 0; z < 16; z++)
                 {
                     chunk.SetBlockID(new Coordinates3D(x, y, z), Layers[i].BlockId);
                     chunk.SetMetadata(new Coordinates3D(x, y, z), Layers[i].Metadata);
                 }
             }
             y++;
         }
     }
     for (int i = 0; i < chunk.Biomes.Length; i++)
         chunk.Biomes[i] = (byte)Biome;
     chunk.TerrainPopulated = true;
     chunk.UpdateHeightMap();
     return chunk;
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:26,代码来源:FlatlandGenerator.cs


示例2: AddChunk

        private static void AddChunk(MinecraftClient client, int x, int z, ushort primaryBitMap, ushort addBitMap, bool lightIncluded, bool groundUp, byte[] data)
        {
            var coordinates = new Coordinates2D(x, z);
            var relativePosition = GetRelativeChunkPosition(coordinates);
            var chunk = new Chunk(relativePosition);
            var sectionCount = GetSectionCount(primaryBitMap);

            // Run through the sections
            // TODO: Support block IDs >255
            for (int y = 0; y < 16; y++)
            {
                if ((primaryBitMap & (1 << y)) > 0)
                {
                    // Blocks
                    Array.Copy(data, y * BlockDataLength, chunk.Sections[y].Blocks, 0, BlockDataLength);
                    // Metadata
                    Array.Copy(data, (BlockDataLength * sectionCount) + (y * NibbleDataLength),
                        chunk.Sections[y].Metadata.Data, 0, NibbleDataLength);
                    // Light
                    Array.Copy(data, ((BlockDataLength + NibbleDataLength) * sectionCount) + (y * NibbleDataLength),
                        chunk.Sections[y].BlockLight.Data, 0, NibbleDataLength);
                    // Sky light
                    if (lightIncluded)
                    {
                        Array.Copy(data, ((BlockDataLength + NibbleDataLength + NibbleDataLength) * sectionCount) + (y * NibbleDataLength),
                            chunk.Sections[y].SkyLight.Data, 0, NibbleDataLength);
                    }
                }
            }
            if (groundUp)
                Array.Copy(data, data.Length - chunk.Biomes.Length, chunk.Biomes, 0, chunk.Biomes.Length);
            client.World.SetChunk(coordinates, chunk);
            //client.OnChunkRecieved(new ChunkRecievedEventArgs(position, new ReadOnlyChunk(chunk)));
        }
开发者ID:Booser,项目名称:Craft.Net,代码行数:34,代码来源:WorldHandlers.cs


示例3: ReadPacket

        public IPacket ReadPacket(IMinecraftDataReader reader)
        {
            Coordinates = Coordinates2D.FromReaderInt(reader);
            RecordList = RecordList.FromReader(reader);

            return this;
        }
开发者ID:beppe9000,项目名称:MineLib.Network,代码行数:7,代码来源:MultiBlockChangePacket.cs


示例4: IsCuboidCorner

 public static bool IsCuboidCorner(Coordinates2D location, Coordinates3D start, Vector3 size)
 {
     return location.X.Equals(start.X) && location.Z.Equals(start.Z)
         || location.X.Equals(start.X) && location.Z.Equals(start.Z + (int)size.Z - 1)
         || location.X.Equals(start.X + (int)size.X - 1) && location.Z.Equals(start.Z)
         || location.X.Equals(start.X + (int)size.X - 1) && location.Z.Equals(start.Z + (int)size.Z - 1);
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:7,代码来源:Decoration.cs


示例5: Model

 public Model(Coordinates2D min, Coordinates2D max, int wolfCount, int preyCount)
 {
     this.min = min;
     this.max = max;
     this.wolfCount = wolfCount;
     this.preyCount = preyCount;
 }
开发者ID:mijay,项目名称:SwarmIntelligence,代码行数:7,代码来源:Model.cs


示例6: GenerateBiome

 public byte GenerateBiome(int seed, IBiomeRepository biomes, Coordinates2D location)
 {
     double temp = Math.Abs(TempNoise.Value2D(location.X, location.Z));
     double rainfall = Math.Abs(RainNoise.Value2D(location.X, location.Z));
     byte ID = biomes.GetBiome(temp, rainfall).ID;
     return ID;
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:7,代码来源:BiomeMap.cs


示例7: GenerateChunk

        public void GenerateChunk(Coordinates2D coordinates)
        {
            int regionX = coordinates.X / Region.Width - ((coordinates.X < 0) ? 1 : 0);
            int regionZ = coordinates.Z / Region.Depth - ((coordinates.Z < 0) ? 1 : 0);

            var region = LoadOrGenerateRegion(new Coordinates2D(regionX, regionZ));
            region.GenerateChunk(new Coordinates2D(coordinates.X - regionX * 32, coordinates.Z - regionZ * 32));
        }
开发者ID:Booser,项目名称:Craft.Net,代码行数:8,代码来源:World.cs


示例8: FindIntersectionVector_LeftBorder

 public void FindIntersectionVector_LeftBorder()
 {
     Coordinates2D intersection = new Coordinates2D(XMIN, 200);
     Vector2D vector = new Vector2D(-140, -20);
     Vector2D actualVector = _testAsset.FindIntersectionVector(vector, intersection);
     Vector2D expectedVector = new Vector2D(140 * RICOCHE, -20 * RICOCHE);
     Assert.AreEqual(expectedVector.X, actualVector.X);
     Assert.AreEqual(expectedVector.Y, actualVector.Y);
 }
开发者ID:djjosse,项目名称:Foosbot,代码行数:9,代码来源:RicochetCalcTest.cs


示例9: FindIntersectionVector_UpperBorder

 public void FindIntersectionVector_UpperBorder()
 {
     Coordinates2D intersection = new Coordinates2D(500, YMAX);
     Vector2D vector = new Vector2D(-100,50);
     Vector2D actualVector = _testAsset.FindIntersectionVector(vector, intersection);
     Vector2D expectedVector = new Vector2D(-100 * RICOCHE, -50 * RICOCHE);
     Assert.AreEqual(expectedVector.X, actualVector.X);
     Assert.AreEqual(expectedVector.Y, actualVector.Y);
 }
开发者ID:djjosse,项目名称:Foosbot,代码行数:9,代码来源:RicochetCalcTest.cs


示例10: FindIntersectionVector_ButtomBorder

 public void FindIntersectionVector_ButtomBorder()
 {
     Coordinates2D intersection = new Coordinates2D(750, YMIN);
     Vector2D vector = new Vector2D(50, -300);
     Vector2D actualVector = _testAsset.FindIntersectionVector(vector, intersection);
     Vector2D expectedVector = new Vector2D(50 * RICOCHE, 300 * RICOCHE);
     Assert.AreEqual(expectedVector.X, actualVector.X);
     Assert.AreEqual(expectedVector.Y, actualVector.Y);
 }
开发者ID:djjosse,项目名称:Foosbot,代码行数:9,代码来源:RicochetCalcTest.cs


示例11: GetChunk

 /// <summary>
 /// Retrieves the requested chunk from the region, or
 /// generates it if a world generator is provided.
 /// </summary>
 /// <param name="position">The position of the requested local chunk coordinates.</param>
 public IChunk GetChunk(Coordinates2D position, bool generate = true)
 {
     // TODO: This could use some refactoring
     lock (Chunks)
     {
         if (!Chunks.ContainsKey(position))
         {
             if (regionFile != null)
             {
                 // Search the stream for that region
                 lock (regionFile)
                 {
                     var chunkData = GetChunkFromTable(position);
                     if (chunkData == null)
                     {
                         if (World.ChunkProvider == null)
                             throw new ArgumentException("The requested chunk is not loaded.", "position");
                         if (generate)
                             GenerateChunk(position);
                         else
                             return null;
                         return Chunks[position];
                     }
                     regionFile.Seek(chunkData.Item1, SeekOrigin.Begin);
                     /*int length = */
                     new MinecraftStream(regionFile).ReadInt32(); // TODO: Avoid making new objects here, and in the WriteInt32
                     int compressionMode = regionFile.ReadByte();
                     switch (compressionMode)
                     {
                         case 1: // gzip
                             throw new NotImplementedException("gzipped chunks are not implemented");
                         case 2: // zlib
                             var nbt = new NbtFile();
                             nbt.LoadFromStream(regionFile, NbtCompression.ZLib, null);
                             var chunk = Chunk.FromNbt(nbt);
                             Chunks.Add(position, chunk);
                             World.OnChunkLoaded(new ChunkLoadedEventArgs(chunk));
                             break;
                         default:
                             throw new InvalidDataException("Invalid compression scheme provided by region file.");
                     }
                 }
             }
             else if (World.ChunkProvider == null)
                 throw new ArgumentException("The requested chunk is not loaded.", "position");
             else
             {
                 if (generate)
                     GenerateChunk(position);
                 else
                     return null;
             }
         }
         return Chunks[position];
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:61,代码来源:Region.cs


示例12: GetChunkWithoutGeneration

        public Chunk GetChunkWithoutGeneration(Coordinates2D coordinates)
        {
            int regionX = coordinates.X / Region.Width - ((coordinates.X < 0) ? 1 : 0);
            int regionZ = coordinates.Z / Region.Depth - ((coordinates.Z < 0) ? 1 : 0);

            var regionPosition = new Coordinates2D(regionX, regionZ);
            if (!Regions.ContainsKey(regionPosition)) return null;
            return Regions[regionPosition].GetChunkWithoutGeneration(
                new Coordinates2D(coordinates.X - regionX * 32, coordinates.Z - regionZ * 32));
        }
开发者ID:Booser,项目名称:Craft.Net,代码行数:10,代码来源:World.cs


示例13: GetChunkIndex

        public int GetChunkIndex(Coordinates2D coordinates)
        {
            foreach (var chunk in Chunks)
            {
                if (chunk.Coordinates == coordinates)
                    return Chunks.IndexOf(chunk);
            }

            return -1;
        }
开发者ID:DefinitlyEvil,项目名称:MineLib.ClientWrapper,代码行数:10,代码来源:World.cs


示例14: Region

 /// <summary>
 /// Creates a region from the given region file.
 /// </summary>
 public Region(Coordinates2D position, World world, string file) : this(position, world)
 {
     if (File.Exists(file))
         regionFile = File.Open(file, FileMode.OpenOrCreate);
     else
     {
         regionFile = File.Open(file, FileMode.OpenOrCreate);
         CreateRegionHeader();
     }
 }
开发者ID:Booser,项目名称:Craft.Net,代码行数:13,代码来源:Region.cs


示例15: FindChunk

 internal IChunk FindChunk(Coordinates2D coordinates)
 {
     try
     {
         return World.FindChunk(new Coordinates3D(coordinates.X, 0, coordinates.Z));
     }
     catch
     {
         return null;
     }
 }
开发者ID:ricucremop,项目名称:TrueCraft,代码行数:11,代码来源:ReadOnlyWorld.cs


示例16: Chunk

 public Chunk(Coordinates2D coordinates)
     : this()
 {
     X = coordinates.X;
     Z = coordinates.Z;
     const int size = Width * Height * Depth;
     Blocks = new byte[size];
     Metadata = new NibbleArray(size);
     BlockLight = new NibbleArray(size);
     SkyLight = new NibbleArray(size);
 }
开发者ID:ac682,项目名称:TrueCraft,代码行数:11,代码来源:Chunk.cs


示例17: GetNeighbours

 protected override IEnumerable<Coordinates2D> GetNeighbours(Coordinates2D coord)
 {
     if(coord.x > TopLeft.x)
         yield return new Coordinates2D(coord.x - 1, coord.y);
     if(coord.x < BottomRight.x)
         yield return new Coordinates2D(coord.x + 1, coord.y);
     if(coord.y > TopLeft.y)
         yield return new Coordinates2D(coord.x, coord.y - 1);
     if(coord.y < BottomRight.y)
         yield return new Coordinates2D(coord.x, coord.y + 1);
 }
开发者ID:mijay,项目名称:SwarmIntelligence,代码行数:11,代码来源:FourConnectedSurfaceTopology.cs


示例18: SetChunk

        public void SetChunk(Coordinates2D coordinates, Chunk chunk)
        {
            int regionX = coordinates.X / Region.Width - ((coordinates.X < 0) ? 1 : 0);
            int regionZ = coordinates.Z / Region.Depth - ((coordinates.Z < 0) ? 1 : 0);

            var region = LoadOrGenerateRegion(new Coordinates2D(regionX, regionZ));
            lock (region)
            {
                chunk.IsModified = true;
                region.SetChunk(new Coordinates2D(coordinates.X - regionX * 32, coordinates.Z - regionZ * 32), chunk);
            }
        }
开发者ID:Booser,项目名称:Craft.Net,代码行数:12,代码来源:World.cs


示例19: ClosestCellPoint

 /*
  * The distance to the closest biome cell point to the specified location(uses the Chebyshev distance function).
  */
 public double ClosestCellPoint(Coordinates2D location)
 {
     var distance = double.MaxValue;
     foreach (BiomeCell C in BiomeCells)
     {
         var _distance = Distance(location, C.CellPoint);
         if (_distance < distance)
         {
             distance = _distance;
         }
     }
     return distance;
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:16,代码来源:BiomeMap.cs


示例20: InitializeWorld

 protected void InitializeWorld(Coordinates2D min, Coordinates2D max)
 {
     ILogManager logManager;
     world = SystemBuilder
         .Create<Coordinates2D, EmptyData, EmptyData>()
         .WithDefaultLog(out logManager)
         .WithTopology(new FourConnectedSurfaceTopology(min, max))
         .WithSurfaceMap()
         .WithEmptyNodeData()
         .WithEmptyEdgeData()
         .Build();
     journal = logManager.Journal;
     world = runner.World;
     runner = new Runner<Coordinates2D, EmptyData, EmptyData>(world);
 }
开发者ID:mijay,项目名称:SwarmIntelligence,代码行数:15,代码来源:SwarmIntelligenceTestBase.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Coordinates3D类代码示例发布时间:2022-05-24
下一篇:
C# Coordinates类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap