Example #1
0
    public void Reset(DungeonAxis playerInitial, List<List<TileBase>> terrain)
    {
        var horizontals = GetComponentsInChildren<HorizontalTiles>();
        foreach (var horizontal in horizontals) horizontal.ResetTiles(null, 0);

        int leftX = playerInitial.x - parent.VisibleWidth / 2;
        int topY = playerInitial.y - parent.VisibleHeight / 2;
        horizontals.SafeSkip(leftX)
            .ZipForEach(terrain.SafeSkip(topY), (horizontalTile, horizontalTerrain) =>
                horizontalTile.ResetTiles(horizontalTerrain.SafeSkip(leftX), Mathf.Max(0, -leftX)));
    }
Example #2
0
    void HandleGraphicOnMoveFinished(DungeonAxis delta, DungeonAxis previous, List<List<TileBase>> terrain)
    {
        var horizontals = GetComponentsInChildren<HorizontalTiles>();

        if (delta.x != 0)
        {
            int newTileX = previous.x + delta.x + parent.VisibleWidth / 2 * delta.x;
            horizontals.SafeSkip(parent.VisibleHeight / 2 - previous.y)
                .ZipForEach(terrain.SafeSkip(previous.y - parent.VisibleHeight / 2), (horizontalTiles, horizontalTerrain) =>
                    horizontalTiles.MoveEdgeTile(delta.x > 0, horizontalTerrain.SafeIndexer(newTileX)));
        }

        if (delta.y != 0)
        {
            int leftOffset = Mathf.Max(0, parent.VisibleWidth / 2 - (previous.x + delta.x));
            horizontals.TurnEdgeSibling(delta.y > 0)
                .ResetTiles(terrain.SafeIndexer(previous.y + delta.y + parent.VisibleHeight / 2 * delta.y).SafeSkip(previous.x + delta.x - parent.VisibleWidth / 2),
                    leftOffset);
        }

        GetComponent<RectTransform>().anchoredPosition += (Vector2.down * delta.y + Vector2.right * delta.x) * parent.TileUnitSize;
    }