public BubbleBurstViewModel() { BubbleMatrix = new BubbleMatrixViewModel(12, 12); // GameOver BubbleMatrix.GameEnded.Subscribe(x => { this.GameOver = new GameOverViewModel(this.BubbleMatrix); this.GameOver.RequestClose.Subscribe(rc => this.GameOver = null); }); // Restart RestartCommand = new ReactiveCommand(); RestartCommand.Subscribe(x => BubbleMatrix.StartNewGame()); // Undo var canUndo = Observable.CombineLatest( this.WhenAnyObservable(x => x.BubbleMatrix.UndoCommand.CanExecuteObservable), this.WhenAnyValue(x => x.GameOver), (ce, go) => ce && go == null); UndoCommand = new ReactiveCommand(canUndo); UndoCommand.Subscribe(x => BubbleMatrix.UndoCommand.Execute(null)); }
/// <summary> /// Starts a new round of the BubbleBurst game. /// </summary> public void StartNewGame() { _bubbleMatrix.StartNewGame(); }