Пример #1
0
        private void OnCurrentTopYChanged(int topY)
        {
            var maxColumns = _maxBounds.x - _minBounds.x;

            for (int col = Mathf.Abs(topY % 2); col < maxColumns; col += 2)
            {
                var view = _bubbleViewFactory.Create(Random.Range(1, _maxSpawnExponent), new Vector2Int(col, topY),
                                                     true);
                view.ViewModel.SetIsOnGrid(true);
                view.ViewModel.SetIsConnectedToCeiling(true);
            }

            UpdateConnectedToCeiling();
        }
Пример #2
0
        private void FillNextBubbles()
        {
            while (NextBubbles.Count < 2)
            {
                var nextExponent = GetNextExponent();
                var view         = _bubbleViewFactory.Create(nextExponent, Vector2Int.zero, false);
                var transform    = view.transform;
                transform.position   = _boardView.BubbleSpawnAnchor.position;
                transform.localScale = _boardView.BubbleSpawnAnchor.localScale;
                view.ViewModel.SetIsOnGrid(false);
                _nextBubbles.Add(view.ViewModel);
            }

            NextBubbles.Last().SetNextBubbleIndex(1);
            var nextBubble = NextBubbles.First();

            nextBubble.SetNextBubbleIndex(0);
            _serialDisposable.Disposable =
                nextBubble.NextBubbleIndex
                .Where(index => index == -1)
                .Take(1)
                .Subscribe(_ => RemoveBubble());
        }
Пример #3
0
        private void InitializeBoard()
        {
            var minRow = _boardSetting.Min.y;
            var maxColumns = _boardSetting.Max.x - _boardSetting.Min.x;
            var maxRows = _boardSetting.InitialRows;

            for (var row = minRow; row < maxRows; row++)
            {
                for (var col = row % 2; col < maxColumns; col += 2)
                {
                    if (row == maxRows - 1 && Random.Range(0f, 1f) < 0.3f)
                    {
                        continue;
                    }

                    _bubbleViewFactory.Create(
                        Random.Range(1, _boardSetting.InitialMaxSpawnExponent),
                        new Vector2Int(col, row),
                        true);
                }
            }

            _boardViewModel.SetIsInitialized(true);
        }