public void CreateCell(List <List <EnvironmentTile> > map, bool isDungeon) { mAll.Clear(); mToBeTested.Clear(); int halfWidth = map.Count / 2; int halfHeight = map[0].Count / 2; Vector3 position = new Vector3(-(halfWidth * TileSize), 0.0f, -(halfHeight * TileSize)); for (int x = 0; x < map.Count; x++) { for (int y = 0; y < map[x].Count; y++) { List <EnvironmentTile> tiles; if (!isDungeon) { if (map[x][y].IsAccessible && !map[x][y].IsEntrance) { tiles = AccessibleTilesWorld; } else if (map[x][y].IsStructure && !map[x][y].IsEntrance) { tiles = AccessibleTilesWorld; } else { tiles = InaccessibleTilesWorld; } } else { if (map[x][y].IsAccessible && !map[x][y].IsEntrance) { tiles = AccessibleTilesDungeon; } else if (map[x][y].IsAccessible && map[x][y].IsEntrance) { tiles = Structures; } else { tiles = InaccessibleTilesDungeon; } } EnvironmentTile prefab = tiles[Random.Range(0, tiles.Count)]; if (map[x][y].IsStructure && map[x][y].IsEntrance) { if (isDungeon) { prefab = Structures[1]; } else { prefab = Structures[0]; } } if (map[x][y].IsChest) { prefab = chest; } EnvironmentTile tile = Instantiate(prefab, position, Quaternion.identity, transform); tile.gameObject.name = string.Format("Tile({0},{1})", x, y); tile.Connections = map[x][y].Connections; tile.GridPos = map[x][y].GridPos; tile.Position = map[x][y].Position; tile.IsAccessible = map[x][y].IsAccessible; tile.IsStructure = map[x][y].IsStructure; if (!isDungeon) { if (tile.IsStructure) { tile.StructureOriginIndex = map[x][y].StructureOriginIndex; } } tile.IsEntrance = map[x][y].IsEntrance; if (tile.IsEntrance) { tile.IsAccessible = true; } if (map[x][y].GetTargetID() != 0) { tile.SetTargetID(map[x][y].GetTargetID()); } tile.TileNumb = map[x][y].TileNumb; tile.IsChest = map[x][y].IsChest; position.z += TileSize; mAll.Add(tile); map[x][y] = tile; } position.x += TileSize; position.z = -(halfHeight * TileSize); } mmap = map; SetupConnections(); if (isDungeon) { roomTiles.Clear(); ConnectRooms(); SetupConnections(); Start = mmap[Start.GridPos.x][Start.GridPos.y]; } else { Start = mmap[0][0]; } }