コード例 #1
0
ファイル: (1) Board.cs プロジェクト: sbo0823/match3_source
    IEnumerator ClearAndRefillBoardRoutine(List <GamePiece> gamePieces)
    {
        m_playerInputEnabled = false;

        isRefilling = true;

        List <GamePiece> matches = gamePieces;

        m_scoreMultiplier = 0; //reset score multiplier every new player move.

        do
        {
            m_scoreMultiplier++;

            yield return(StartCoroutine(ClearAndCollapseRoutine(matches)));            //after it collapsed,


            // add pause here
            yield return(null);

            yield return(StartCoroutine(RefillRoutine())); //refill

            matches = FindAllMatches();                    //and find all matches again


            yield return(new WaitForSeconds(0.2f)); //wait again

            if (matches.Count != 0)
            {
                //Debug.Log("There is  matches from refilled area.");
                if (UIManager.Instance.comboText != null)
                {
                    GameManager.Instance.Combo(GameManager.Instance.numofCombo);
                    GameManager.Instance.numofCombo++;
                }
            }
        }       while (matches.Count != 0); //if finding matches finisehd

//        numofCombo = 2;

        //initiate num of combo

        //deadlock check

        if (m_boardDeadlock.IsDeadlocked(m_allGamePieces, 3))
        {
            yield return(new WaitForSeconds(1f));

            //ClearBoard();
            yield return(StartCoroutine(ShuffleBoardRoutine())); //wait for shuffle to finish

            yield return(new WaitForSeconds(1f));

            yield return(StartCoroutine(RefillRoutine()));
        }
        //re-enable player input
        m_playerInputEnabled            = true;  //user can play game again.
        isRefilling                     = false; //does board refilling gamepieces currently?
        GameManager.Instance.numofCombo = 2;     //initialize numofCombo to the start point.
    }
コード例 #2
0
ファイル: Board.cs プロジェクト: th-tran/bubble-pop
    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;
    }
コード例 #3
0
ファイル: Board.cs プロジェクト: lx-mllr/pixel_crush
    IEnumerator ClearAndRefillBoardRoutine(List <GamePiece> gamePieces)
    {
        m_playerInputEnabled = false;
        isRefilling          = true;

        List <GamePiece> matches = gamePieces;

        //score multiplier
        m_scoreMultiplier = 0;

        do
        {
            //increment score multiplier by 1 for each recursive call of clearandcollapse
            m_scoreMultiplier++;

            yield return(StartCoroutine(ClearAndCollapseRoutine(matches)));

            yield return(null);

            //callback to refill the board
            yield return(StartCoroutine(RefillRoutine()));

            //find any matches and repeat
            matches = FindAllMatches();

            yield return(new WaitForSeconds(0.2f));
        } while (matches.Count != 0); //while list of matches still has gamepieces in it
        //deadlock check
        if (m_boardDeadlock.IsDeadlocked(m_allGamePieces, 3))
        {
            yield return(new WaitForSeconds(1f));

            //ClearBoard();
            StartCoroutine(ShuffleBoardRoutine());
            yield return(new WaitForSeconds(1f));

            //could be bad, no subsequent checks for deadlock
            yield return(StartCoroutine(RefillRoutine()));
        }

        //enable player input
        m_playerInputEnabled = true;
        //refilling is done
        isRefilling = false;
    }
コード例 #4
0
    IEnumerator ClearAndRefillBoardRoutine(List <GamePiece> gamePieces)
    {
        m_playerInputEnabled = false;       // allows player to switch tiles only once
        List <GamePiece> matches = gamePieces;

        isRefilling = true;

        m_scoreMultiplier = 0;

        do
        {
            m_scoreMultiplier++;

            yield return(StartCoroutine(ClearAndCollapseRoutine(matches)));

            yield return(null);

            //refill
            yield return(StartCoroutine(RefillRoutine()));

            matches = FindAllMatches();

            yield return(new WaitForSeconds(0.2f));
        }while (matches.Count != 0);


        if (m_boardDeadlock.IsDeadlocked(m_allGamePieces, 3))
        {
            yield return(new WaitForSeconds(1f));

            //ClearBoard ();
            yield return(StartCoroutine(ShuffleBoardRoutine()));

            yield return(new WaitForSeconds(1f));

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

        m_playerInputEnabled = true;

        isRefilling = false;
    }
コード例 #5
0
    private IEnumerator ClearAndRefillBoardRoutine(List <GamePiece> gamePieces)
    {
        playerInputEnabled = false;
        isRefilling        = true;

        List <GamePiece> matches = gamePieces;

        scoreMultiplier = 0;

        do
        {
            scoreMultiplier++;

            yield return(StartCoroutine(ClearAndCollapseRoutine(matches)));

            yield return(null);

            yield return(StartCoroutine(RefillRoutine()));

            matches = FindAllMatches();

            yield return(new WaitForSeconds(0.25f));
        }while (matches.Count != 0);

        if (boardDeadlock.IsDeadlocked(allGamePieces, 3))
        {
            yield return(new WaitForSeconds(1f));

            // ClearBoard();

            yield return(StartCoroutine(ShuffleBoardRoutine()));

            yield return(new WaitForSeconds(1f));

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

        playerInputEnabled = true;
        isRefilling        = false;
    }
コード例 #6
0
 // test if the Board is deadlocked
 public void TestDeadlock()
 {
     boardDeadlock.IsDeadlocked(allGamePieces, 3);
 }