/// <summary> /// Pops up. management, stack and Close() shutdown function /// </summary> /// <param name="sceneName">Scene name.</param> /// <param name="data">Data.</param> /// <param name="active">Active.</param> /// <param name="deactive">Deactive.</param> public virtual void PopUp(string sceneName, object data = null, SceneCallbackDelegate active = null, SceneCallbackDelegate deactive = null) { LoadLevelData loadLevel = new LoadLevelData(sceneName, data, active, deactive); loadLevel.type = SceneType.Popup; LoadLevel(loadLevel); }
public void LoadNewScene() { sys.Play(); LoadLevelData a = new LoadLevelData(levelToLoad); transitionState.SetTransition_(loadAndUnloadScene, a); }
/// <summary> /// Screen the specified sceneName, data, active and deactive. /// </summary> /// <param name="sceneName">Scene name.</param> /// <param name="data">Data.</param> /// <param name="active">Active.</param> /// <param name="deactive">Deactive.</param> public virtual void Screen(string sceneName, object data = null, SceneCallbackDelegate active = null, SceneCallbackDelegate deactive = null) { ClearPopUp(delegate() { LoadLevelData loadLevel = new LoadLevelData(sceneName, data, active, deactive); LoadLevel(loadLevel); }); }
public void loadAndUnloadScene(System.Object obj) { LoadLevelData sceneToLoad = (LoadLevelData)obj; //transitionState.currentBoardActive = ; transitionState.boardParent.SetActive(true); transitionState.overworldParent.SetActive(false); GameObject board = transitionState.levelObjects[(int)sceneToLoad.type]; transitionState.currentLevelType = sceneToLoad.type; board.SetActive(true); BoardLogic bor = board.GetComponent <BoardLogic>(); bor.ResetBoard(true, true); //SceneManager.LoadScene(sceneName, LoadSceneMode.Single); //SceneManager.UnloadScene("Scenes/Overworld"); }
/// <summary> /// Loads the menu. /// </summary> /// <param name="sceneName">Scene name.</param> /// <param name="data">Data.</param> /// <param name="active">Active.</param> /// <param name="deactive">Deactive.</param> public virtual void LoadMenu(string sceneName, object data = null, SceneCallbackDelegate active = null, SceneCallbackDelegate deactive = null) { if (menus.ContainsKey(sceneName)) { GameObject root = menus [sceneName]; if (root.activeSelf) { DestroyScene(sceneName); } else { OnActiveScreen(root); return; } } LoadLevelData loadLevel = new LoadLevelData(sceneName, data, active, deactive); loadLevel.type = SceneType.Menu; LoadLevel(loadLevel); }
/// <summary> /// Loads the level. /// </summary> /// <param name="loadLevelData">Load level data.</param> protected virtual void LoadLevel(LoadLevelData loadLevelData) { switch (loadLevelData.type) { case SceneType.POPUP: case SceneType.SCREEN: case SceneType.ADDSCREEN: if (scenes.ContainsKey (loadLevelData.sceneName)) { GameObject root = scenes [loadLevelData.sceneName]; if (!root.activeSelf) { if (loadLevelData.type == SceneType.POPUP) { DistancePopUp (root); popups.Push (loadLevelData.sceneName); } OnActiveScreen (root); if (loadLevelData.type == SceneType.SCREEN || loadLevelData.type == SceneType.ADDSCREEN) { ClearScene (loadLevelData.sceneName); } if (loadLevelData.type == SceneType.ADDSCREEN) { screens.Push (loadLevelData.sceneName); } } SSceneController ctrl = root.GetComponent<SSceneController> (); ctrl.OnReset (loadLevelData.data); return; } break; case SceneType.MENU: if (menus.ContainsKey (loadLevelData.sceneName)) { GameObject root = menus [loadLevelData.sceneName]; if (!root.activeSelf) { OnActiveScreen (root); return; } } break; } bool isAddtive = false; if (loadLevelData.type == SceneType.MENU || loadLevelData.type == SceneType.POPUP) { isAddtive = true; } SSceneApplication.LoadLevel (loadLevelData.sceneName, delegate(GameObject root) { root.transform.parent = scene.transform; root.transform.localPosition = Vector3.zero; SSceneRoot sRoot = root.GetComponent<SSceneRoot> (); foreach (Camera cam in sRoot.Cameras) { AudioListener audio = cam.GetComponent<AudioListener> (); if (audio != null) { audio.enabled = false; } // ngui if (uIType == UIType.NGUI) { if (nGUICamera == null) { if (cam.GetComponent ("UICamera") != null) { cam.clearFlags = CameraClearFlags.Depth; nGUICamera = Instantiate (cam.gameObject) as GameObject; nGUICamera.name = "UICamera"; nGUICamera.transform.parent = gCamera.transform; nGUICamera.transform.localPosition = Vector3.zero; nGUICamera.SetActive (true); cam.gameObject.SetActive (false); } } else { if (loadLevelData.type != SceneType.POPUP && cam.GetComponent ("UICamera") != null) { cam.gameObject.SetActive (false); } } } } SSceneController ctrl = root.GetComponent<SSceneController> (); if (ctrl == null) { HDebug.LogError ("No SceneController."); return; } ctrl.active = loadLevelData.active; ctrl.deactive = loadLevelData.deactive; switch (loadLevelData.type) { case SceneType.SCREEN: case SceneType.ADDSCREEN: ctrl.OnSet (loadLevelData.data); scenes.Add (loadLevelData.sceneName, root); ClearScene (loadLevelData.sceneName); if (screenStartChange != null) { screenStartChange (loadLevelData.sceneName); } if (loadLevelData.type == SceneType.ADDSCREEN) { screens.Push (loadLevelData.sceneName); } break; case SceneType.POPUP: scenes.Add (loadLevelData.sceneName, root); DistancePopUp (root); popups.Push (loadLevelData.sceneName); ctrl.OnSet (loadLevelData.data); if (popUpStart != null) { popUpStart (loadLevelData.sceneName); } break; case SceneType.MENU: ctrl.OnSet (loadLevelData.data); menus.Add (loadLevelData.sceneName, root); if (menuStart != null) { menuStart (loadLevelData.sceneName); } break; } // ngui if (nGUICamera != null) { MonoBehaviour uicam = nGUICamera.GetComponent<MonoBehaviour> (); uicam.enabled = false; uicam.enabled = true; } }, isAddtive); }
/// <summary> /// Screen the specified sceneName, data, active and deactive. /// </summary> /// <param name="sceneName">Scene name.</param> /// <param name="data">Data.</param> /// <param name="active">Active.</param> /// <param name="deactive">Deactive.</param> public virtual void Screen(string sceneName, object data = null, SceneCallbackDelegate active = null, SceneCallbackDelegate deactive = null) { ClearPopUp (delegate() { LoadLevelData loadLevel = new LoadLevelData (sceneName, data, active, deactive); LoadLevel (loadLevel); }); }
/// <summary> /// Pops up. management, stack and Close() shutdown function /// </summary> /// <param name="sceneName">Scene name.</param> /// <param name="data">Data.</param> /// <param name="active">Active.</param> /// <param name="deactive">Deactive.</param> public virtual void PopUp(string sceneName, object data = null, SceneCallbackDelegate active = null, SceneCallbackDelegate deactive = null) { LoadLevelData loadLevel = new LoadLevelData (sceneName, data, active, deactive); loadLevel.type = SceneType.POPUP; LoadLevel (loadLevel); }
/// <summary> /// Loads the menu. /// </summary> /// <param name="sceneName">Scene name.</param> /// <param name="data">Data.</param> /// <param name="active">Active.</param> /// <param name="deactive">Deactive.</param> public virtual void LoadMenu(string sceneName, object data = null, SceneCallbackDelegate active = null, SceneCallbackDelegate deactive = null) { if (menus.ContainsKey (sceneName)) { GameObject root = menus [sceneName]; if (root.activeSelf) { DestroyScene (sceneName); } else { OnActiveScreen (root); return; } } LoadLevelData loadLevel = new LoadLevelData (sceneName, data, active, deactive); loadLevel.type = SceneType.MENU; LoadLevel (loadLevel); }
void Awake() { loadLevelDataScript = GetComponent<LoadLevelData>(); //beginningText.text = loadLevelDataScript.GetBeginningText(level); //endingText.text = loadLevelDataScript.GetEndingText(level); }
/// <summary> /// Loads the level. /// </summary> /// <param name="loadLevelData">Load level data.</param> protected virtual void LoadLevel(LoadLevelData loadLevelData) { switch (loadLevelData.type) { case SceneType.Popup: case SceneType.Screen: case SceneType.AddScreen: if (scenes.ContainsKey(loadLevelData.sceneName)) { GameObject root = scenes [loadLevelData.sceneName]; if (!root.activeSelf) { if (loadLevelData.type == SceneType.Popup) { DistancePopUp(root); popups.Push(loadLevelData.sceneName); } if (loadLevelData.type != SceneType.Popup) { ClearScene(loadLevelData.sceneName); } if (loadLevelData.type == SceneType.AddScreen) { screens.Push(loadLevelData.sceneName); } } OnActiveScreen(root); SSceneController ctrl = root.GetComponent <SSceneController> (); ctrl.OnReset(loadLevelData.data); return; } // ugui if (uIType == UIType.UGUI) { if (loadLevelData.type != SceneType.Popup) { ClearEventSystem(loadLevelData.sceneName); } } break; case SceneType.Menu: if (menus.ContainsKey(loadLevelData.sceneName)) { GameObject root = menus [loadLevelData.sceneName]; OnActiveScreen(root); return; } break; } bool isAddtive = false; if (loadLevelData.type == SceneType.Menu || loadLevelData.type == SceneType.Popup) { isAddtive = true; } SSceneApplication.LoadLevel(loadLevelData.sceneName, delegate(GameObject root) { root.transform.parent = scene.transform; root.transform.localPosition = Vector3.zero; SSceneRoot sRoot = root.GetComponent <SSceneRoot> (); foreach (Camera cam in sRoot.Cameras) { AudioListener audio = cam.GetComponent <AudioListener> (); if (audio != null) { audio.enabled = false; } // ngui if (uIType == UIType.NGUI) { if (nGUICamera == null) { if (cam.GetComponent("UICamera") != null) { cam.clearFlags = CameraClearFlags.Depth; nGUICamera = Instantiate(cam.gameObject) as GameObject; nGUICamera.name = "UICamera"; nGUICamera.transform.parent = gCamera.transform; nGUICamera.transform.localPosition = Vector3.zero; nGUICamera.SetActive(true); cam.gameObject.SetActive(false); } } else { if (loadLevelData.type != SceneType.Popup && cam.GetComponent("UICamera") != null) { cam.gameObject.SetActive(false); } } } } if (sRoot.EventSystem != null) { eventSystem = sRoot.EventSystem.gameObject; } SSceneController ctrl = root.GetComponent <SSceneController> (); if (ctrl == null) { HDebug.LogError("No SceneController."); return; } ctrl.active = loadLevelData.active; ctrl.deactive = loadLevelData.deactive; switch (loadLevelData.type) { case SceneType.Screen: case SceneType.AddScreen: ctrl.OnSet(loadLevelData.data); scenes.Add(loadLevelData.sceneName, root); ClearScene(loadLevelData.sceneName); if (screenStartChange != null) { screenStartChange(loadLevelData.sceneName); } if (loadLevelData.type == SceneType.AddScreen) { screens.Push(loadLevelData.sceneName); } break; case SceneType.Popup: scenes.Add(loadLevelData.sceneName, root); DistancePopUp(root); popups.Push(loadLevelData.sceneName); ctrl.OnSet(loadLevelData.data); if (popUpStart != null) { popUpStart(loadLevelData.sceneName); } break; case SceneType.Menu: ctrl.OnSet(loadLevelData.data); menus.Add(loadLevelData.sceneName, root); if (menuStart != null) { menuStart(loadLevelData.sceneName); } break; } if (uIType == UIType.NGUI) // ngui { if (nGUICamera != null) { MonoBehaviour uicam = nGUICamera.GetComponent <MonoBehaviour> (); uicam.enabled = false; uicam.enabled = true; } } }, isAddtive); }