Exemple #1
0
 private void DeactivateBubbleSlotPreview()
 {
     if (_activatedSlotPreview != null)
     {
         _activatedSlotPreview.DeactivatePreview();
         _activatedSlotPreview = null;
     }
 }
        public void Pop(BubbleSlotView mergedBubbleSlot)
        {
            _text.SetText(string.Empty);
            _renderer.color = new Color(1f, 1f, 1f, 0f);

            if (mergedBubbleSlot != null)
            {
                SpawnBubblePop(mergedBubbleSlot.transform.position);
            }
        }
Exemple #3
0
        private void BubbleAddedToBoard(BubbleSlotView bubbleSlotView, BubbleConfigItem bubbleConfig)
        {
            var bubbleSlot = _bubbleSlots[Array.IndexOf(_bubbleSlots, bubbleSlotView.BubbleSlot())];

            bubbleSlot.PlaceBubble(bubbleConfig);

            var adjacentBubblesWithSameScore = GetAdjacentBubblesWithSameScore(bubbleSlot, new List <BubbleSlot> {
                bubbleSlot
            });

            if (adjacentBubblesWithSameScore.Count > 1)
            {
                _score.AddScore(bubbleConfig.number * adjacentBubblesWithSameScore.Count);
                var newBubbleNumber = CalculateMergeScore(bubbleConfig.number, adjacentBubblesWithSameScore.Count);
                var bubbleToMerge   = adjacentBubblesWithSameScore.Last();
                foreach (var adjacent in adjacentBubblesWithSameScore)
                {
                    if (HasAdjacentWithNumber(adjacent, newBubbleNumber))
                    {
                        bubbleToMerge = adjacent;
                        break;
                    }
                }

                var otherAdjacentsToPop = adjacentBubblesWithSameScore.Where(adjacent => adjacent.Id() != bubbleToMerge.Id()).ToList();
                foreach (var otherAdjacent in otherAdjacentsToPop)
                {
                    otherAdjacent.Pop(bubbleToMerge.View());
                }

                if (newBubbleNumber == 2048)
                {
                    var adjacentsWithBubble = GetAdjacentBubbles(bubbleToMerge);
                    foreach (var adjacentBubble in adjacentsWithBubble)
                    {
                        adjacentBubble.Pop(null);
                    }
                }

                RemoveEmptyRows();

                var newBubbleConfig = _bubbleConfig.configs.FirstOrDefault(config => config.number == newBubbleNumber);
                BubbleAddedToBoard(bubbleToMerge.View(), newBubbleConfig);
            }
            else
            {
                SearchHangingBubbles();
                RemoveEmptyRows();

                if (NoMoreBubblesLeft())
                {
                    LevelCompleted();
                }
            }
        }
Exemple #4
0
        private void ActivateBubbleSlotPreview(BubbleSlotView bubbleSlot)
        {
            if (_activatedSlotPreview == bubbleSlot)
            {
                return;
            }

            DeactivateBubbleSlotPreview();

            _activatedSlotPreview = bubbleSlot;
            _activatedSlotPreview.ActivatePreview(_bubbleAmmo.GetCurrentAmmoConfig());
        }
Exemple #5
0
 public void Pop(BubbleSlotView mergedBubbleSlot)
 {
     _view.Pop(mergedBubbleSlot);
     _isReserved   = false;
     _bubbleConfig = null;
 }
Exemple #6
0
 public BubbleSlot(BubbleSlotView view)
 {
     _id   = Guid.NewGuid();
     _view = view;
     _view.SetBubbleSlot(this);
 }