예제 #1
0
    void UpdateSwapResults(TileSwapType swapType, TileController firstTile = null, TileController secondTile = null)
    {
        swapResults.SwapType = swapType;
        List <TileController> tiles = swapResults.TilesInvolved;

        tiles.Clear();

        if (firstTile == null)
        {
            tiles.Add(firstTileClicked);
        }
        else
        {
            tiles.Add(firstTile);
        }

        if (secondTile == null)
        {
            tiles.Add(secondTileClicked);
        }
        else
        {
            tiles.Add(secondTile);
        }
    }
예제 #2
0
    void AlertSwapListeners(TileSwapType swapType)
    {
        // Whether it's Fungus blocks or custom code.
        AnyPhysicalSwapMade.Invoke(this, swapResults);

        if (swapType != TileSwapType.freeAdjacent &&
            swapType != TileSwapType.gravityControl) // Don't let the Fungus system count this as a swap
        {
            SwapMadeEvent.Invoke(swapResults);
        }
    }
예제 #3
0
    protected virtual void ConsiderSwappingTiles()
    {
        TileSwapType swapType = CanSwapTiles(firstTileClicked, secondTileClicked);

        if (swapType != TileSwapType.none) // We have a valid swap attempt here!
        {
            SwapEnabled = false;           // Will be reenabled once the swap is done
            SwapTask(firstTileClicked, secondTileClicked, swapType);
            //StartCoroutine(SwapCoroutine(firstTileClicked, secondTileClicked, swapType));
        }
        else
        {
            UnregisterTiles();
        }
    }
예제 #4
0
    protected virtual async SysTask SwapTask(TileController firstTile, TileController secondTile, TileSwapType swapType)
    {
        switch (swapType)
        {
        case TileSwapType.adjacent:
            await AdjacentSwapTask(firstTile, secondTile);

            break;

        case TileSwapType.freeAdjacent:
            await AdjacentSwapTask(firstTile, secondTile);

            break;

        case TileSwapType.gravityControl:
            await AdjacentSwapTask(firstTile, secondTile);

            break;

        case TileSwapType.knight:
            await KnightSwapTask(firstTile, secondTile);

            break;

        default:
            Debug.LogError("TileSwapType " + swapType + " not accounted for!");
            break;
        }

        UpdateSwapResults(swapType);
        UnregisterTiles();
        AlertSwapListeners(swapType);
        SwapEnabled = true;
    }