コード例 #1
0
    bool SwapTile()
    {
        bool bCanSwap = false;

        int currentPositonX = currentSelectedTile.PositionX;
        int currentPositonY = currentSelectedTile.PositionY;

        int previousPositonX = previousSelectedTile.PositionX;
        int previousPositonY = previousSelectedTile.PositionY;

        boardGame.SwapTileSync(currentSelectedTile, previousSelectedTile);

        MatchedList = MatchTileCheckNeighbours(currentPositonX, currentPositonY);
        MatchedList.InsertRange(MatchedList.Count, MatchTileCheckNeighbours(previousPositonX, previousPositonY));

        if (MatchedList.Count != 0)
        {
            bCanSwap = true;
        }
        else
        {
            boardGame.SwapTileSync(currentSelectedTile, previousSelectedTile);
            bCanSwap = false;
        }


        Debug.Log("After Swap:");
        Debug.Log("CurrentTile: " + currentSelectedTile.colorTileID + " X: " + currentSelectedTile.PositionX + " Y: " + currentSelectedTile.PositionY);
        Debug.Log("PreviousTile: " + previousSelectedTile.colorTileID + " X: " + previousSelectedTile.PositionX + " Y: " + previousSelectedTile.PositionY);

        Debug.Log("GameBoard Data:");
        Debug.Log("PreviousTile: " + boardGame.GetTileFormCoord(previousPositonX, previousPositonY).GetComponent <Tile>().colorTileID +
                  " X: " + boardGame.GetTileFormCoord(previousPositonX, previousPositonY).GetComponent <Tile>().PositionX +
                  " Y: " + boardGame.GetTileFormCoord(previousPositonX, previousPositonY).GetComponent <Tile>().PositionY);
        Debug.Log("CurrentTile: " + boardGame.GetTileFormCoord(currentPositonX, currentPositonY).GetComponent <Tile>().colorTileID +
                  " X: " + boardGame.GetTileFormCoord(currentPositonX, currentPositonY).GetComponent <Tile>().PositionX +
                  " Y: " + boardGame.GetTileFormCoord(currentPositonX, currentPositonY).GetComponent <Tile>().PositionY);


        return(bCanSwap);
    }