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 GameCompiler DefineGame(string type, string difficulty, string size) { GameProgram.GameType gameType = GameProgram.GameType.Platformer; string dungeonGame = Enum.GetName(typeof(GameProgram.GameType), GameProgram.GameType.Dungeon); if (type.ToUpper().Equals(dungeonGame.ToUpper())) { gameType = GameProgram.GameType.Dungeon; } GameProgram.SkillLevel gameDifficulty = GameProgram.SkillLevel.Easy; string regDifficulty = Enum.GetName(typeof(GameProgram.SkillLevel), GameProgram.SkillLevel.Regular); string hardDifficulty = Enum.GetName(typeof(GameProgram.SkillLevel), GameProgram.SkillLevel.Hard); if (difficulty.ToUpper().Equals(regDifficulty.ToUpper())) { gameDifficulty = GameProgram.SkillLevel.Regular; } else if (difficulty.ToUpper().Equals(hardDifficulty.ToUpper())) { gameDifficulty = GameProgram.SkillLevel.Hard; } GameProgram.MapSize mapSize = GameProgram.MapSize.Small; string medMap = Enum.GetName(typeof(GameProgram.MapSize), GameProgram.MapSize.Medium); string largeMap = Enum.GetName(typeof(GameProgram.MapSize), GameProgram.MapSize.Large); if (size.ToUpper().Equals(medMap.ToUpper())) { mapSize = GameProgram.MapSize.Medium; } else if (size.ToUpper().Equals(largeMap.ToUpper())) { mapSize = GameProgram.MapSize.Large; } GameProgram.GameTypeSetup gameTypeSetup = new GameProgram.GameTypeSetup(gameType, gameDifficulty, mapSize); _elements.Add(gameTypeSetup); return(this); }
public IEnumerator GenerateDungeonMap(GameProgram.MapSize mapSize) { //Randomly choose dominant direction domDir = (DominantDirection)(UnityEngine.Random.Range(0, Enum.GetNames(typeof(DominantDirection)).Length)); //Randomly choose the number of rooms (from a range, based on size) int maxRooms = 1; if (mapSize == GameProgram.MapSize.Small) { maxRooms = UnityEngine.Random.Range(4, 6); } else if (mapSize == GameProgram.MapSize.Medium) { maxRooms = UnityEngine.Random.Range(7, 10);; } else if (mapSize == GameProgram.MapSize.Large) { maxRooms = UnityEngine.Random.Range(11, 15); } int completedCorrSegments = 5; int maxIterations = (completedCorrSegments * 4) - 1; //build a random corridor to connection each room: string path = ""; for (int i = 0; i < maxRooms; i++) { string firstChar; if (i == 0) { firstChar = "X"; } else { firstChar = "R"; } path += DungeonPathString(maxIterations, firstChar); } path += DungeonPathString(maxIterations, "Z"); path = path.ToLower(); Debug.Log(domDir); Debug.Log(path); //TESTING: //path = "aj.fnnj.fnnl.hnnm.innl.hnnj.fnnm.innj"; //Testing all DD:North connections //path = "bk.gssk.gssl.hssm.issl.hssk.jssm.issj"; //Testing all DD:South connections //path = "cl.heel.heek.geej.feek.geel.heej.feel"; //Testing all DD:East connections //path = "dm.iwwm.iwwk.gwwj.fwwk.gwwm.iwwj.fwwm"; //Testing all DD:West connections //path = "aj.fnnj.feej.fnnj.frm.iwwj.feel.hnnm.innj.frm.iwwm.innj.frm.innl.heej.frl.heej.fnnj.frm.iwwm.innj.fz"; //testing rooms going north //path = "bk.gssk.gssl.hssm.iwwk.grl.heel.hssk.grm.issl.heek.gwwm.iwwk.grl.hssm.issk.grl.heel.hssk.grm.issl.hssk.gz"; //testing rooms going south //path = "cl.heel.heel.hrj.fnnl.heel.hrk.gssl.hssl.hrj.feej.feel.hrj.feej.feek.geel.hz"; //testing rooms going east //path = "dm.iwwm.iwwm.issm.irk.gssm.issm.iwwm.iwwm.irk.gssm.innj.fwwm.irj.fwwk.gwwk.gwwm.irj.fnnm.iwwm.iz"; //testing rooms going west _dProgram = DungeonCompiler.Compile(path); yield return(_dProgram.Run()); }