Skip to content

Instantly share code, notes, and snippets.

@Gillissie
Created July 12, 2011 03:10
Show Gist options
  • Save Gillissie/1077319 to your computer and use it in GitHub Desktop.
Save Gillissie/1077319 to your computer and use it in GitHub Desktop.
<<<<<<< HEAD
duration = JUMP_TIME;
halfDuration = duration * 0.5f;
startTime = Time.time;
=======
while (closest == null && nextList.Count > 0)
{
tileList = nextList;
nextList = new List<Tile>();
foreach (Tile tile in tileList)
{
// see if we can use this tile as a drop location, then rank it
if ((tile.item == null || tile.isPassable) && (tile.y > -1f) && tile.isFlat)
{
float distance = (tile.vector3 - cameraPosition).sqrMagnitude;
if (distance < closestDistance)
{
closestDistance = distance;
closest = tile;
}
}
// add any unvisited neighbors to the next list
foreach (Tile neighbor in tile.allAdjacentTiles())
{
if (!visited.Contains(neighbor))
{
visited.Add(neighbor);
nextList.Add(neighbor);
}
}
}
>>>>>>> Tile-level pathfinding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment