/// <summary> /// Start this instance. /// </summary> protected override void Start() { Instance = this; base.Start(); init(); StartCoroutine(RecodeGameDuration()); RecodeSessionNumber(); }
/// <summary> /// Init this instance. /// </summary> protected virtual void Init() { if (m_ModaleView == null) { m_ModaleView = GetComponent <AppModalView>(); } m_MainController = CocoMainController.Instance; // ShowPopup (); }
protected virtual void OnBackButtonClick() { CocoMainController.EnterScene(BackSceneID); }
/// <summary> /// Inits the scene. /// </summary> virtual protected void initScene() { //初始化场景信息。 m_MainController = CocoMainController.Instance; }
protected override void OnClick() { StopPingpong(); CocoMainController.EnterScene(CocoSceneID.Map); }
/// <summary> /// Loads the scene. /// </summary> /// <returns>The scene.</returns> private IEnumerator LoadScene() { //重置状态 DontDestroyOnLoad(gameObject); CocoMainController.Instance.TouchEnable = false; CocoMainController.Canvas_UI = null; CocoMainController.UICamera = null; CocoGlobalData.EnterSceneID = m_EnterSceneID; SceneLoadingStartSignal.Dispatch(m_EnterSceneID); var waitFrame = new WaitForEndOfFrame(); // show transition in if (m_Transition != null) { yield return(m_Transition.TransitionInAsync()); } //卸载场景 yield return(waitFrame); yield return(StartModule.ClearCurrSceneAsync()); yield return(waitFrame); //加载空场景 StartModule.UnloadCurrScene(); if (unloadAssetsAfterLoadEmptyScene) { yield return(waitFrame); Resources.UnloadUnusedAssets(); System.GC.Collect(); yield return(waitFrame); } Time.timeScale = 1; yield return(new WaitForSeconds(0.5f)); //加载新场景 GlobalData.CurSceneID = m_EnterSceneID; StartModule.LoadScene(m_EnterSceneID); yield return(waitFrame); m_SceneInitFinished = !StartModule.GetSceneWaitInit(m_EnterSceneID); //等待场景初始化 while (!m_SceneInitFinished) { yield return(waitFrame); } //加载Interstitial // bool canShowIntertial = false; // bool haveShowIntertial = false; // // LocationShowSignal.AddListener (OnLocationShow); // if (GlobalData.CanShowInterstitialBetweenScene (GlobalData.FrontSceneID, m_EnterSceneID)) { // yield return CocoMainController.AdsControl.showInterstitial ((a, b) => { // canShowIntertial = a; // haveShowIntertial = b; // }); // } // // // show transition out // if (!(canShowIntertial && haveShowIntertial)) { // if (transform.childCount > 0) { // transform.GetChild (0).localScale = Vector3.one; // } // // if (m_Transition != null) { // yield return m_Transition.TransitionOutAsync (); // } // } // LocationShowSignal.RemoveListener (OnLocationShow); var isInterstitialDone = true; var isInterstitialShown = false; if (GlobalData.CanShowInterstitialBetweenScene(GlobalData.FrontSceneID, m_EnterSceneID)) { isInterstitialDone = false; StartCoroutine(CocoMainController.AdsControl.ShowInterstitial( () => isInterstitialShown = true, () => isInterstitialDone = true)); // wait for interstitial show while (!isInterstitialShown && !isInterstitialDone) { yield return(waitFrame); } } // show transition out if (m_Transition != null) { if (isInterstitialShown) { yield return(new WaitForSeconds(0.5f)); } yield return(m_Transition.TransitionOutAsync()); // hide transition if (transform.childCount > 0) { transform.GetChild(0).localScale = Vector3.zero; } } // wait for interstitial done while (!isInterstitialDone) { yield return(waitFrame); } // clean CocoMainController.Instance.TouchEnable = true; SceneLoadingFinishSignal.Dispatch(); CocoMainController.sceneSwitchControl = null; CocoMainController.CleanResources(); Destroy(gameObject); }