public static int GetTilemapIndex(int x, int y, Tile.Tilemaps tilemap, Tile[,] tiles) { east = CheckNeighbour(x + 1, y, tilemap, tiles); west = CheckNeighbour(x - 1, y, tilemap, tiles); south = CheckNeighbour(x, y - 1, tilemap, tiles); north = CheckNeighbour(x, y + 1, tilemap, tiles); northEast = CheckNeighbour(x + 1, y + 1, tilemap, tiles); northWest = CheckNeighbour(x - 1, y + 1, tilemap, tiles); southEast = CheckNeighbour(x + 1, y - 1, tilemap, tiles); southWest = CheckNeighbour(x - 1, y - 1, tilemap, tiles); return(indexes[CalculateTileFlags(east, west, north, south, northWest, northEast, southWest, southEast)]); }
public Sprite GetSprite(Tile.Tilemaps tilemap, int tileIndex) { switch (tilemap) { case Tile.Tilemaps.Floor_Metal_Cargo: return(Floor_Metal_Cargo[tileIndex]); case Tile.Tilemaps.Floor_Metal: return(Floor_Metal[tileIndex]); case Tile.Tilemaps.Wall_Metal: return(Wall_Metal[tileIndex]); default: return(SpriteNotFound); } }
private static bool CheckNeighbour(int x, int y, Tile.Tilemaps tilemap, Tile[,] tiles) { if (x < 0 || x >= tiles.GetLength(0)) { return(false); } if (y < 0 || y >= tiles.GetLength(1)) { return(false); } if (tiles[x, y] == null) { return(false); } return(tiles[x, y].Tilemap == tilemap); }
private static Tile PixelToTile(int x, int y, Color32 pixel) { Tile.Tilemaps id = Tile.Tilemaps.Floor_Metal_Cargo; if (pixel.IsEqualTo(Space)) { return(null); } else if (pixel.IsEqualTo(Wall)) { id = Tile.Tilemaps.Wall_Metal; } else if (pixel.IsEqualTo(Floor)) { id = Tile.Tilemaps.Floor_Metal; } else if (pixel.IsEqualTo(FloorZone)) { id = Tile.Tilemaps.Floor_Metal_Cargo; } return(new Tile(id, new Vector2Int(x, y))); }