private void RefreshList() { bool flag = true; int currentVersion = OperateActivityManager.Instance.CurrentVersion; using (List <UpdateAcInfo> .Enumerator enumerator = OperateActivityManager.Instance.LocalUpdateGiftInfos.GetEnumerator()) { while (enumerator.MoveNext()) { UpdateAcInfo current = enumerator.get_Current(); if (this.mItems.ContainsKey(current.acId)) { if ((current.status == UpdateAcInfo.AcStep.STEP.Finish || current.status == UpdateAcInfo.AcStep.STEP.Close) && this.mItems.get_Item(current.acId).Data.FinishPar > currentVersion && !this.mIsCheck) { current.status = UpdateAcInfo.AcStep.STEP.Ready; } this.mItems.get_Item(current.acId).Status = current.status; this.mItems.get_Item(current.acId).get_gameObject().SetActive(true); this.mItems.get_Item(current.acId).BtnStart.set_interactable(flag); if (flag) { flag = (current.status != UpdateAcInfo.AcStep.STEP.Start); } } } } this.mIsCheck = true; }
private void OnUpdateAwardPush(short state, UpdateAwardPush down = null) { if (state != 0) { StateManager.Instance.StateShow(state, 0); return; } if (this.mServerUpdateGiftInfos == null) { this.mServerUpdateGiftInfos = down.ac; this.mLocalUpdateGiftInfos = new List <UpdateAcInfo>(); for (int i = 0; i < this.mServerUpdateGiftInfos.get_Count(); i++) { UpdateAcInfo updateAcInfo = new UpdateAcInfo(); updateAcInfo.acId = this.mServerUpdateGiftInfos.get_Item(i).acId; updateAcInfo.status = this.mServerUpdateGiftInfos.get_Item(i).status; this.mLocalUpdateGiftInfos.Add(updateAcInfo); } } else { using (List <UpdateAcInfo> .Enumerator enumerator = down.ac.GetEnumerator()) { while (enumerator.MoveNext()) { UpdateAcInfo current = enumerator.get_Current(); bool flag = true; for (int j = 0; j < this.mServerUpdateGiftInfos.get_Count(); j++) { if (this.mServerUpdateGiftInfos.get_Item(j).acId == current.acId) { this.mServerUpdateGiftInfos.get_Item(j).status = current.status; this.mLocalUpdateGiftInfos.get_Item(j).status = current.status; flag = false; break; } } if (flag) { this.mServerUpdateGiftInfos.Add(current); UpdateAcInfo updateAcInfo2 = new UpdateAcInfo(); updateAcInfo2.acId = current.acId; updateAcInfo2.status = current.status; this.mLocalUpdateGiftInfos.Add(updateAcInfo2); } } } EventDispatcher.Broadcast(EventNames.UpdateAwardPush); } if (this.IsNeedUpdatePack) { this.AddCheckIsWifi(); } }
private void CheckIsWifi() { if (!UIManagerControl.Instance.IsOpen("TownUI") && !this.mIsForecUpdate) { if (this.mDownloadingAcId > 0) { Downloader.Instance.OnPauseClick(); this.mDownloadingAcId = -1; Debug.Log("===[暂停下载]==="); } } else if (!this.IsWifi && this.mDownloadingAcId > 0 && !this.mUsing4GDownload) { Downloader.Instance.OnPauseClick(); this.mDownloadingAcId = -1; Debug.Log("===[暂停下载]==="); } else if (!this.mIsForecUpdate && this.IsWifi && this.mDownloadingAcId == -1) { using (List <UpdateAcInfo> .Enumerator enumerator = this.mLocalUpdateGiftInfos.GetEnumerator()) { UpdateAcInfo info; while (enumerator.MoveNext()) { info = enumerator.get_Current(); if (info.status == UpdateAcInfo.AcStep.STEP.Ready) { GengXinYouLi gengXinYouLi = DataReader <GengXinYouLi> .Get(info.acId); if (gengXinYouLi != null && gengXinYouLi.FinishPar > this.mDownloadVersion) { this.StartDownloadPackageById(info.acId, false); UpdateAcInfo updateAcInfo = this.mLocalUpdateGiftInfos.Find((UpdateAcInfo e) => e.acId == info.acId); if (updateAcInfo != null) { updateAcInfo.status = UpdateAcInfo.AcStep.STEP.Start; } Debug.Log("===[开始下载]==="); return; } } } } this.RemoveCheckIsWifi(); } }
public void UpdateItem(GengXinYouLi data) { if (!this.m_bInited) { base.AwakeBase(BindingContext.BindingContextMode.MonoBinding, false); } this.Data = data; if (this.Data == null || this.Data.ItemId.get_Count() != this.Data.ItemNum.get_Count()) { Debug.Log("<color=red>Error:</color>[有礼更新]GengXinYouLi配置数据异常"); return; } this.mLastPack = DataReader <ResourceSplit> .Get(this.Data.FinishPar - 1); if (this.mLastPack == null) { Debug.Log("<color=red>Error:</color>[有礼更新]ResourceSplit配置数据异常"); return; } this.Pack = DataReader <ResourceSplit> .Get(this.Data.FinishPar); if (this.Pack == null) { Debug.Log("<color=red>Error:</color>[有礼更新]ResourceSplit配置数据异常"); return; } UIHelper.GetText(base.get_transform(), "txTitle").set_text(string.Format(GameDataUtils.GetChineseContent(513143, false), OperateActivityManager.Instance.SwitchChineseNumber(this.mLastPack.ID))); UIHelper.GetText(base.get_transform(), "txMaxLv").set_text(string.Format(GameDataUtils.GetChineseContent(513144, false), this.mLastPack.LvLimit)); using (List <UpdateAcInfo> .Enumerator enumerator = OperateActivityManager.Instance.LocalUpdateGiftInfos.GetEnumerator()) { while (enumerator.MoveNext()) { UpdateAcInfo current = enumerator.get_Current(); if (current.acId == this.Data.Id) { this.IsOnlyLocalDownload = (current.status != UpdateAcInfo.AcStep.STEP.Ready && this.Data.FinishPar > OperateActivityManager.Instance.CurrentVersion); break; } } } this.Status = UpdateAcInfo.AcStep.STEP.Ready; this.Size = this.Pack.SizeMbit; }
private void DownloadPackageFinish(bool isDone) { if (this.mDownloadingAcId > 0 && isDone) { this.SetFinishedUpdatePackageId(); UpdateAcInfo updateAcInfo = this.mLocalUpdateGiftInfos.Find((UpdateAcInfo e) => e.acId == this.mDownloadingAcId); if (updateAcInfo != null) { updateAcInfo.status = UpdateAcInfo.AcStep.STEP.Finish; } EventDispatcher.Broadcast <int>(EventNames.UpdateDownloadFinish, this.mDownloadingAcId); this.SendDownLoadFinishReq(this.mDownloadingAcId); if (this.mIsForecUpdate) { this.RestartConfirm(GameDataUtils.GetChineseContent(513157, false)); } else { this.mDownloadVersion++; } this.mIsNeedRestart = true; } else { UpdateAcInfo updateAcInfo2 = this.mLocalUpdateGiftInfos.Find((UpdateAcInfo e) => e.acId == this.mDownloadingAcId); if (updateAcInfo2 != null) { updateAcInfo2.status = UpdateAcInfo.AcStep.STEP.Ready; } this.mDownloadingAcId = -1; UIManagerControl.Instance.ShowToastText(GameDataUtils.GetChineseContent(513150, false)); this.RemoveCheckIsWifi(); } EventDispatcher.Broadcast(EventNames.UpdateAwardPush); if (!this.IsNeedUpdatePack) { EventDispatcher.Broadcast(EventNames.GetAllUpdateReward); } }
private void CreateItemList(List <GengXinYouLi> list) { if (list == null) { Debug.Log("<color=red>Error:</color>[更新有礼]说好的配置表呢???"); return; } for (int i = 0; i < list.get_Count(); i++) { GameObject instantiate2Prefab = ResourceManager.GetInstantiate2Prefab("UpdateGiftItem"); UGUITools.SetParent(this.mListGrid, instantiate2Prefab, false); UpdateGiftItem component = instantiate2Prefab.GetComponent <UpdateGiftItem>(); component.UpdateItem(list.get_Item(i)); component.EventHandler = new Action <string, UpdateGiftItem>(this.OnClickButton); component.get_gameObject().SetActive(false); this.mItems.Add(list.get_Item(i).Id, component); } int currentVersion = OperateActivityManager.Instance.CurrentVersion; List <UpdateAcInfo> localUpdateGiftInfos = OperateActivityManager.Instance.LocalUpdateGiftInfos; using (List <UpdateAcInfo> .Enumerator enumerator = localUpdateGiftInfos.GetEnumerator()) { while (enumerator.MoveNext()) { UpdateAcInfo current = enumerator.get_Current(); if (this.mItems.ContainsKey(current.acId) && this.mItems.get_Item(current.acId).Data.FinishPar <= currentVersion && current.status == UpdateAcInfo.AcStep.STEP.Ready) { if (this.reqIds == null) { this.reqIds = new List <int>(); } OperateActivityManager.Instance.SendUpdateAwardReq(current.acId); this.reqIds.Add(current.acId); } } } }