本文整理汇总了C#中State.GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# State.GetPosition方法的具体用法?C# State.GetPosition怎么用?C# State.GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类State
的用法示例。
在下文中一共展示了State.GetPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Successor
//Successor
public List<KeyValuePair<Vector2,State>> Successor(State state)
{
//Next states
List<KeyValuePair<Vector2,State>> nextStates = new List<KeyValuePair<Vector2, State>> ();
//Get all theoretically valid movements
List<Vector2> totalMovs = new List<Vector2>() { Vector2.up, Vector2.right, Vector2.down, Vector2.left };
//Create a list with valid movements
List<Vector2> validMovs = new List<Vector2> ();
//Get state position
Vector2 actorPos = state.GetPosition();
//Loop movements to validate using unity collisions
foreach (Vector2 mov in totalMovs) {
//If the movement is valid is moved to valid movements
Vector2 newPos = state.GetPosition() + mov;
int newX = Convert.ToInt32(newPos.x);
int newY = Convert.ToInt32(newPos.y);
if(newX >= 0 && newX < _matrix.GetLength(0) && newY >= 0 && newY < _matrix.GetLength(1))
if (_matrix[newX, newY].overFloor != OverFloorType.Wall)
{
validMovs.Add(mov);
}
}
//Loop valid movements to check result
foreach (Vector2 validMov in validMovs) {
//Set next character state
Vector2 nextActorPos = actorPos + validMov;
nextStates.Add(new KeyValuePair<Vector2,State>(validMov,new State(nextActorPos)));
}
return nextStates;
}
示例2: GoalTest
//Goal test
public bool GoalTest(State state)
{
_guimanager.MarkThinkCell(state.GetPosition());
return state.GetPosition() == _finalPosition;
}