Exemple #1
0
    public IEnumerator ClearAndRefillBoardRoutine(List <Bubble> bubbles)
    {
        // Disable player input while the Board is collapsing/refilling
        playerInputEnabled = false;

        // Create a new List of Bubbles, using the initial list as a starting point
        List <Bubble> matches = bubbles;

        do
        {
            scoreMultiplier = 1;
            // Run the coroutine to clear the Board and collapse any columns to fill in the spaces
            yield return(StartCoroutine(ClearAndProcessRoutine(matches)));

            // Refill empty spaces from collapsing
            yield return(StartCoroutine(boardFiller.RefillRoutine()));

            // Find any subsequent matches and repeat the process
            matches = boardMatcher.FindAllMatches();
            if (matches.Count > 0)
            {
                Debug.Log(matches.Count);
            }
        }while (matches.Count != 0);

        if (boardDeadlock.IsDeadlocked())
        {
            yield return(new WaitForSeconds(m_delay));

            yield return(StartCoroutine(boardShuffler.ShuffleBoardRoutine()));
        }

        // Re-enable player input
        playerInputEnabled = true;
    }
Exemple #2
0
    // coroutine to clear GamePieces and collapse empty spaces, then refill the Board
    public IEnumerator ClearAndRefillBoardRoutine(List <GamePiece> gamePieces)
    {
        // disable player input so we cannot swap pieces while the Board is collapsing/refilling
        playerInputEnabled = false;
        isRefilling        = true;

        // clear any blockers adjacent to matching pieces
        boardClearer.ClearAdjacentBlockers(gamePieces);

        // create a new List of GamePieces, using our initial list as a starting point
        List <GamePiece> matches = gamePieces;



        // store a score multiplier for chain reactions
        scoreMultiplier = 0;
        do
        {
            //  increment our score multiplier by 1 for each subsequent recursive call of ClearAndCollapseRoutine
            scoreMultiplier++;

            // run the coroutine to clear the Board and collapse any columns to fill in the spaces
            yield return(StartCoroutine(ClearAndCollapseRoutine(matches)));

            // pause one frame
            yield return(null);

            // run the coroutine to refill the Board
            yield return(StartCoroutine(boardFiller.RefillRoutine()));

            // find any subsequent matches and repeat the process...
            matches = boardMatcher.FindAllMatches();

            yield return(new WaitForSeconds(delay));
        }
        // .. while our list of matches still has GamePieces in it
        while (matches.Count != 0);

        // deadlock check
        if (boardDeadlock.IsDeadlocked(allGamePieces, 3))
        {
            yield return(new WaitForSeconds(delay * 5f));

            // shuffle the Board's normal pieces instead of Clearing out the whole Board
            yield return(StartCoroutine(boardShuffler.ShuffleBoardRoutine(this)));

            yield return(new WaitForSeconds(delay * 5f));

            yield return(StartCoroutine(boardFiller.RefillRoutine()));
        }


        // re-enable player input
        playerInputEnabled = true;
        isRefilling        = false;
    }