예제 #1
0
    public void RaiseBoardShuffleRequiredEvent()
    {
        Match3BoardGameLogic.Instance.unstableLock++;

        IsBoardReshuffling = true;

        if (OnBoardShuffleRequired != null)
        {
            OnBoardShuffleRequired();
        }

        OnReshuffleRequired.RaiseEvent();

//		Debug.LogWarning("[BoardShuffleController] RaiseBoardShuffleRequiredEvent -> No more possible matches on the board...");

        board = Match3BoardGameLogic.Instance.boardData;

        // Collect all board pieces containing a normal tile to prepare for shuffling.
        board.ApplyActionToAll((boardPiece) =>
        {
            // Only re-shuffle normal tiles
            if (boardPiece.Tile != null && boardPiece.Tile.GetType() == typeof(NormalTile) && !boardPiece.Tile.IsDestroying)
            {
                piecesToReshuffle.Add(boardPiece as Match3BoardPiece);
                // Disable the tiles logic before starting the re-shuffle
                boardPiece.Tile.enabled = false;
            }
        });

        // Disable tile switching input
        TileSwitchInput.Instance.DisableInput();

        StartReshuffleTilesAnim();
    }
	public void RaiseBoardShuffleRequiredEvent() 
	{
		Match3BoardGameLogic.Instance.unstableLock++;
		
		IsBoardReshuffling = true;
		
		if (OnBoardShuffleRequired != null) {
			OnBoardShuffleRequired();
		}

		OnReshuffleRequired.RaiseEvent();
		
//		Debug.LogWarning("[BoardShuffleController] RaiseBoardShuffleRequiredEvent -> No more possible matches on the board...");
		
		board = Match3BoardGameLogic.Instance.boardData;

		// Collect all board pieces containing a normal tile to prepare for shuffling.
		board.ApplyActionToAll((boardPiece) => 
		{
			// Only re-shuffle normal tiles
			if (boardPiece.Tile != null && boardPiece.Tile.GetType() == typeof(NormalTile) && !boardPiece.Tile.IsDestroying)
			{
				piecesToReshuffle.Add(boardPiece as Match3BoardPiece);
				// Disable the tiles logic before starting the re-shuffle
				boardPiece.Tile.enabled = false;
			}
		});	

		// Disable tile switching input
		TileSwitchInput.Instance.DisableInput();

		StartReshuffleTilesAnim();
	}
예제 #3
0
    public bool FindMatches()
    {
//		Debug.LogWarning("[Match3BoardGameLogic] FindBoardMatches()...");
        Match3Tile targetTile = null;

        lastFoundMatches.Clear();
        matchesBatch.Clear();

        // Clear the match count status for all tiles before looking new matches.
        boardData.ApplyActionToAll((boardPiece) =>
        {
            Match3Tile tile = boardPiece.Tile as Match3Tile;

            if (tile != null)
            {
                tile.ResetMatchCountDirections();
            }
        });

        // Vertical matches check.
        for (int colIdx = 0; colIdx < boardData.NumColumns; colIdx++)
        {
            targetTile = null;
            // Reset the targetTile that will be used to detect batches of matches.
            for (int rowIdx = 0; rowIdx < boardData.NumRows; rowIdx++)
            {
                // Check each tile on this row with the current targetTile for match.
                // If the targetTile is null, meaning we don't have a current target tile to match with, we
                // set targetTile to the current tile were on (boardData[rowIdx, colIdx].Tile).
                CheckMatch(boardData[rowIdx, colIdx].Tile as Match3Tile, ref targetTile, true);
            }

            if (matchesBatch.Count >= 3)
            {
                CollectNewFoundMatches(matchesBatch, true);
            }
            matchesBatch.Clear();
        }

        // Horizontal matches check.
        for (int rowIdx = 0; rowIdx < boardData.NumRows; rowIdx++)
        {
            targetTile = null;
            for (int colIdx = 0; colIdx < boardData.NumColumns; colIdx++)
            {
                CheckMatch(boardData[rowIdx, colIdx].Tile as Match3Tile, ref targetTile, false);
            }

            if (matchesBatch.Count >= 3)
            {
                CollectNewFoundMatches(matchesBatch, false);
            }
            matchesBatch.Clear();
        }

        if (lastFoundMatches.Count > 0)
        {
            if (OnBoardMatchesFound != null)
            {
                OnBoardMatchesFound(this);
            }

//			if (useBugTrap)
//			{
//				for(int i = 0; i < lastFoundMatches.Count; i++)
//				{
//					if (lastFoundMatches[i] == null || lastFoundMatches[i].IsMoving || !lastFoundMatches[i].HasReachedBoardPieceArea() || lastFoundMatches[i].IsDestroying)
//					{
//						Debug.LogWarning("ALARM!!! Invalid tile found in matches: " + lastFoundMatches[i] + " frame: " + Time.frameCount);
//						Debug.LogWarning("IsMoving = " + lastFoundMatches[i].IsMoving);
//						Debug.LogWarning("HasReachedBoardPieceArea = " + lastFoundMatches[i].HasReachedBoardPieceArea());
//						Debug.LogWarning("IsDestroying = " + lastFoundMatches[i].IsDestroying);
//						Debug.Break();
//					}
//				}
//			}
        }

        return(lastFoundMatches.Count > 0);
    }