本文整理汇总了C#中Position.GetX方法的典型用法代码示例。如果您正苦于以下问题:C# Position.GetX方法的具体用法?C# Position.GetX怎么用?C# Position.GetX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Position
的用法示例。
在下文中一共展示了Position.GetX方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RandomPositionInRange
public static Position RandomPositionInRange(Position minPosition, Position maxPosition)
{
return new Position(Random.Range(minPosition.GetX(),
maxPosition.GetX() + 1),
Random.Range(minPosition.GetY(),
maxPosition.GetY() + 1));
}
示例2: SetMazePosition
public void SetMazePosition(Position mazePosition)
{
MazePosition = mazePosition;
GetComponent<MazePieceController>().SetPosition(
mazePosition.GetX(),
mazePosition.GetY());
}
示例3: WorldPathFromPosition
public static Vector3[] WorldPathFromPosition(Position startPosition, Position endPosition, Maze maze)
{
setGoalPosition(endPosition);
int w = maze.Width();
int h = maze.Height();
bool[][] path = Util.InitializeMatrixAsJaggedArray(new bool[w][], w, h);
bool[][] visited = Util.InitializeMatrixAsJaggedArray(new bool[w][], w, h);
if (arraySearch(ref path,
ref visited,
startPosition.GetX(),
startPosition.GetY())) {
return MazePieceController.GetWorldPath(MazePiecesFromPositions(
pathFromSpaces(path, startPosition, new List<Position>()).ToArray(),
MazeController.Instance.GetMazePieceControllers()));
} else {
return null;
}
}
示例4: Absorber
public Absorber(Position p)
{
SetType(TypeGizmo.ABSORBER);
SetPos(p.GetX(), 0); // Absorber的pos是算在最左邊的
}
示例5: PositionFromIndex
public static Vector3 PositionFromIndex(Position position, float height = defaultHeight, float anchorOffset = 0)
{
return PositionFromIndex (position.GetX(), position.GetY(), height, anchorOffset);
}
示例6: pathFromSpaces
private static List<Position> pathFromSpaces(bool[][] pathSpaces,
Position currentPosition,
List<Position> path)
{
if (path.Count != 0 && path.Contains(goalPosition))
return path;
int x = currentPosition.GetX ();
int y = currentPosition.GetY ();
Position newPosition;
if (inBounds(x, y+1) &&
pathSpaces[x][y+1] &&
!path.Contains(newPosition = new Position(x, y+1))) {
path.Add(newPosition);
path = pathFromSpaces(pathSpaces, x, y+1, path);
} else if (inBounds(x+1, y) &&
pathSpaces[x+1][y] &&
!path.Contains(newPosition = new Position(x+1, y))) {
path.Add(newPosition);
path = pathFromSpaces(pathSpaces, x+1, y, path);
} else if (inBounds(x, y-1) &&
pathSpaces[x][y-1] &&
!path.Contains(newPosition = new Position(x, y-1))) {
path.Add(newPosition);
path = pathFromSpaces(pathSpaces, x, y-1, path);
} else if (inBounds(x-1, y) &&
pathSpaces[x-1][y] &&
!path.Contains(newPosition = new Position(x-1, y))) {
path.Add (newPosition);
path = pathFromSpaces(pathSpaces, x-1, y, path);
}
return path;
}
示例7: inBounds
private static bool inBounds(Position position)
{
Maze maze = MazeController.Instance.GetCurrentMaze();
int x = position.GetX();
int y = position.GetY();
return (x >= 0 &&
x < maze.Width() &&
y >= 0 &&
y < maze.Height() &&
!isWall(maze.GetPieces()[x][y]));
}
示例8: MazePieceControllerFromPosition
public MazePieceController MazePieceControllerFromPosition(Position position)
{
return currentMazePieceControllers[position.GetX()][position.GetY()];
}
示例9: ModifyPiece
// Overloaded method for the position
public void ModifyPiece(Position position, MazePiece newType)
{
ModifyPiece(position.GetX(),
position.GetY(),
newType);
}
示例10: MazePieceFromPosition
public MazePiece MazePieceFromPosition(Position position)
{
return pieces[position.GetX()][position.GetY()];
}
示例11: WithinMazeOuterBounds
public bool WithinMazeOuterBounds(Position position)
{
return Util.WithinRange(position.GetX(), Width()) &&
Util.WithinRange(position.GetY(), Height());
}
示例12: Distance
public float Distance(Position position)
{
return Mathf.Sqrt(
Mathf.Pow(x - position.GetX(), 2) +
Mathf.Pow(y - position.GetY(), 2));
}
示例13: Area
public static int Area(Position position1, Position position2)
{
return Mathf.Abs(position1.GetX() - position2.GetX()) *
Mathf.Abs(position1.GetY() - position2.GetY());
}