本文整理汇总了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);
}
}
示例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);
}
示例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;
}
}
}
}
示例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;
}