/// <summary> /// Loads the level and all related GameObjects like <c>LevelElement</c>s using the <c>ILevelLoader</c> /// </summary> public void LoadLevel() { if (MainMenuPlayerPreferences.InLevelCreationMode) { dataProvider = DeserializeLevel(); levelLoader = new BasicLevelLoader(dataProvider); } // Execute the following in try catch blocks, because levelLoader could be null. try { levelDataCollection = new LevelDataCollection(); level = levelLoader.LoadLevel(); levelDataCollection.levelElements = levelLoader.LoadLevelElements(transform); levelDataCollection.levelItemsData = levelLoader.LoadItemsData(); levelDataCollection.levelItems = levelLoader.LoadItems(transform, levelDataCollection.levelItemsData); if (MainMenuPlayerPreferences.InLevelCreationMode) { levelDataCollection.enemyData = dataProvider.GetEnemyData(); levelDataCollection.enemies = LoadEnemies(levelDataCollection.enemyData); JsonDataProvider jsonDataProvider = (JsonDataProvider)dataProvider; levelDataCollection.playerData = jsonDataProvider.GetPlayerData(); } } catch (NullReferenceException ex) { Debug.LogError("Cannot load level. No ILevelLoader assigned!"); throw new NullReferenceException("Cannot load level. No ILevelLoader assigned!", ex); } }
public void OnLoadSceneButtonClicked() => levelManager.LoadLevel();
protected override void Start() { base.Start(); m_levelLoader.LoadLevel(m_defaultName); }
public UAsyncOperation Load(ILevelLoader _loader, string _levelName, ELoadLevelMode _mode = ELoadLevelMode.SingleMainLevel, Action _finish = null) { return(_loader?.LoadLevel(_levelName, _mode, _finish)); }