예제 #1
0
파일: Piece.cs 프로젝트: Yeo-Yong-Jun/AA
        public IEnumerator CheckMove()                                            //coroutine function to check the move of the piece
        {
            yield return(new WaitForSeconds(.5f));

            if (otherPiece != null)                                               //if other piece is not null
            {
                if (!isMatched && !otherPiece.GetComponent <Piece>().isMatched)   //if piece is not matched and other piece is not matched
                {
                    otherPiece.GetComponent <Piece>().row    = row;               //resets the otherpiece row back to its original row before the move
                    otherPiece.GetComponent <Piece>().column = column;            //resets the otherpiece column back to its  original column before the move
                    row    = previousRow;                                         //resets this piece row back to its original row
                    column = previousColumn;                                      //resets this column back to its original column
                    yield return(new WaitForSeconds(0.2f));

                    board.currState = GameState.Move;
                }
                else                                                              //otherwise, if the pieces are matched
                {
                    board.DestroyMatches();                                       //call the destroymatches from board

                    criteria.moveCounter--;
                }
                otherPiece = null;                                                //sets otherpiece to null
            }
        }