public bool Initalize(int screenWidth, int screenHeight, DirectoryInfo dataSet, bool showTutorial, Form parentForm, out string reason) { _parentForm = parentForm; Random = new Random(); MousePos = new Point(); ScreenWidth = screenWidth; ScreenHeight = screenHeight; GameDataSet = dataSet; Galaxy = new Galaxy(); EmpireManager = new EmpireManager(this); ShipShader = GorgonLibrary.Graphics.FXShader.FromFile("ColorShader.fx", GorgonLibrary.Graphics.ShaderCompileOptions.OptimizationLevel3); StarShader = GorgonLibrary.Graphics.FXShader.FromFile("StarShader.fx", GorgonLibrary.Graphics.ShaderCompileOptions.OptimizationLevel3); if (!SpriteManager.Initialize(GameDataSet, out reason)) { return false; } if (!FontManager.Initialize(GameDataSet, out reason)) { return false; } RaceManager = new RaceManager(); if (!RaceManager.Initialize(GameDataSet, Random, out reason)) { return false; } AIManager = new AIManager(); if (!AIManager.Initialize(GameDataSet, out reason)) { return false; } MasterTechnologyManager = new MasterTechnologyManager(); if (!MasterTechnologyManager.Initialize(this, out reason)) { return false; } _mainGameMenu = new MainGameMenu(); if (!_mainGameMenu.Initialize(this, out reason)) { return false; } _screenInterface = _mainGameMenu; _currentScreen = Screen.MainMenu; _situationReport = new SituationReport(this); Cursor = SpriteManager.GetSprite("Cursor", Random); if (Cursor == null) { reason = "Cursor is not defined in sprites.xml"; return false; } reason = string.Empty; return true; }
public void ChangeToScreen(Screen whichScreen) { switch (whichScreen) { case Screen.MainMenu: if (_mainGameMenu == null) { _mainGameMenu = new MainGameMenu(); string reason; if (!_mainGameMenu.Initialize(this, out reason)) { MessageBox.Show("Exception in loading Main Menu. Reason: " + reason); _parentForm.Close(); } } _screenInterface = _mainGameMenu; break; case Screen.NewGame: if (_newGame == null) { _newGame = new NewGame(); string reason; if (!_newGame.Initialize(this, out reason)) { MessageBox.Show("Exception in loading New Game Menu. Reason: " + reason); _parentForm.Close(); } } _screenInterface = _newGame; break; case Screen.Galaxy: if (_galaxyScreen == null) { _galaxyScreen = new GalaxyScreen(); string reason; if (!_galaxyScreen.Initialize(this, out reason)) { MessageBox.Show("Exception in loading Galaxy Screen. Reason: " + reason); _parentForm.Close(); } } _galaxyScreen.CenterScreen(); _screenInterface = _galaxyScreen; break; case Screen.Diplomacy: if (_diplomacyScreen == null) { _diplomacyScreen = new DiplomacyScreen(); string reason; if (!_diplomacyScreen.Initialize(this, out reason)) { MessageBox.Show("Exception in loading Diplomacy Screen. Reason: " + reason); _parentForm.Close(); } } _diplomacyScreen.SetupScreen(); _screenInterface = _diplomacyScreen; break; case Screen.FleetList: if (_fleetListScreen == null) { _fleetListScreen = new FleetListScreen(); string reason; if (!_fleetListScreen.Initialize(this, out reason)) { MessageBox.Show("Exception in loading Fleet List Screen. Reason: " + reason); _parentForm.Close(); } } _fleetListScreen.LoadScreen(); _screenInterface = _fleetListScreen; break; case Screen.ProcessTurn: EmpireManager.CurrentEmpire.ClearTurnData(); if (_processingTurnScreen == null) { _processingTurnScreen = new ProcessingTurnScreen(); string reason; if (!_processingTurnScreen.Initialize(this, out reason)) { MessageBox.Show("Exception in loading Processing Turn Screen. Reason: " + reason); _parentForm.Close(); } } if (!EmpireManager.ProcessNextEmpire()) { _situationReport.Refresh(); ChangeToScreen(Screen.Galaxy); break; } _screenInterface = _processingTurnScreen; break; case Screen.Battle: /*if (_spaceCombat == null) { _spaceCombat = new SpaceCombat(); _spaceCombat.Initialize(this); } _spaceCombat.SetupScreen(); _screenInterface = _spaceCombat;*/ break; } _currentScreen = whichScreen; }