public void Dispose() { if (!Disposed) { ingameUI.Dispose(); ingameUI = null; scene = null; soundWorld = null; gameState = null; Disposed = true; } else { throw new ObjectDisposedException(ToString()); } }
public Game(Code2015 game, GameCreationParameters gcp) { this.game = game; this.renderSys = game.RenderSystem; this.parameters = gcp; this.soundWorld = new SoundObjectWorld(); gameState = new GameState(GetLocalPlayers(gcp)); BattleField field = gameState.Field; // 初始化场景 this.scene = new GameScene(renderSys); field.ResourceBallChanged += Field_ResourceBallChanged; for (int i = 0; i < field.CityCount; i++) { City city = field.Cities[i]; city.InitalizeGraphics(renderSys); city.CityVisible += scene.City_Visible; GatherCity gaCity = city as GatherCity; if (gaCity != null) { gaCity.Harvester.InitializeGraphics(renderSys); scene.Scene.AddObjectToScene(gaCity.Harvester); } scene.Scene.AddObjectToScene(city); } field.Fog.InitailizeGraphics(renderSys); AddResources(field); AddScenery(field); gameState.InitialStandards(); { HumanPlayer = gameState.LocalHumanPlayer; City hstart = HumanPlayer.Area.RootCity; this.scene.Camera.Longitude = MathEx.Degree2Radian(hstart.Longitude); this.scene.Camera.Latitude = MathEx.Degree2Radian(hstart.Latitude); } this.ingameUI = new InGameUI(game, this, scene, gameState); }