private bool TileValue(ITilemap tileMap, Vector3Int position) { TileBase tile = tileMap.GetTile(position); TerrainTile terrainTile = tileMap.GetTile <TerrainTile>(position); if (terrainTile != null) { if (m_layerIndex != terrainTile.m_layerIndex) { tile = null; } } return(tile != null && tile == this); }
public override void GetTileData(Vector3Int position, ITilemap tilemap, ref TileData tileData) { base.GetTileData(position, tilemap, ref tileData); if (wallTile != null && specialTile != null) { if (tilemap.GetTile(position + new Vector3Int(-1, 0, 0)) == this && tilemap.GetTile(position + new Vector3Int(1, 0, 0)) == this && tilemap.GetTile(position + new Vector3Int(0, 1, 0)) == this && tilemap.GetTile(position + new Vector3Int(0, -1, 0)) == this) { tileData.sprite = specialTile; } else { tileData.sprite = wallTile; } } }
public override void RefreshTile(Vector3Int location, ITilemap tileMap) { for (int yd = -1; yd <= 1; yd++) { for (int xd = -1; xd <= 1; xd++) { var position = new Vector3Int(location.x + xd, location.y + yd, location.z); var tile = tileMap.GetTile(position); if (tile == this) { tileMap.RefreshTile(position); } } } }
public bool RuleMatches(TilingRule rule, Vector3Int position, ITilemap tilemap, int angle) { for (int y = -1; y <= 1; y++) { for (int x = -1; x <= 1; x++) { if (x != 0 || y != 0) { Vector3Int offset = new Vector3Int(x, y, 0); Vector3Int rotated = GetRotatedPos(offset, angle); int index = GetIndexOfOffset(rotated); TileBase tile = tilemap.GetTile(position + offset); if (rule.m_Neighbors[index] == TilingRule.Neighbor.This && tile != this || rule.m_Neighbors[index] == TilingRule.Neighbor.NotThis && tile == this) { return(false); } } } } return(true); }
public bool RuleMatches(TilingRule rule, Vector3Int position, ITilemap tilemap, bool mirrorX, bool mirrorY) { for (int y = -1; y <= 1; y++) { for (int x = -1; x <= 1; x++) { if (x != 0 || y != 0) { Vector3Int offset = new Vector3Int(x, y, 0); Vector3Int mirrored = GetMirroredPos(offset, mirrorX, mirrorY); int index = GetIndexOfOffset(mirrored); TileBase tile = tilemap.GetTile(position + offset); if (rule.m_Neighbors[index] == TilingRule.Neighbor.This && tile != this || rule.m_Neighbors[index] == TilingRule.Neighbor.NotThis && tile == this) { return false; } } } } return true; }
private bool TileValue(ITilemap tileMap, Vector3Int position) { TileBase tile = tileMap.GetTile(position); return(tile != null && tile == this); }
private bool TileValue(ITilemap tileMap, Vector3Int position) { TileBase tile = tileMap.GetTile(position); return(tile != null && ((friendlyTiles != null && friendlyTiles.Contains(tile)) || tile == this)); }
public void ConfigureTile(Vector3Int location, ITilemap tileMap, ref TileData tileData) { var left = tileMap.GetTile(location + Vector3Int.left) == this; var right = tileMap.GetTile(location + Vector3Int.right) == this; var top = tileMap.GetTile(location + Vector3Int.up) == this; var bottom = tileMap.GetTile(location + Vector3Int.down) == this; if (left && top && right && bottom) { tileData.sprite = LTRB; } else if (left && top && right) { tileData.sprite = LTR; } else if (left && top && bottom) { tileData.sprite = LTB; } else if (top && right && bottom) { tileData.sprite = TRB; } else if (left && right && bottom) { tileData.sprite = LRB; } else if (left && right) { tileData.sprite = LR; } else if (top && bottom) { tileData.sprite = TB; } else if (left && top) { tileData.sprite = LT; } else if (left && bottom) { tileData.sprite = LB; } else if (top && right) { tileData.sprite = TR; } else if (right && bottom) { tileData.sprite = RB; } else if (left) { tileData.sprite = L; } else if (right) { tileData.sprite = R; } else if (top) { tileData.sprite = T; } else if (bottom) { tileData.sprite = B; } else { tileData.sprite = alone; } }