コード例 #1
0
 void ResetGridForAStar(bool startFromCurrentPosition)
 {
     if (startFromCurrentPosition)
         startPosition = graph.curNodePosition;
     myCat.SetImmediatePosition(startPosition * gridSize, gridSize);
     graph = new Graph(grid, graphics.PreferredBackBufferWidth / gridSize, graphics.PreferredBackBufferHeight / gridSize, false, myCat);
     graph.AStarSearchInitialize(startPosition, destination);
 }
コード例 #2
0
 void StartRandomSearch()
 {
     destination = new Vector2(random.Next(0, graphics.PreferredBackBufferWidth / gridSize - 1), random.Next(0, graphics.PreferredBackBufferHeight / gridSize - 1));
     startPosition = new Vector2(random.Next(0, graphics.PreferredBackBufferWidth / gridSize - 1), random.Next(0, graphics.PreferredBackBufferHeight / gridSize - 1));
     myCat.SetImmediatePosition(startPosition * gridSize, gridSize);
     graph = new Graph(grid, graphics.PreferredBackBufferWidth / gridSize, graphics.PreferredBackBufferHeight / gridSize, myCat);
     graph.BreadthFirstSearchInitialize(startPosition, destination);
 }