private void DFSVisitting(Planet current, Planet old, bool[] visited, int len)
{
int length;
length = len;
visited[current.id] = true;
if (!(current == old)) {
foreach (Route route in gameScreen.board.routes) {
if (!(route.color == color && route.built)) continue;
if ((route.planet1 == current && route.planet2 == old) || (route.planet2 == current && route.planet1 == old)) length += route.costs;
}
}
List<Planet> neighbours = adjacent[current.id];
foreach (Planet p in neighbours) {
if (!visited[p.id]) {
DFSVisitting(p, current, visited, length);
// returns here
lengths.Add(length);
length = 0;
}
}
lengths.Add(length);
}
private void DFSVisitting(Planet current, Planet old, bool[] visited, int len)
{
int length;
length = len;
visited[current.id] = true;
if (!(current == old)) {
foreach (Route route in gameScreen.board.routes) {
if (!(route.color == color && route.built)) continue;
if ((route.planet1 == current && route.planet2 == old) || (route.planet2 == current && route.planet1 == old)) length += route.costs;
}
}
List<Planet> neighbours = adjacent[current.id];
foreach (Planet p in neighbours) {
if (!visited[p.id]) {
DFSVisitting(p, current, visited, length);
// returns here
lengths.Add(length);
length = 0;
}
}
lengths.Add(length);
}