コード例 #1
0
    /// <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);
        }
    }
コード例 #2
0
 public void OnLoadSceneButtonClicked() => levelManager.LoadLevel();
コード例 #3
0
ファイル: Manager.cs プロジェクト: xkteng/VR2019
 protected override void Start()
 {
     base.Start();
     m_levelLoader.LoadLevel(m_defaultName);
 }
コード例 #4
0
ファイル: ULevelManager.cs プロジェクト: xtiy/unity-gameplay
 public UAsyncOperation Load(ILevelLoader _loader, string _levelName, ELoadLevelMode _mode = ELoadLevelMode.SingleMainLevel, Action _finish = null)
 {
     return(_loader?.LoadLevel(_levelName, _mode, _finish));
 }