예제 #1
0
파일: Game.cs 프로젝트: tuita520/u3dmmorpg
    private void CleanupAllGameData(bool stopNet = true)
    {
        try
        {
            EventDispatcher.Instance.DispatchEvent(new UIEvent_VisibleEyeCanBeStart(false));
            ServerInfoCached = false;
            PlatformHelper.CloseToolBar();
            //正在loading过程中,如果被踢下线,删除掉全局的uiroot
            if (null != LoadingLogic.Instance)
            {
                var loadingRoot = GameObject.Find("LoadingObject");
                if (null != loadingRoot)
                {
                    Destroy(loadingRoot);
                }
            }


            if (null != ObjManager.Instance.MyPlayer)
            {
                Destroy(ObjManager.Instance.MyPlayer.gameObject);
            }


            var bc = Instance.GetComponent <BrightnessController>();
            if (bc)
            {
                bc.OnTouchOrMouseRelease();
            }

            NetManager.Instance.SyncCenter.Clear();
            EventDispatcher.Instance.RemoveAllEventListeners();
            CleanUpManagers();
            NetManager.Instance.StopAllCoroutines();
            ConditionTrigger.Instance.Init();
            TimeManager.Instance.CleanUp();
            PlayerAttr.Instance.CleanUp();
            UIManager.Instance.ClearCacheUI();
            if (stopNet)
            {
                NetManager.Instance.Stop();
            }
        }
        catch (Exception e)
        {
            Logger.Log2Bugly("----CleanupAllGameData throw exception:{0}", e);
            throw;
        }
    }