Created
May 5, 2013 01:06
-
-
Save markedagain/5519317 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<GameObject> getRoute(GameObject fromRoad , GameObject toRoad , GameObject lastRoad, List<GameObject> pathSoFar ){ | |
List<GameObject> _tmpListRoad = GeneralHelper.findTilesNear(_roadList,fromRoad.transform.position,2); | |
for (int i = 0; i < _tmpListRoad.Count; i++) { | |
if (_tmpListRoad[i] == toRoad ){//we found our destination | |
pathSoFar.Add(_tmpListRoad[i]); | |
return pathSoFar; | |
}else{//nope lets make sure this tile is not where we currently are and try the next tile in connection | |
if (fromRoad != _tmpListRoad[i] && lastRoad != _tmpListRoad[i]){ //make sure this tile was not already verified | |
if (getRoute(_tmpListRoad[i],toRoad,fromRoad , pathSoFar) != null){ | |
pathSoFar.Add(_tmpListRoad[i]); | |
return pathSoFar; | |
} | |
} | |
} | |
} | |
return null;//we did not find any new paths connecting to this road | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment