// Use this for initialization void Start() { // Subscribe to tile change updates WorldEventHandler pmc = new WorldEventHandler(TileUpdated); WorldEventHandlerManager.AddListener(worldEventChannels.map, mapChannelEvents.change, pmc); }
void Start() { // Initialize the Domain and MapData if (domain == null) { domain = new Domain(); } N = mapGenerator.GetN(); domain.mapData = new MapData(N); // Load in the tiles LoadTiles(); //Generate the map mapGenerator.GenerateMap(domain.mapData); // Draw the ground & surface tiles for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { groundTileMap.SetTile(new Vector3Int(i, j, 0), groundTiles[domain.mapData.GetGroundValue(i, j)]); if (domain.mapData.GetSurfaceValue(i, j) >= 0) { surfaceTileMap.SetTile(new Vector3Int(i, j, 0), surfaceTiles[domain.mapData.GetSurfaceValue(i, j)]); } } } // Draw the underground tiles for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { undergroundTileMap.SetTile(new Vector3Int(i, j, 0), undergroundTiles[domain.mapData.GetUndergroundValue(i, j)][domain.mapData.GetStoneValue(i, j)]); } } undergroundTileMap.GetComponent <Renderer>().enabled = false; WorldEventHandler pmc = new WorldEventHandler(ProcessMapChange); WorldEventHandlerManager.AddListener(worldEventChannels.map, mapChannelEvents.change, pmc); }