예제 #1
0
        public void Pop(BubbleConfigItem config, Vector3 towards)
        {
            _renderer.color = config.color;
            _text.SetText(config.display);

            transform.DOMove(towards, 0.25f).OnComplete(() => PlayPopParticles(config.color));
        }
예제 #2
0
 public void PlaceBubble(BubbleConfigItem bubbleConfig)
 {
     _bubbleConfig = bubbleConfig;
     _view.SetBubbleColor(bubbleConfig.color);
     _view.SetBubbleNumber(bubbleConfig.display);
     _isReserved = false;
     _view.PlayBubbleAddedSound();
 }
예제 #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();
                }
            }
        }
예제 #4
0
        public void Refresh(IBubbleScore score)
        {
            current          = config.Get(score.Exponent);
            background.color = outline.color = current.Background;
            var valueStr   = Mathf.Pow(2, score.Exponent % 10).ToString("0");
            var textConf   = font[valueStr];
            var suffixConf = GetSuffix(score);

            text.sprite   = textConf.Sprite;
            suffix.sprite = suffixConf.Sprite;

            Vector3 textPosition = Vector3.right * -suffixConf.Width / 2f;
            Vector3 suffixOffset = Vector3.right * (textConf.Width + suffixConf.Width) / 2f;

            text.transform.localPosition = textPosition;
            suffix.transform.position    = text.transform.position + suffixOffset;// + suffixOffset;
            ShowOutline(score.Exponent);
        }
예제 #5
0
 public void InstantPop(BubbleConfigItem config)
 {
     PlayPopParticles(config.color);
 }
예제 #6
0
 public void SetBubbleConfig(BubbleConfigItem bubbleConfigItem)
 {
     _bubbleConfig   = bubbleConfigItem;
     _renderer.color = bubbleConfigItem.color;
     _text.SetText(bubbleConfigItem.display);
 }
예제 #7
0
 private void BubbleAddedToBoard(BubbleSlotView bubbleSlotView, BubbleConfigItem bubbleConfig)
 {
     _waitForBubbleToArrive = false;
 }
예제 #8
0
 public void Pop(BubbleSlotView mergedBubbleSlot)
 {
     _view.Pop(mergedBubbleSlot);
     _isReserved   = false;
     _bubbleConfig = null;
 }
예제 #9
0
 public void ActivatePreview(BubbleConfigItem config)
 {
     _renderer.color = new Color(config.color.r / 255f, config.color.g / 255f, config.color.b / 255f, 0.25f);
 }