public void RemoveObstacle_OutOfMaterix() { Vector2 obstaclePosition = new Vector2(5, 3); AStarWithOutClosedList aStar = new AStarWithOutClosedList(10, 10); aStar.SetObstacle(obstaclePosition); aStar.RemoveObstacle(new Vector2(100, 5)); aStar.RemoveObstacle(new Vector2(5, 100)); aStar.RemoveObstacle(new Vector2(-10, 5)); aStar.RemoveObstacle(new Vector2(5, -10)); for (int x = 0; x < aStar.matrix.GetLength(0); x++) { for (int y = 0; y < aStar.matrix.GetLength(1); y++) { if (x != (int)obstaclePosition.x || y != (int)obstaclePosition.y) { Assert.IsTrue(aStar.matrix[x, y].canThrough); } else { Assert.IsFalse(aStar.matrix[x, y].canThrough); } } } }
public void RemoveObstacle_Normal() { Vector2 obstaclePosition = new Vector2(5, 3); AStarWithOutClosedList aStar = new AStarWithOutClosedList(10, 10); aStar.SetObstacle(obstaclePosition); aStar.RemoveObstacle(obstaclePosition); foreach (AStarWithOutClosedListNode node in aStar.matrix) { Assert.IsTrue(node.canThrough); } }
void MouseMiddleDown() { Vector2 position = GetMousePosition(); AStarWithOutClosedListNode node = _aStar.GetNode(position); if (node == null) { return; } if (node.canThrough) { _aStar.SetObstacle(position); } else { _aStar.RemoveObstacle(position); } DoFindPath(); }