Exemple #1
0
    public bool Move(Vector3Int origin, Vector3Int movementInt)
    {
        Vector3Int examinePos  = origin + movementInt;
        bool       bloodOnPath = false;

        while (true)
        {
            TileBase tile = tilemap.GetTile(examinePos);
            if (tile == null || (bloodOnPath && TileUtility.IsHole(tile)))
            {
                break;
            }
            if (!TileUtility.IsBlood(tile))
            {
                return(false);
            }
            else
            {
                bloodOnPath = true;
            }
            examinePos += movementInt;
        }

        PushObjectsOnPath(origin, movementInt, examinePos);
        return(true);
    }
Exemple #2
0
    void PushObjectsOnPath(Vector3Int origin, Vector3Int movementInt, Vector3Int destination)
    {
        Vector3Int examinePos      = destination;
        TileBase   destinationTile = tilemap.GetTile(examinePos);

        if (destinationTile != null && TileUtility.IsHole(destinationTile))
        {
            examinePos -= movementInt;
            TileBase lastPushedTile = tilemap.GetTile(examinePos);
            if (lastPushedTile != null && TileUtility.IsBlood(lastPushedTile))
            {
                tilemap.SetTile(examinePos, null);
                tilemap.SetTile(destination, holeWithBlood);

                tileSwapper.removeSwap(destination);
                tileSwapper.addTileSwap(holeTile, Time.time + tileAnimationTime, destination);

                payEvent.Invoke();
                DecrementCounter(destination);
            }
        }

        tileSwapper.removeSwap(examinePos);
        Vector3Int from = examinePos - movementInt;

        while (from != origin)
        {
            tilemap.SetTile(examinePos, tilemap.GetTile(from));
            tileSwapper.moveSwap(from, examinePos);

            examinePos -= movementInt;
            from       -= movementInt;
        }

        tilemap.SetTile(origin + movementInt, null);
    }