public virtual int GetBaseLevel() { var stairVec = HushPuppy.GetVecAsTileVec(this.transform.position); var stairBaseVec = stairVec + Vector3Int.down; return(GetLevel(stairBaseVec)); }
Vector3Int GetCurrentPosInt() { return(HushPuppy.GetVecAsTileVec(new Vector3( this.transform.position.x - 0.5f, this.transform.position.y - 0.5f, this.transform.position.z ))); }
public static Vector3 TilePosInFrontOfObj(GameObject obj, Vector3 direction, bool local = true) { Vector3 target = local ? obj.transform.localPosition : obj.transform.position; target = target + direction * 0.5f; target = HushPuppy.GetVecAsTileVec(target, false, true); return(target); }
public bool IsPositionValid(Vector3 position) { Vector3Int vec = HushPuppy.GetVecAsTileVec(position); TileBase seaTile = seaTilemap.GetTile(vec); bool insideSea = seaTile != null; return(!insideSea); }
void ClearPath() { var walls = TilemapHelper.GetWallsTilemap(); var posInt = HushPuppy.GetVecAsTileVec(this.transform.position); var tile = walls.GetTile(posInt); if (tile != null) { var sprite = ((Tile)tile).sprite; fakeWall.sprite = sprite; walls.SetTile(posInt, null); } }
public static int GetFloor(Vector3 position) { var posInt = HushPuppy.GetVecAsTileVec(position); int maxLevel = -1; foreach (var tilemap in GetAllFloors()) { var targetTile = tilemap.map.GetTile(posInt); if (targetTile != null) { maxLevel = tilemap.level > maxLevel ? tilemap.level : maxLevel; } } return(maxLevel); }
public override int GetTopLevel() { Vector3Int targetTileInt = Vector3Int.zero; int maxLevel = -1; if (destinationRoom != null) { targetTileInt = HushPuppy.GetVecAsTileVec(destinationRoom.startingPos.transform.position); } else if (destinationPos) { targetTileInt = HushPuppy.GetVecAsTileVec(destinationPos.transform.position); } var tilemaps = new List <Tilemap>(FindObjectsOfType <Tilemap>()); foreach (var tilemap in tilemaps) { string tilemapLayerName = LayerMask.LayerToName(tilemap.gameObject.layer); if (!tilemapLayerName.Contains("Floor")) { continue; } int tilemapLevel = int.Parse(tilemapLayerName.Split('_')[1]); tilemapLevel -= 1; //in the layers, we start counting on 1 var targetTile = tilemap.GetTile(targetTileInt); if (targetTile != null) { maxLevel = tilemapLevel > maxLevel ? tilemapLevel : maxLevel; } } return(maxLevel); }