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


C# Vector3.Floor方法代码示例

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


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

示例1: FloorTest

        public void FloorTest()
        {
            const int max = 1000;

            var r = new Random(102);

            for (var i = 0; i < 30; i++)
            {
                var v = new Vector3(r.NextFloat() * max, r.NextFloat() * max, r.NextFloat() * max);
                var c = v.Floor();
                Assert.AreEqual(Math.Floor(v.X), c.X);
                Assert.AreEqual(Math.Floor(v.Y), c.Y);
                Assert.AreEqual(Math.Floor(v.Z), c.Z);
            }
        }
开发者ID:wtfcolt,项目名称:game,代码行数:15,代码来源:Vector3Tests.cs

示例2: SetBlock

        /// <summary>
        /// Sets the block at the given local position.
        /// </summary>
        public void SetBlock(Vector3 position, Block value)
        {
            position = position.Floor();
            Vector3 relativePosition = position;
            position.X = (int)(position.X) / Chunk.Width;
            position.Y = 0;
            position.Z = (int)(position.Z) / Chunk.Depth;

            relativePosition.X = (int)(relativePosition.X) % Chunk.Width;
            relativePosition.Z = (int)(relativePosition.Z) % Chunk.Depth;

            if (!Chunks.ContainsKey(position))
                Chunks.Add(position, WorldGenerator.GenerateChunk(position, this));

            Chunks[position].SetBlock(relativePosition, value);
        }
开发者ID:pdelvo,项目名称:Craft.Net,代码行数:19,代码来源:Region.cs

示例3: SetBlock

        /// <summary>
        /// Sets a block in this chunk.
        /// </summary>
        /// <param name="pos">The position in local coordinates.</param>
        /// <param name="block">The block to set.</param>
        /// <remarks></remarks>
        public virtual void SetBlock(Vector3 pos, Block block)
        {
            int x = (int)pos.X;
            int y = (int)pos.Y;
            int z = (int)pos.Z;
            int index = x + (z * Width) + (y * Height * Width);
            Metadata[index] = block.Metadata;
            Blocks[index] = block;
            if (block.AdditionalData == null)
            {
                if (AdditionalData.ContainsKey(pos.Floor()))
                    AdditionalData.Remove(pos.Floor());
            }
            if (block.AdditionalData != null)
                AdditionalData[pos.Floor()] = new byte[] {
                    block.AdditionalData.BlockID }.Concat(block.AdditionalData.Serialize()).ToArray();

            if (!(block is AirBlock))
                IsAir = false;
            else
            {
                IsAir = true;
                for (int i = 0; i < Blocks.Length; i++)
                {
                    if (Blocks[i] != 0)
                    {
                        IsAir = false;
                        break;
                    }
                }
            }
        }
开发者ID:vatt849,项目名称:LibMinecraft,代码行数:38,代码来源:Chunk.cs

示例4: GetBlock

 /// <summary>
 /// Gets a block from this chunk.
 /// </summary>
 /// <param name="pos">The position, in local chunk coordinates.</param>
 /// <returns>The specified block.</returns>
 /// <remarks></remarks>
 public virtual Block GetBlock(Vector3 pos)
 {
     if (IsAir)
         return new AirBlock();
     int x = (int)pos.X;
     int y = (int)pos.Y;
     int z = (int)pos.Z;
     int index = x + (z * Width) + (y * Height * Width);
     Block b = Blocks[index];
     b.Metadata = Metadata[index];
     if (AdditionalData.ContainsKey(pos.Floor()))
         b.AdditionalData.Deseralize(AdditionalData[pos.Floor()].Skip(1).ToArray());
     return b;
 }
开发者ID:vatt849,项目名称:LibMinecraft,代码行数:20,代码来源:Chunk.cs


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