示例#1
0
        internal BubbleViewModel(BubbleMatrixViewModel bubbleMatrix, int row, int column)
        {
            if (bubbleMatrix == null)
            {
                throw new ArgumentNullException("bubbleMatrix");
            }

            if (row < 0 || bubbleMatrix.RowCount <= row)
            {
                throw new ArgumentOutOfRangeException("row");
            }

            if (column < 0 || bubbleMatrix.ColumnCount <= column)
            {
                throw new ArgumentOutOfRangeException("column");
            }

            _bubbleMatrix = bubbleMatrix;

            MoveTo(row, column);

            this.BubbleType = GetRandomBubbleType();

            BurstBubbleGroupCommand = new ReactiveCommand();
            BurstBubbleGroupCommand.Subscribe(x => _bubbleMatrix.BurstBubbleGroup());
        }
        internal GameOverViewModel(BubbleMatrixViewModel bubbleMatrix)
        {
            if (bubbleMatrix == null)
            {
                throw new ArgumentNullException("bubbleMatrix");
            }

            _bubbleMatrix = bubbleMatrix;

            if (bubbleMatrix.Bubbles.Count == 0)
            {
                this.Title = "CONGRATULATIONS!";
            }
            else
            {
                string theLetterS = bubbleMatrix.Bubbles.Count == 1 ? string.Empty : "S";
                this.Title = string.Format(CultureInfo.CurrentCulture, "{0} BUBBLE{1} LEFT", bubbleMatrix.Bubbles.Count, theLetterS);
            }

            this.Subtitle = "Most bubbles popped at once: " + bubbleMatrix.MostBubblesPoppedAtOnce;

            this.QuitCommand = new RelayCommand(Application.Current.Shutdown);
        }
示例#3
0
        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));
        }
示例#4
0
        internal BubbleViewModel(BubbleMatrixViewModel bubbleMatrix, int row, int column)
        {
            if (bubbleMatrix == null)
            {
                throw new ArgumentNullException("bubbleMatrix");
            }

            if (row < 0 || bubbleMatrix.RowCount <= row)
            {
                throw new ArgumentOutOfRangeException("row");
            }

            if (column < 0 || bubbleMatrix.ColumnCount <= column)
            {
                throw new ArgumentOutOfRangeException("column");
            }

            _bubbleMatrix = bubbleMatrix;

            _locationManager = new BubbleLocationManager();
            _locationManager.MoveTo(row, column);

            this.BubbleType = GetRandomBubbleType();
        }
 internal BubblesTaskManager(BubbleMatrixViewModel bubbleMatrix)
 {
     _bubblesTaskFactory = new BubblesTaskFactory(bubbleMatrix);
     _pendingTasks       = new Queue <BubblesTask>();
     _undoStack          = new Stack <IEnumerable <BubblesTask> >();
 }
示例#6
0
 internal BubbleTaskFactory(BubbleMatrixViewModel bubbleMatrix)
 {
     _bubbleMatrix = bubbleMatrix;
 }
示例#7
0
 internal BubbleTaskManager(BubbleMatrixViewModel bubbleMatrix)
 {
     _bubbleMatrix = bubbleMatrix;
     _taskFactory  = new BubbleTaskFactory(bubbleMatrix);
     _undoStack    = new Stack <IEnumerable <BubbleTaskGroup> >();
 }