public GameEngine(GameField playfieldInfo, GameRenderer renderer) { this.playfieldInfo = playfieldInfo; this.renderer = renderer; this.frameRenderTimer = new DispatcherTimer(); this.frameRenderTimer.Interval = TimeSpan.FromMilliseconds(frameRenderingInterval); this.frameRenderTimer.Tick += OnFrameRenderTimerTick; this.highscore = ScoringSystem.GetHighscore(); this.InitializeEndGameAnimationWorker(); this.endGameBlocksBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#8FC461")); this.endGameBlocksBrush.Freeze(); }
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.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.Highscore = ScoringSystem.GetHighscore(); }