Пример #1
0
        private GemMatch MatchInGem(Gem gem, Vector2 gemPosition, bool canCheckSelf = true)
        {
            GemMatch horizontalMatch = HorizontalMatchOfGem(gem, gemPosition, canCheckSelf);

            horizontalMatch.AddGem(gem);

            GemMatch verticalMatch = VerticalMatchOfGem(gem, gemPosition, canCheckSelf);

            verticalMatch.AddGem(gem);

            GemMatch definitiveMatch = new GemMatch();

            if (horizontalMatch.IsMatch())
            {
                foreach (var _gem in horizontalMatch.gems)
                {
                    definitiveMatch.AddGem(_gem);
                }
            }

            if (verticalMatch.IsMatch())
            {
                foreach (var _gem in verticalMatch.gems)
                {
                    definitiveMatch.AddGem(_gem);
                }
            }

            return(definitiveMatch);
        }
Пример #2
0
        private void DoMatch(GemMatch match)
        {
            bool isMatchLegal = match.IsMatch();

            if (!isMatchLegal)
            {
                return;
            }

            foreach (var hGem in match.gems)
            {
                hGem.OnMatchEnd();
                hGem.TransformIntoNewGem(GetRandomGemData());
                FallAllGemsFromPosition(hGem.boardPosition + Vector2.up);
                SendGemToTop(hGem);
            }
        }