void SetConfigurationInBuilder(Level level) { //get builder from IBuilder builder = mScene.GetServiceManager().GetService <LocalLevelBuilder_v2>(ApplicationConstants.SERVICE_LOCAL_LEVEL_BUILDER); if (builder == null) { Debug.Log("Builder cannot be null"); return; } Dictionary <string, TilePainter> configMap = new Dictionary <string, TilePainter>(); foreach (ColorToTilePainter ctt in level.GetColorToTileMap()) { configMap.Add(ColorUtility.ToHtmlStringRGB(ctt.GetColor()).ToLower(), ctt.GetTilePainter()); } //set builder new configuration builder.SetColorToTileDataDictionaryConfig(configMap); }
/// <summary> /// This level initializes the local level builder, it gets the world index as parameter /// and configures the correct background and tileset to the system /// </summary> /// <param name="worldIndex"></param> public void Init(int worldIndex) { Debug.unityLogger.Log(TAG, "Init()"); //get current level from data Level currentLevel = mLevels[worldIndex]; //spawn a background for the game GameObject background = Instantiate(currentLevel.GetBackground()); background.transform.position = mScene.transform.position + new Vector3(0, 6.29f); background.transform.parent = mScene.transform; Dictionary <string, TilePainter> configMap = new Dictionary <string, TilePainter>(); foreach (ColorToTilePainter ctt in currentLevel.GetColorToTileMap()) { configMap.Add(ColorUtility.ToHtmlStringRGB(ctt.GetColor()).ToLower(), ctt.GetTilePainter()); } //set builder new configuration SetColorToTileDataDictionaryConfig(configMap); mChunkIndex = 0; //--Instantiate a new grid GameObject grid = Instantiate(m_GridPrefab, mScene.transform.position + new Vector3(-13.51f, 17.9f), Quaternion.identity, mScene.transform); //--Instantiate the different types of tilemaps the builder can draw into mTilemapDefault = Instantiate(m_TilemapPrefab_Default, grid.transform.position, Quaternion.identity, grid.transform) .GetComponent <Tilemap>(); mTilemapSolid = Instantiate(m_TilemapPrefab_Solid, grid.transform.position, Quaternion.identity, grid.transform) .GetComponent <Tilemap>(); mTilemapPlatform = Instantiate(m_TilemapPrefab_Platform, grid.transform.position, Quaternion.identity, grid.transform) .GetComponent <Tilemap>(); }