private void ShowNotice() { for (int i = 0; i < NoticeConfig.getInstance().getDataList().Count; i++) { NoticeInfo config = NoticeConfig.getInstance().getDataList()[i]; string key = $"{PlayerInfoComponent.Instance.uid}{config.id}"; if (PlayerPrefs.GetInt(key) != 1) { PlayerPrefs.SetInt(key, 1); UICommonPanelComponent script = UICommonPanelComponent.showCommonPanel(config.title, config.content); script.setOnClickOkEvent(() => { Game.Scene.GetComponent <UIComponent>().Remove(UIType.UICommonPanel); ShowNotice(); }); script.setOnClickCloseEvent(() => { Game.Scene.GetComponent <UIComponent>().Remove(UIType.UICommonPanel); ShowNotice(); }); break; } } }
protected override bool HandleRecentInfo() { if (RecentInfo.Length == 0) { UserConfig = new NoticeConfig(); UserConfig.reply_code = (int)ReplyCodeMeaning.NoNetWork; UserConfig.reply_msg = "没有校园网"; Debug.WriteLine(UserConfig.reply_msg); return(false); } else { //如果有返回信息 var serializer = new DataContractJsonSerializer(typeof(NoticeConfig)); var mStream = new MemoryStream(Encoding.UTF8.GetBytes(RecentInfo)); try { UserConfig = (NoticeConfig)serializer.ReadObject(mStream); } catch (Exception e) { UserConfig.reply_code = (int)ReplyCodeMeaning.OtherFail; UserConfig.reply_msg = "数据分析失败"; Debug.WriteLine(UserConfig.reply_msg); return(false); } if (UserConfig.notice != null) { UserConfig.reply_code = (int)ReplyCodeMeaning.QuerySucceed; UserConfig.reply_msg = "获取成功!"; for (int i = 0; i < UserConfig.total; ++i) { UserConfig.notice[i].title = Regex.Replace(UserConfig.notice[i].title, @"<.*?>", @""); } Debug.WriteLine(UserConfig.reply_msg); return(true); } else if (UserConfig.total == 0) { UserConfig.reply_code = (int)ReplyCodeMeaning.QuerySucceed; UserConfig.reply_msg = "暂时没有通知."; Debug.WriteLine(UserConfig.reply_msg); return(true); } else { UserConfig.reply_code = (int)ReplyCodeMeaning.OtherFail; UserConfig.reply_msg = "数据分析失败"; Debug.WriteLine(UserConfig.reply_msg); return(false); } } }
public async Task getAllData() { UINetLoadingComponent.showNetLoading(); try { await HttpReqUtil.Req(NetConfig.getInstance().getWebUrl() + "files/tips.json", TipsConfig.getInstance().init); await HttpReqUtil.Req(NetConfig.getInstance().getWebUrl() + "files/prop.json", PropConfig.getInstance().init); await HttpReqUtil.Req(NetConfig.getInstance().getWebUrl() + "files/zhuanpan.json", ZhuanPanConfig.getInstance().init); await HttpReqUtil.Req(NetConfig.getInstance().getWebUrl() + "files/notice.json", NoticeConfig.getInstance().init); await HttpReqUtil.Req(NetConfig.getInstance().getWebUrl() + "files/friendRoomConfig.json", FriendRoomConfig.getInstance().init); //await SensitiveWordUtil.Req("http://fwdown.hy51v.com/online/file/stopwords.txt"); string data = CommonUtil.getTextFileByBundle("config", "stopwords"); SensitiveWordUtil.WordsDatas = data.Split(','); } catch (Exception ex) { Log.Error(ex); } UINetLoadingComponent.closeNetLoading(); }
/// <summary> /// 创建通知列表 /// </summary> private void CreateNoticeItems() { GameObject obj = null; for (int i = 0; i < NoticeConfig.getInstance().getDataList().Count; ++i) { NoticeInfo info = NoticeConfig.getInstance().getDataList()[i]; if (i < objList.Count) { obj = objList[i]; } else { obj = GameObject.Instantiate(noticeItem); obj.transform.SetParent(Grid.transform); obj.transform.localPosition = Vector3.zero; obj.transform.localScale = Vector3.one; UI ui = ComponentFactory.Create <UI, GameObject>(obj); ui.AddComponent <UINoticeItemComponent>(); string key = $"{PlayerInfoComponent.Instance.uid}{info.id}"; int state = PlayerPrefs.GetInt(key); if (state != 1) { obj.transform.SetAsFirstSibling(); objList.Insert(0, obj); uiList.Insert(0, ui); } else { objList.Add(obj); uiList.Add(ui); } ui.GetComponent <UINoticeItemComponent>().SetText(info); ui.GetComponent <UINoticeItemComponent>().SetLine(); } } #region float TotalTextHeight = 0; float objHeight = noticeItem.GetComponent <RectTransform>().rect.height; for (int i = 0; i < uiList.Count; ++i) { TotalTextHeight += uiList[i].GetComponent <UINoticeItemComponent>().GetTextHeight(); } float height = Grid.transform.childCount * objHeight + TotalTextHeight + 70; Grid.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height); for (int i = 0; i < Grid.transform.childCount; ++i) { float y = 0; if (i == 0) { y = (float)(-objHeight) * i; } else { y = (float)Grid.transform.GetChild(i - 1).transform.localPosition.y - objHeight - (uiList[i - 1].GetComponent <UINoticeItemComponent>().GetTextHeight()); } Grid.transform.GetChild(i).transform.localPosition = new Vector3(0, y, 0.0f); // Debug.Log("pos :" + TestGrid.transform.GetChild(i).transform.localPosition); } #endregion }