Ejemplo n.º 1
0
        public void Dispose()
        {
            if (_isDisposed)
            {
                return;
            }
            _isDisposed = true;
            _clientSessionStateMachine.Dispose();
            FreePrefabLoader.Destroy();
            var _sessionObjects = _contexts.session.commonSession;

            _contexts.session.commonSession.Dispose();
            _contexts.session.clientSessionObjects.Dispose();

            if (_contexts.session.clientSessionObjects.NetworkChannel != null)
            {
                _contexts.session.clientSessionObjects.NetworkChannel.Dispose();
            }

            foreach (var info in _sessionObjects.GameContexts.AllContexts)
            {
                foreach (IGameEntity entity in info.GetEntities())
                {
                    foreach (var comp in entity.ComponentList)
                    {
                        if (comp is IAssetComponent)
                        {
                            ((IAssetComponent)comp).Recycle(_sessionObjects.AssetManager);
                        }
                    }

                    if (_sessionObjects.AssetManager != null)
                    {
                        _sessionObjects.AssetManager.LoadCancel(entity.RealEntity);
                    }
                    entity.Destroy();
                }
            }

            foreach (Entity entity in _contexts.ui.GetEntities())
            {
                DestroyEntity(_sessionObjects, entity);
            }


            foreach (Entity entity in _contexts.sceneObject.GetEntities())
            {
                DestroyEntity(_sessionObjects, entity);
            }

            _clientSessionStateMachine.ShutDown();
            try
            {
                _contexts.Reset();
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat("contexts.Reset error:{0}", ex.Message);
            }

            UiModule.DestroyAll();
            FreeUILoader.Destroy();
        }
Ejemplo n.º 2
0
        public void Dispose()
        {
            if (_isDisposed)
            {
                return;
            }
            _isDisposed = true;
            try
            {
                _clientSessionStateMachine.Dispose();
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat("_clientSessionStateMachine.Disposeerror:{0}", ex);
            }

            try
            {
                FreePrefabLoader.Destroy();
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat("FreePrefabLoader.Destroy(){0}", ex);
            }

            try
            {
                _contexts.session.commonSession.Dispose();
                _contexts.session.clientSessionObjects.Dispose();
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat(" _contexts.session {0}", ex);
            }

            var _sessionObjects = _contexts.session.commonSession;

            try
            {
                if (_contexts.session.clientSessionObjects.NetworkChannel != null)
                {
                    _contexts.session.clientSessionObjects.NetworkChannel.Dispose();
                }
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat(" _contexts.NetworkChannel {0}", ex);
            }


            RecycleEntitys(_contexts);

            try
            {
                _clientSessionStateMachine.ShutDown();
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat(" _clientSessionStateMachine.ShutDown {0}", ex);
            }

            try
            {
                _contexts.Reset();
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat("contexts.Reset error:{0}", ex.Message);
            }

            try
            {
                UiModule.DestroyAll();
                FreeUILoader.Destroy();
            }
            catch (Exception ex)
            {
                _logger.ErrorFormat("contexts.Reset error:{0}", ex.Message);
            }
        }