/// <summary> /// Loads a game and starts it. /// </summary> /// <param name="filename"></param> public void LoadGame(string filename) { GameUserIterface = new TetrisGUI(); Model = FileManager.LoadGameFromFile(filename); if (Model != null) { KillGame(); GameUserIterface.GameController = this; Model.GameController = this; game = new Thread(Model.PlayGame); GameUserIterface.Grid = Model.Fieldgrid; game.Start(); GameUserIterface.ActiveTetromino = Model.ActiveTetromino; UpdateScore(); UpdateLevel(); UpdateLineCount(); GameUserIterface.Show(); } else { BaseUserInterface.Show(); BaseUserInterface.DisplayErrorMessage("Game could not be loaded"); } }
/// <summary> /// Handles the logic that closes the application. /// </summary> public void ExitApplication() { FileManager.SaveHighscore(AllTimeHighScore); if (BaseUserInterface != null) { BaseUserInterface.Close(); } if (game != null) { game.Abort(); } }