// load level if player is coming back from a test session // register for events private void Start() { ExampleGame_LoadSave.Init(); if (PLAYER != null) { PLAYER.enabled = false; } // show a loading message uMyGUI_PopupManager.Instance.ShowPopup(uMyGUI_PopupManager.POPUP_LOADING); // try load dungeon level from file if (ExampleGame_LoadSave.IsLevelFileFound(LEVEL_FILE_NAME)) { // load level from file StartCoroutine(ExampleGame_LoadSave.LoadRoutineByFileName(LEVEL_FILE_NAME, (byte[][] p_levelData) => { LE_LevelEditorMain.Instance.ExecuteWhenReady(() => StartCoroutine(LateLoad(LE_LevelEditorMain.Instance.GetLoadEvent(), p_levelData))); })); } else { // load default dungeon level if no file is saved string[] dataAsStringArray = ExampleGame_DungeonGame_Level.LEVEL.Split('#'); byte[][] loadedByteArrays = new byte[][] { System.Convert.FromBase64String(dataAsStringArray[0]), System.Convert.FromBase64String(dataAsStringArray[1]) }; LE_LevelEditorMain.Instance.ExecuteWhenReady(() => StartCoroutine(LateLoad(LE_LevelEditorMain.Instance.GetLoadEvent(), loadedByteArrays))); } // set up the event handling (link the buttons in the editor to functions in this script) LE_EventInterface.OnSave += OnSave; LE_EventInterface.OnLoad += OnLoad; }
// load level if player is coming back from a test session // register for events private void Start() { ExampleGame_LoadSave.Init(); // when the game was started from the editor and the user is coming back to the editor from his game session // he probably will want the level that he has played to be loaded into the editor if (m_isComingBackFromGame) { // reload level LE_ExtensionInterface.Load.Delegate(this, (byte[][] p_levelData) => { if (LE_LevelEditorMain.Instance.IsReady) { StartCoroutine(LateLoad(LE_LevelEditorMain.Instance.GetLoadEvent(), p_levelData)); } else { LE_LevelEditorMain.Instance.ExecuteWhenReady(() => StartCoroutine(LateLoad(LE_LevelEditorMain.Instance.GetLoadEvent(), p_levelData))); } }, true); } m_isComingBackFromGame = false; // set up the event handling (link the buttons in the editor to functions in this script) LE_EventInterface.OnSave += OnSave; LE_EventInterface.OnLoad += OnLoad; }
private void Start() { ExampleGame_LoadSave.Init(); // load level LE_ExtensionInterface.Load.Delegate(this, (byte[][] p_levelData) => { if (p_levelData != null && p_levelData.Length > 0 && p_levelData[0] != null) { // load level data (we do not need p_levelData[1], since it contains only meta data for example the level icon) // however, you might want to load it as well when you add other information to it for example the level time LE_SaveLoadData level = LE_SaveLoad.LoadLevelDataFromByteArray( p_levelData[0], TERRAIN_LAYER, TERRAIN_TEXTURE_CONFIG.TERRAIN_TEXTURES, TERRAIN_TEXTURE_CONFIG.TERRAIN_TEXTURE_SIZES, TERRAIN_TEXTURE_CONFIG.TERRAIN_TEXTURE_OFFSETS); // call this function to destroy level editing scripts and improve performance LE_SaveLoad.DisableLevelEditing(level); } else { Debug.LogError("ExampleGame_Game: No saved level found!"); } // hide loading popup shown after calling LE_ExtensionInterface.Load uMyGUI_PopupManager.Instance.HidePopup(uMyGUI_PopupManager.POPUP_LOADING); // find player start position /* GameObject goPlayerStart = GameObject.Find("Objects/PlayerStartPosition"); * if (goPlayerStart != null) * { * PLAYER.transform.position = goPlayerStart.transform.position + goPlayerStart.transform.up; * Destroy(goPlayerStart); // not needed any more * } * else * { * Debug.LogError("ExampleGame_Game: could not find a PlayerStartPosition GameObject!"); * } */ }, true); }