public IEnumerator GeneratePlatformerMap(GameProgram.MapSize mapSize) { //Randomly choose the number of rooms (from a range, based on size) int iterations = 10; if (mapSize == GameProgram.MapSize.Small) { iterations = UnityEngine.Random.Range(30, 40); } else if (mapSize == GameProgram.MapSize.Medium) { iterations = UnityEngine.Random.Range(41, 60);; } else if (mapSize == GameProgram.MapSize.Large) { iterations = UnityEngine.Random.Range(61, 80); } string path = PlatformerPathString(iterations); Debug.Log("path: " + path); _pProgram = PlatformerCompiler.Compile(path); yield return(_pProgram.Run()); }
public static PlatformerProgram Compile(string source) { AntlrInputStream antlerStream = new AntlrInputStream(source); PlatformerMapLexer lexer = new PlatformerMapLexer(antlerStream); CommonTokenStream tokenStream = new CommonTokenStream(lexer); PlatformerMapParser parser = new PlatformerMapParser(tokenStream); parser.prog(); // <-- compile happens here (see .g4 file) PlatformerCompiler compiler = parser.Compiler; PlatformerProgram program = new PlatformerProgram(compiler.Elements); return(program); }