/// <summary> /// 切换状态,并清空之前的状态 /// </summary> /// <Param name="stateName">状态名</Param> /// <Param name="stateParam">状态参数</Param> public void ChangeState(string stateName, object stateParam = null) { if (string.IsNullOrEmpty(stateName)) { return; } //正在切换 if (_switchState) { JW.Common.Log.LogE("UIStateService.ChangeState : state is switching"); return; } // 状态相同,无须跳转 string oldStateName = _state.Count > 0 ? _state[_state.Count - 1].StateName : string.Empty; if (stateName.Equals(oldStateName, StringComparison.OrdinalIgnoreCase)) { JW.Common.Log.LogD("UIStateService.ChangeState error - already in state {0}", stateName); return; } _switchState = true; // 跳转 _state.Clear(); StateData stateData; stateData.StateName = stateName; stateData.Param = stateParam; _state.Add(stateData); AddStateHistory(stateName); SwitchState(UIStateChangeTypeChange, oldStateName, stateName, stateParam); _switchState = false; }
public override void Uninitialize() { if (_prepareSessions != null) { for (int i = 0; i < _prepareSessions.Count; i++) { NetAssetSession session = _prepareSessions[i]; session.StopSession(); _prepareSessions[i] = session; } _prepareSessions.Clear(); } this.RemoveTimer(); if (_cachedNetAssetInfoSet != null) { //保存记录 int offset = 0; _cachedNetAssetInfoSet.Write(S_Buffer, ref offset); if (!JW.Res.FileUtil.IsFileExist(S_CachedNetAssetInfoSetFileFullPath)) { JW.Res.FileUtil.WriteFile(S_CachedNetAssetInfoSetFileFullPath, S_Buffer, 0, offset); } _cachedNetAssetInfoSet = null; } }
/// <summary> /// 反初始化 /// </summary> public override void Uninitialize() { if (_updateCheckers != null) { for(int i = 0; i < _updateCheckers.Count; i++) { IFSUpdateChecker.Destory(_updateCheckers[i]); } _updateCheckers.Clear(); _updateCheckers = null; } if (_sessionProcessors != null) { for (int i = 0; i < _sessionProcessors.Count; i++) { IFSSessionProcessor.Destory(_sessionProcessors[i]); } _sessionProcessors.Clear(); _sessionProcessors = null; } if (_localCheckers != null) { for (int i = 0; i < _localCheckers.Count; i++) { IFSLocalChecker.Destory(_localCheckers[i]); } _localCheckers.Clear(); _localCheckers = null; } }
public override void Uninitialize() { _currentId = 1; _httpSessions.Clear(); StopAllCoroutines(); this.RemoveTimer(); }
public override void Uninitialize() { _currentID = 1; _updates.Clear(); _timers.Clear(); _frames.Clear(); }
/// <summary> /// 销毁 /// </summary> public void Destroy() { for (int i = 0; i < _allMediator.Count; i++) { _allMediator[i].Destroy(); } _allMediator.Clear(); OnUninitializeModule(); }
/// <summary> /// 反初始化 /// </summary> public void Uninitialize() { StopAllCoroutines(); _assetManager = null; _data.Clear(); _data = null; _resourceRequesting = null; _resourceDiscardRequest = null; _synLoading = false; }
public override void Uninitialize() { for (int i = _modules.Count - 1; i >= 0; --i) { _modules[i].Destroy(); } _modules.Clear(); _modules.Release(); _modules = null; StateService.GetInstance().RemoveCallback(this); this.RemoveTimer(); }
/// <summary> /// 销毁对象,外部不要调用 /// </summary> public void Destroy() { OnUninitialize(); UIStateService.GetInstance().RemoveMediator(this); for (int i = 0; i < _forms.Count; i++) { if (_forms[i] != null) { JW.Common.Log.LogE("UIMediator.Destroy : FormClass {0} of {1} is living", _forms[i].GetType().FullName, GetType().FullName); } } _inState = false; _forms.Clear(); Module = null; }
/// <summary> /// 清理缓存的资源 /// </summary> /// <param name="uiStateHistory">UI状态历史列表(=null标识没有UI状态)</param> public void ClearUIStateCache(JWArrayList <string> uiStateHistory) { if (_loader == null) { return; } _tempList.Clear(); _tempList2.Clear(); if (uiStateHistory != null) { _assetManager.GetCacheUIState(ref _tempList); _loader.GetUIState(ref _tempList); for (int i = uiStateHistory.Count - 1; i >= 0; i--) { string stateName = uiStateHistory[i]; if (string.IsNullOrEmpty(stateName) || _tempList.IndexOf(stateName, StringComparer.OrdinalIgnoreCase) == -1) { continue; } _tempList2.Add(stateName); if (_tempList2.Count == CacheUIStateCount) { break; } } } _assetManager.ClearCache(_tempList2); _loader.ClearTask(_tempList2); if (AlwaysGc) { if (LuaGCHook != null) { LuaGCHook(true); } ResService.GetInstance().UnloadUnusedAssets(); return; } }
//切换状态 private void SwitchState(int changeType, string oldStateName, string newStateName, object stateParam) { // 新状态信息应用 if (string.IsNullOrEmpty(newStateName)) { JW.Common.Log.LogE("UIStateService.ChangeState error stateName"); return; } // 通知Mediator _switchMediatorData.Clear(); for (int i = 0; i < _mediator.Count; i++) { MediatorData mediatorData = _mediator[i]; if (mediatorData.Mediator == null) { continue; } bool oldState = mediatorData.IsBelongsState(oldStateName); bool newState = mediatorData.IsBelongsState(newStateName); if (oldState == newState) { if (newState) { _switchMediatorData.Add(new KeyValuePair <UIMediator, int>(mediatorData.Mediator, 0)); } continue; } if (oldState) { _switchMediatorData.Add(new KeyValuePair <UIMediator, int>(mediatorData.Mediator, 1)); } if (newState) { _switchMediatorData.Add(new KeyValuePair <UIMediator, int>(mediatorData.Mediator, 2)); } } // out for (int i = 0; i < _switchMediatorData.Count; i++) { KeyValuePair <UIMediator, int> data = _switchMediatorData[i]; if (data.Value == 1) { data.Key.ChangeState(changeType, false, oldStateName, newStateName, null); } } if (Hook != null) { Hook(1, changeType, oldStateName, newStateName, stateParam); } //清理资源 if (StateService.IsValidate()) { AssetService.GetInstance().ClearUIStateCache(_stateHistory); } for (int i = 0; i < _switchMediatorData.Count; i++) { KeyValuePair <UIMediator, int> data = _switchMediatorData[i]; if (data.Value == 2) { data.Key.ChangeState(changeType, true, oldStateName, newStateName, stateParam); } } if (Hook != null) { Hook(2, changeType, oldStateName, newStateName, stateParam); } //stay for (int i = 0; i < _switchMediatorData.Count; i++) { KeyValuePair <UIMediator, int> data = _switchMediatorData[i]; if (data.Value == 0) { data.Key.RefreshState(changeType, oldStateName, newStateName, stateParam); } } if (Hook != null) { Hook(0, changeType, oldStateName, newStateName, stateParam); } JW.Common.Log.LogD("<color=yellow>UIStateService</color>--->Switch UI State from {0} to {1}<----", oldStateName, newStateName); }
/// <summary> /// 移除所有工厂 /// </summary> public void RemoveAllFactory() { _data.Clear(); }
private IEnumerator AsynchronousLoad_LoadAssetBundle(JWObjList <string> stringList, JWArrayList <AssetData> assetDataList) { while (true) { stringList.Clear(); assetDataList.Clear(); for (int i = 0; i < _data.Count;) { AssetData data = _data[i]; if (data.Priority != _loadAssetBundlePriority) { ++i; continue; } _data.RemoveAt(i); if (_assetManager.GetCacheCount(data.Name) >= data.Count) { if (data.Callback != null) { assetDataList.Add(data); } continue; } LoadData loadData; loadData.Data = data; loadData.LoadBundleState = LoadStateLoading; loadData.Request = null; bool insert = false; for (int j = _resourceRequesting.Count - 1; j >= 0; --j) { if (_resourceRequesting[j].Data.Priority <= data.Priority) { _resourceRequesting.Insert(j + 1, loadData); insert = true; break; } } if (!insert) { _resourceRequesting.Insert(0, loadData); } stringList.Add(data.Filename); if (_loadAssetBundlePriority >= LoadPriority.Preprocess) { break; } } yield return(null); if (stringList.Count > 0) { #if USE_PACK_RES BundleMediator.GetInstance().LoadBundle(stringList, OnBundleLoadCompleted); #else OnBundleLoadCompleted(stringList, true); #endif } yield return(null); for (int i = 0; i < assetDataList.Count; i++) { AssetData data = assetDataList[i]; if (data.Callback != null) { data.Callback.OnLoadAssetCompleted(data.Name, AssetLoadResult.Success, null); yield return(null); } } yield return(InstructionEnd); } }
public override void Uninitialize() { _eventHandler.Clear(); }