本文整理汇总了C#中Vector2i.ToVector2方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2i.ToVector2方法的具体用法?C# Vector2i.ToVector2怎么用?C# Vector2i.ToVector2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector2i
的用法示例。
在下文中一共展示了Vector2i.ToVector2方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildControlNodes
private void BuildControlNodes(float[,] map)
{
ControlNodes = new ControlNode[MapSize.x, MapSize.y];
for (int y = 0; y < MapSize.y; y++)
{
for (int x = 0; x < MapSize.x; x++)
{
Vector2i p = new Vector2i(x, y);
ControlNodes[x, y] =
new ControlNode(
p,
map,
p.ToVector2() - WorldSize * 0.5f + Vector2.one * 0.5f,
SquareSize);
}
}
}
示例2: Vector2iWithNormal
public Vector2iWithNormal(Vector2i vector2i)
: this()
{
this.vector2i = vector2i;
normal = vector2i.ToVector2().normalized;
magnitude = vector2i.ToVector2().magnitude;
isDiagonal = magnitude > 1;
if (isDiagonal)
{
// Prefer diagonals...
magnitude = magnitude * 0.96f;
}
}
示例3: SquareGrid
public SquareGrid(float[,] map, float squareSize)
{
Vertices = new List<Node>();
Triangles = new List<Node>();
SquareSize = squareSize;
MapSize =
new Vector2i(
map.GetLength(0),
map.GetLength(1));
Size = MapSize - Vector2i.One;
WorldSize = MapSize.ToVector2() * squareSize;
BuildControlNodes(map);
BuildSquares();
BuildTriangles();
BuildMesh();
}
示例4: GetCellCenter
//public void OnDrawGizmos()
//{
// if (Costs == null)
// {
// Start();
// }
// for (int y = 0; y < fieldSize.y; y++)
// {
// for (int x = 0; x < fieldSize.x; x++)
// {
// Gizmos.color = new Color(1, 0.5f, 0.5f, 0.7f);
// Vector2i p = new Vector2i(x, y);
// Vector2 center = GetCellCenter(p);
// if (float.IsPositiveInfinity(Costs[x, y]))
// {
// Rect rect = GetCellRect(p);
// Gizmos.DrawCube(rect.center, rect.size * 0.95f);
// }
// else
// {
// Rect rect = GetCellRect(p);
// Gizmos.color = new Color(1, 1, 1, 0.3f);
// Gizmos.DrawCube(rect.center, rect.size * 0.95f);
// }
// if (PotentialField.DebugInstance != null)
// {
// //float potential = PotentialField.DebugInstance.Potentials[x, y];
// //if (potential > PotentialField.UnreachablePotential)
// //{
// // Handles.Label(center, potential.ToString("F2"));
// //}
// Vector2 flow = PotentialField.DebugInstance.Flows[x, y];
// Gizmos.color = Color.black;
// Gizmos.DrawRay(center, flow * 0.5f);
// }
// }
// }
//}
private Vector2 GetCellCenter(Vector2i p)
{
Vector2 pos = p.ToVector2() * gridSize;
return pos;
}