Ejemplo n.º 1
0
        public void CheckForMatch(Grid grid, List <PlacedHexagon> placedHexagons, ISet <PlacedHexagon> list)
        {
            var neighbors = NeighborHood.GetNeighborsIndexed(Cell, placedHexagons, grid);

            for (var i = 0; i < 6; i++)
            {
                if (!neighbors.ContainsKey(i))
                {
                    continue;
                }
                if (!neighbors[i].Hexagon.color.Equals(Hexagon.color))
                {
                    continue;
                }
                int nextIndex = (i + 1) % 6;
                if (!neighbors.ContainsKey(nextIndex))
                {
                    continue;
                }
                if (!neighbors[nextIndex].Hexagon.color.Equals(Hexagon.color))
                {
                    return;
                }
                list.Add(this);
                list.Add(neighbors[i]);
                list.Add(neighbors[nextIndex]);
            }
        }
        private void ExplodeMatchedHexagons(ICollection <PlacedHexagon> matchedHexagons)
        {
            AnimatePopOut(matchedHexagons);
            for (var i = 0; i < matchedHexagons.Count; i++)
            {
                score.IncreaseValue(scoreMultiplier);
                if (score.GetValue() % bombScoreInterval == 0)
                {
                    _shouldPlaceBomb = true;
                }
            }

            foreach (var _ in _gridBuilder.GetPlacement().OfType <BombHexagon>())
            {
                _shouldPlaceBomb = false;
            }
            highScore.SetMaximum(score.GetValue());
            if (!NeighborHood.IsThereAnyAvailableMovesLeft(_gridBuilder.GetPlacement(), _grid))
            {
                ExecuteGameOver();
            }
        }