예제 #1
0
    private bool TrySwap(Tile first, Tile second)
    {
        if (Mathf.Abs(first.fieldPosition.x - second.fieldPosition.x) +
            Mathf.Abs(first.fieldPosition.y - second.fieldPosition.y) != 1 ||
            second.state != TileState.Empty)
        {
            return(false);
        }
        field.SwapTiles(first, second);

        if (!field.CheckWinCondition())
        {
            return(true);
        }

        Debug.Log("Win!");
        areYouWinningSon = true;
        field.StartEndgameFirework();
        return(true);
    }