Ejemplo n.º 1
0
        /// <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");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Starts a new game.
        /// </summary>
        public void StartNewGame()
        {
            KillGame();
            GameUserIterface = new TetrisGUI();
            Model            = new Tetris();
            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();
        }