/// <summary> /// Checks if a ledge would be valid if superimposed to a higher tilemap by checking if said higher /// tilemap contains a tile either: /// 1. Above (on the superimposed tile map) the tile that the ledge originated from (on base tilemap) /// 2. Above and adjacent (on superimposed tilemap) the tile that the ledge originated from IN THE /// DIRECTION that the ledge is in. /// </summary> /// <param name="ledge">Ledge being checked for validity.</param> /// <param name="baseTileMap">TileMap that the ledge is on.</param> /// <param name="superTileMap">TileMap that ledge would be superimposed to if valid.</param> /// <returns>True is valid, false otherwise.</returns> private static bool _IsLedgeValid(TileEdge ledge, TileMap baseTileMap, TileMap superTileMap) { Vector2 aboveTile = TileFuncs.GetTileAboveOrBelow(ledge.tileCoords, baseTileMap.ZIndex, superTileMap.ZIndex); Vector2 adjAboveTile = TileFuncs.GetTileAdjacent(aboveTile, ledge.tileSide); return(superTileMap.GetCellv(aboveTile) == TileMap.InvalidCell && superTileMap.GetCellv(adjAboveTile) == TileMap.InvalidCell); }
/// <summary> /// Given some input edge, grabs the tile it originated from and attempts to calculate coordinates /// for some adjacent tile on the observed layer (which should be lower than the current layer). /// </summary> /// <param name="edge">Edge that is checked for what tile it originated from.</param> /// <param name="currentLayer">Layer of edge.</param> /// <param name="observedLayer">Layer of the tile that this func calcs coords for.</param> /// <returns>Coordinates of some adjacent tile on the observed layer, even if it does not exist.</returns> private static Vector2 _GetAdjLowerCoords(TileEdge edge, int currentLayer, int observedLayer) { Vector2 currentTile = edge.tileCoords; int side = edge.tileSide; Vector2 belowTile = TileFuncs.GetTileAboveOrBelow(currentTile, currentLayer, observedLayer); Vector2 adjBelowTile = TileFuncs.GetTileAdjacent(belowTile, side); return(adjBelowTile); }