public MenuModule Create(Bank bank, Dictionary <string, Shape> shipList, Dictionary <string, Level> levelList, IReceiveMenuData receiver, ExitGame exit) { //spawn asteroids Level menuScene = levelList["MenuScene"]; EntityHandler entityHandler = new EntityHandler(null, menuScene.PlayArea); AsteroidFactory asteroidFac = new AsteroidFactory(entityHandler); string asteroidPath = SwinGame.AppPath() + "\\resources\\data\\asteroids\\asteroid.json"; for (int i = 0; i < menuScene.AsteroidsToSpawn; i++) { Asteroid toSpawn = asteroidFac.Create(asteroidPath, menuScene.PlayArea); entityHandler.Track(toSpawn); } MenuModule result = new MenuModule(new MenuSendData(receiver), bank, shipList, levelList, menuScene, entityHandler, exit); MenuFactory menuFac = new MenuFactory(dirPath, result); result.AddMenu(menuFac.CreateNormalMenu("\\help.json")); result.AddMenu(menuFac.CreateHighscoreMenu("\\highscores.json")); result.AddMenu(menuFac.CreateNormalMenu("\\main.json")); result.AddMenu(menuFac.CreateNormalMenu("\\options.json")); result.AddMenu(menuFac.CreateNormalMenu("\\scorescreen.json")); result.AddMenu(menuFac.CreateSelectMenu("\\select.json", shipList, levelList)); result.ChangeMenu("Main"); return(result); }
public GameModule Create(string shipId, Difficulty diff, Level level, ShipFactory shipFac, GameSendData gameSendData) { Scoresheet scoreSheet = new Scoresheet(); EntityHandler entHandler = new EntityHandler(scoreSheet, level.PlayArea); CollisionHandler collHandler = new CollisionHandler(level.PlayArea, entHandler); //create player's ship Ship p = shipFac.Create(shipId, Util.RandomPointInRect(level.PlayArea), new WrapBoundaryBehaviour(level.PlayArea), ControllerType.Player1, diff, entHandler); entHandler.Track(p); //camera CameraHandler camHandler = new CameraHandler(p, level.PlayArea); //ai spawner AISpawner aiSpawner = new AISpawner(diff, level.PlayArea, shipFac, entHandler); //spawn predefined ships from the level foreach (string enemyId in level.ShipsToSpawn) { Ship toSpawn = shipFac.Create(enemyId, Util.RandomPointInRect(level.PlayArea), new WrapBoundaryBehaviour(level.PlayArea), ControllerType.Computer, diff, entHandler); entHandler.Track(toSpawn); } //spawn asteroids AsteroidFactory asteroidFac = new AsteroidFactory(entHandler); string asteroidPath = SwinGame.AppPath() + "\\resources\\data\\asteroids\\asteroid.json"; for (int i = 0; i < level.AsteroidsToSpawn; i++) { Asteroid toSpawn = asteroidFac.Create(asteroidPath, level.PlayArea); entHandler.Track(toSpawn); } InputController inpController; if (p is IControllable) { InputControllerFactory inpContFac = new InputControllerFactory(); inpController = inpContFac.Create(p as IControllable, ControllerType.Player1); } else { inpController = null; } return(new GameModule(p, level, aiSpawner, entHandler, collHandler, camHandler, gameSendData, scoreSheet, inpController)); }