示例#1
0
        public TetrisGameViewModel(Grid gameRenderSurface, Grid nextShapeRenderSurface)
        {
            var playfield = new GameField();
            var renderer  = new GameRenderer(gameRenderSurface, nextShapeRenderSurface, playfield);

            this.gameEngine = new GameEngine(playfield, renderer);
            this.gameEngine.GamePropertyChanged       += GameEngine_PropertyChanged;
            this.gameEngine.GameEnded                 += GameEngine_GameEnded;
            this.gameEngine.EndGameAnimationCompleted += GameEngine_EndGameAnimationCompleted;

            this.StartGameCommand       = new RelayCommand(OnStartGame, OnCanStartGame);
            this.EndGameCommand         = new RelayCommand(OnEndGame, OnCanEndGame);
            this.PauseGameCommand       = new RelayCommand(OnPause, OnCanPauseGame);
            this.ResumeGameCommand      = new RelayCommand(OnResume, OnCanResumeGame);
            this.MoveCommand            = new RelayCommand(OnMove);
            this.RotateCommand          = new RelayCommand(OnRotate);
            this.HideEndGameInfoCommand = new RelayCommand(OnHideEndGameInfo);

            this.Highscore = ScoringSystem.GetHighscore();
        }