void generate_map() { set_variables(); map = new int[width, height]; // binary map generation, using cellular automata method random_fill(); smooth(smoothness); pad_edges(); // map post-processing extract_regions(); create_adjacency_lists(); bridge_all_regions(); Debug.Log("done generating map!"); Vector3 offset = new Vector3(width / (2f * cell_size), 0.0f, height / (2f * cell_size)); // create meshes for all objects SurfaceMeshGenerator surface_mesh_gen = transform.Find("Surfaces").GetComponent <SurfaceMeshGenerator>(); surface_mesh_gen.generate_surface_mesh(map, cmds, offset); WallMeshGenerator wall_mesh_gen = transform.Find("Walls").GetComponent <WallMeshGenerator>(); wall_mesh_gen.generate_wall_mesh(cmds, offset); BridgeMeshGenerator bridge_mesh_gen = transform.Find("Bridges").GetComponent <BridgeMeshGenerator>(); bridge_mesh_gen.generate_bridge_mesh(map, offset); Floor floor_gen = transform.Find("Floor").GetComponent <Floor>(); floor_gen.generate_floor(); Water water_gen = transform.Find("Water").GetComponent <Water>(); water_gen.generate_water_mesh(offset); // init tile hover detector with map data TileSelector tile_select = transform.Find("TileSelector").GetComponent <TileSelector>(); tile_select.init_tile_selector(map); }
public int[,] generate_map() { set_variables(); map = new int[width, height]; Debug.Log("Generating map data..."); // binary map generation, using cellular automata method random_fill(); smooth(smoothness); pad_edges(); // pads out map to point where edge is not normally visible to player // map post-processing extract_regions(); create_adjacency_lists(); bridge_all_regions(); Debug.Log("Done generating map! Creating meshes..."); GetComponent <FogOfWar>().Init(); MapMeshGenerator surface_gen = transform.Find("Surface").GetComponent <MapMeshGenerator>(); surface_gen.generate_map_mesh(map); BridgeMeshGenerator bridge_mesh_gen = transform.Find("Bridges").GetComponent <BridgeMeshGenerator>(); bridge_mesh_gen.generateBridgeMesh(map); Boundary boundary_gen = transform.Find("Boundaries").GetComponent <Boundary>(); boundary_gen.generateBoundary(); BoxCollider box = GetComponent <BoxCollider>(); box.center = GetComponent <MapConfiguration>().GetCenter(); box.size = new Vector3(width, 0.5f, height); Debug.Log("Mesh generation complete!"); //print_region_tree(); return(map); }