本文整理汇总了C#中Index3.NormalizeXY方法的典型用法代码示例。如果您正苦于以下问题:C# Index3.NormalizeXY方法的具体用法?C# Index3.NormalizeXY怎么用?C# Index3.NormalizeXY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Index3
的用法示例。
在下文中一共展示了Index3.NormalizeXY方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBlock
/// <summary>
/// Liefert den Block an der angegebenen Block-Koodinate zurück.
/// </summary>
/// <param name="index">Block Index</param>
/// <returns>Block oder null, falls dort kein Block existiert</returns>
public IBlock GetBlock(int planetId, Index3 index)
{
IPlanet planet = GetPlanet(planetId);
index.NormalizeXY(new Index2(
planet.Size.X * Chunk.CHUNKSIZE_X,
planet.Size.Y * Chunk.CHUNKSIZE_Y));
Coordinate coordinate = new Coordinate(0, index, Vector3.Zero);
// Betroffener Chunk ermitteln
Index3 chunkIndex = coordinate.ChunkIndex;
if (chunkIndex.X < 0 || chunkIndex.X >= planet.Size.X ||
chunkIndex.Y < 0 || chunkIndex.Y >= planet.Size.Y ||
chunkIndex.Z < 0 || chunkIndex.Z >= planet.Size.Z)
return null;
IChunk chunk = chunkCache.Get(new PlanetIndex3(planetId, chunkIndex));
if (chunk == null)
return null;
return chunk.GetBlock(coordinate.LocalBlockIndex);
}
示例2: GetBlock
/// <summary>
/// Liefert den Block an der angegebenen Block-Koodinate zurück.
/// </summary>
/// <param name="index">Block Index</param>
/// <returns>Block oder null, falls dort kein Block existiert</returns>
public IBlock GetBlock(Index3 index)
{
IPlanet planet = ResourceManager.Instance.GetPlanet(Player.Position.Planet);
index.NormalizeXY(new Index2(
planet.Size.X * Chunk.CHUNKSIZE_X,
planet.Size.Y * Chunk.CHUNKSIZE_Y));
Coordinate coordinate = new Coordinate(0, index, Vector3.Zero);
// Betroffener Chunk ermitteln
Index3 chunkIndex = coordinate.ChunkIndex;
if (chunkIndex.X < 0 || chunkIndex.X >= planet.Size.X ||
chunkIndex.Y < 0 || chunkIndex.Y >= planet.Size.Y ||
chunkIndex.Z < 0 || chunkIndex.Z >= planet.Size.Z)
return null;
IChunk chunk = localChunkCache.Get(chunkIndex);
if (chunk == null)
return null;
return chunk.GetBlock(coordinate.LocalBlockIndex);
}