Untitled

mail@pastecode.io avatar
unknown
csharp
a month ago
854 B
10
Indexable
Never
        private bool GeneratePathToLevel(int lookedAtLevelID, int targetLevelID, ref List<int> visited)
        {
            if(lookedAtLevelID == targetLevelID)
            {
                return true;
            }

            OverworldLevel level = GetOverworldLevelByID(lookedAtLevelID);
            foreach (int connectingLevelID in level.AdjacentMapLevels)
            {
                if(visited.Contains(connectingLevelID))
                {
                    continue;
                }

                visited.Add(connectingLevelID);                
                if(GeneratePathToLevel(connectingLevelID, targetLevelID, ref visited))
                {
                    pathToLevel.Add(connectingLevelID);
                    return true;
                }
            }

            return false;
        }
Leave a Comment