本文整理汇总了C#中System.Coordinate.Move方法的典型用法代码示例。如果您正苦于以下问题:C# Coordinate.Move方法的具体用法?C# Coordinate.Move怎么用?C# Coordinate.Move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Coordinate
的用法示例。
在下文中一共展示了Coordinate.Move方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Raycast
public RaycastResult Raycast(Coordinate start, Direction dir, int length)
{
return this.Raycast(start, start.Move(dir, length));
}
示例2: adjacentToFilledCell
private bool adjacentToFilledCell(Coordinate coord)
{
return this[coord.Move(0, 0, 1)].ID != 0
|| this[coord.Move(0, 1, 0)].ID != 0
|| this[coord.Move(0, 1, 1)].ID != 0
|| this[coord.Move(1, 0, 0)].ID != 0
|| this[coord.Move(1, 0, 1)].ID != 0
|| this[coord.Move(1, 1, 0)].ID != 0
|| this[coord.Move(1, 1, 1)].ID != 0
|| this[coord.Move(0, 0, -1)].ID != 0
|| this[coord.Move(0, -1, 0)].ID != 0
|| this[coord.Move(0, -1, -1)].ID != 0
|| this[coord.Move(-1, 0, 0)].ID != 0
|| this[coord.Move(-1, 0, 1)].ID != 0
|| this[coord.Move(-1, -1, 0)].ID != 0
|| this[coord.Move(-1, -1, -1)].ID != 0;
}
示例3: FindClosestFilledCell
public Coordinate? FindClosestFilledCell(Coordinate coord, int maxDistance = 20)
{
if (this[coord].ID != 0)
return coord;
Vector3 pos = this.GetRelativePosition(coord);
Coordinate? closestCoord = null;
for (int radius = 1; radius < maxDistance; radius++)
{
float closestDistance = float.MaxValue;
// Left
for (int y = -radius; y <= radius; y++)
{
for (int z = -radius; z <= radius; z++)
{
Coordinate c = coord.Move(-radius, y, z);
if (this[c].ID != 0)
{
float distance = (this.GetRelativePosition(c) - pos).LengthSquared();
if (distance < closestDistance)
{
closestDistance = distance;
closestCoord = c;
}
}
}
}
// Right
for (int y = -radius; y <= radius; y++)
{
for (int z = -radius; z <= radius; z++)
{
Coordinate c = coord.Move(radius, y, z);
if (this[c].ID != 0)
{
float distance = (this.GetRelativePosition(c) - pos).LengthSquared();
if (distance < closestDistance)
{
closestDistance = distance;
closestCoord = c;
}
}
}
}
// Bottom
for (int x = -radius + 1; x < radius; x++)
{
for (int z = -radius + 1; z < radius; z++)
{
Coordinate c = coord.Move(x, -radius, z);
if (this[c].ID != 0)
{
float distance = (this.GetRelativePosition(c) - pos).LengthSquared();
if (distance < closestDistance)
{
closestDistance = distance;
closestCoord = c;
}
}
}
}
// Top
for (int x = -radius + 1; x < radius; x++)
{
for (int z = -radius + 1; z < radius; z++)
{
Coordinate c = coord.Move(x, radius, z);
if (this[c].ID != 0)
{
float distance = (this.GetRelativePosition(c) - pos).LengthSquared();
if (distance < closestDistance)
{
closestDistance = distance;
closestCoord = c;
}
}
}
}
// Backward
for (int x = -radius + 1; x < radius; x++)
{
for (int y = -radius; y <= radius; y++)
{
Coordinate c = coord.Move(x, y, -radius);
if (this[c].ID != 0)
{
float distance = (this.GetRelativePosition(c) - pos).LengthSquared();
if (distance < closestDistance)
{
closestDistance = distance;
closestCoord = c;
}
}
//.........这里部分代码省略.........