本文整理匯總了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;
}
}
//.........這裏部分代碼省略.........