private void GenerateMap_Normal() { m_mapHolder = new GameObject("MapHolder"); m_tiles = new Dictionary <Vector3Int, Tile>(); var seed = UnityEngine.Random.Range(0, 99999); var map = MapFunctions.GenerateCellularAutomata(m_width, m_length, seed, m_fillPercent, m_edgesAreWalls); map = MapFunctions.SmoothMooreCellularAutomata(map, m_edgesAreWalls, m_smoothCount); if (m_randomWalkTopEnabled == true) { map = MapFunctions.RandomWalkTop(map, seed); if (m_randomWalkTopSmoothedEnabled == true) { map = MapFunctions.RandomWalkTopSmoothed(map, seed, m_minSectionWidth); } } for (int i = 0; i < m_numberOfRivers; i++) { if (m_directionTunnelEnabled == true) { var rand = UnityEngine.Random.Range(0, 2) * 2 - 1; map = MapFunctions.DirectionalTunnel(map, m_minPathWidth, m_maxPathWidth, m_maxPathChange * rand, m_roughness, m_windyness, UnityEngine.Random.Range(m_width / 4, m_width - (m_width / 4) - 1)); } } var cellSize = m_tileMap.m_tileObjects[0].GetComponentInChildren <Renderer>().bounds.size; for (int x = 0; x < map.GetUpperBound(0); x++) { for (int y = 0; y < map.GetUpperBound(1); y++) { if (map[x, y] != 0) { var location = new Vector3Int(x, y, 0); m_tiles.Add(location, new Tile(null, Matrix4x4.identity)); } } } for (int x = 0; x < map.GetUpperBound(0); x++) { for (int y = 0; y < map.GetUpperBound(1); y++) { if (map[x, y] != 0) { var location = new Vector3Int(x, y, 0); int xDir = (int)(x * cellSize.x); int zDir = (int)(y * cellSize.z); if (m_flipXAxis == true) { xDir *= -1; } if (m_flipZAxis == true) { zDir *= -1; } var position = new Vector3Int(xDir, 0, zDir); ThreeDTileData threeDTileData = new ThreeDTileData(); m_tileMap.GetTileData(location, this, ref threeDTileData); var go = Instantiate(threeDTileData.gameObject, position, threeDTileData.transform.rotation, m_mapHolder.transform); m_tiles[location].gameObject = go; m_tiles[location].transform = threeDTileData.transform; } } } }