public DungeonGame(string gameDir, GameOptions options) : base(gameDir, options) { EnvironmentObject env; switch (options.Map) { case GameMap.Fortress: env = FortressWorldCreator.InitializeWorld(this.World, options.MapSize); break; case GameMap.Adventure: var dwc = new DungeonWorldCreator(this.World); dwc.InitializeWorld(this.World, options.MapSize); env = dwc.MainEnv; break; default: throw new Exception(); } var player = CreatePlayer(env); this.AddPlayer(player); }
public IGame CreateGame(string gameDir, GameMode mode, GameMap map) { MyTraceContext.ThreadTraceContext = new MyTraceContext("Server"); WorldTickMethod tickMethod; switch (mode) { case GameMode.Fortress: tickMethod = WorldTickMethod.Simultaneous; break; case GameMode.Adventure: tickMethod = WorldTickMethod.Sequential; break; default: throw new Exception(); } var world = new World(mode, tickMethod); Action<World> worldCreator; switch (map) { case GameMap.Fortress: worldCreator = Fortress.MountainWorldCreator.InitializeWorld; break; case GameMap.Adventure: var dwc = new Fortress.DungeonWorldCreator(world); worldCreator = dwc.InitializeWorld; break; case GameMap.Arena: throw new Exception(); default: throw new Exception(); } world.Initialize(delegate { worldCreator(world); }); var engine = new GameEngine(world, mode); InitGame(engine, gameDir); return engine; }