Пример #1
0
    private IEnumerator HandleMatch(List <StackNode> matches)
    {
        handlingMatch = true;
        board.Freeze();
        int points = 0;

        audioManager.Play(audioSource, audioManager.matchRisingAudio);
        yield return(new WaitForSeconds(handleMatchDelay));

        for (int i = 0; i < matches.Count; i++)
        {
            // handle match i
            //Destroy scoop game objects
            for (int j = matches[i].startIndex + matches[i].consecutiveScoops - 1; j >= matches[i].startIndex; j--)
            {
                scoopStack[j].MeltScoop();
                yield return(new WaitForSeconds(.01f));
            }
            points += PointsManager.AccruePoints(matches[i].consecutiveScoops, i + 1);
            yield return(audioManager.PlayAndWait(audioSource, audioManager.ScoopsMatchAudio));

            // move everything above matches[i].startIndex + matches[i].consecutiveScoops down
            for (int j = matches[i].startIndex + matches[i].consecutiveScoops; j < scoopStack.Count; j++)
            {
                Vector2Int newIndex = new Vector2Int(
                    scoopStack[j].currentIndex.x,
                    Mathf.Clamp(scoopStack[j].currentIndex.y - matches[i].consecutiveScoops, 1, scoopStack[j].currentIndex.y));
                scoopStack[j].DropAfterMatch(newIndex);
                yield return(new WaitForSeconds(.02f));
            }
            scoopStack.RemoveRange(matches[i].startIndex, matches[i].consecutiveScoops);
            yield return(new WaitForSeconds(.3f));
        }
        (audioManager.ScoopsMatchAudio as IncreasingPitchAudioEvent).Reset();

        board.Unfreeze();
        if (scoopStack.Count == 0)
        {
            // Apply emptyCone Bonus
            points += PointsManager.AddEmptyConeBonus();
        }
        PointsManager.AddPoints(PointsManager.CalculatePoints(points, matches.Count));
        handlingMatch = false;
    }