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); } }
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(); } } }
private void ActivateBubbleSlotPreview(BubbleSlotView bubbleSlot) { if (_activatedSlotPreview == bubbleSlot) { return; } DeactivateBubbleSlotPreview(); _activatedSlotPreview = bubbleSlot; _activatedSlotPreview.ActivatePreview(_bubbleAmmo.GetCurrentAmmoConfig()); }
public void Pop(BubbleSlotView mergedBubbleSlot) { _view.Pop(mergedBubbleSlot); _isReserved = false; _bubbleConfig = null; }
public BubbleSlot(BubbleSlotView view) { _id = Guid.NewGuid(); _view = view; _view.SetBubbleSlot(this); }