예제 #1
0
 /// <summary>
 /// Gets the next node to move from from the path.
 /// </summary>
 /// <returns>null</returns>
 private IEnumerator Move()
 {
     while (true)
     {
         FindPath(grid.GetNodeFromWorldPoint(player.transform.position), grid.GetNodeFromWorldPoint(transform.position));
         if (grid.path.Count > 0)
         {
             grid.path.RemoveAt(0);
         }
         if (grid.path.Count > 0)
         {
             Node nextPos = grid.path[0];
             grid.path.RemoveAt(0);
             yield return(MoveToPos(nextPos.position));
         }
         else
         {
             yield return(null);
         }
     }
 }