using UnityEngine; using FairyGUI; using UI.Notice; namespace GFGGame { public class NoticeView : BaseWindow { private UI_NoticeUI _ui; private EffectUI _effectUI1; private EffectUI _effectUI2; public override void Dispose() { EffectUIPool.Recycle(_effectUI1); _effectUI1 = null; EffectUIPool.Recycle(_effectUI2); _effectUI2 = null; if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void Init() { base.Init(); packageName = UI_NoticeUI.PACKAGE_NAME; _ui = UI_NoticeUI.Create(); this.viewCom = _ui.target; this.viewCom.Center(); this.modal = true; viewAnimationType = EnumViewAnimationType.ZOOM_CENTER; } protected override void OnInit() { base.OnInit(); _ui.m_listActivity.itemRenderer = ListActivityItemRender; _ui.m_listActivity.onClick.Add(OnListActivityClick); _ui.m_listNotice.itemRenderer = ListNoticeItemRender; _ui.m_c1.onChanged.Add(OnCtrlChange); AddEffect(); } protected override void AddEventListener() { base.AddEventListener(); EventAgent.AddEventListener(ConstMessage.NOTICE_SYSTOM_ADD, OnCtrlChange); EventAgent.AddEventListener(ConstMessage.NOTICE_SYSTOM_REMOVE, OnCtrlChange); } protected override void OnShown() { base.OnShown(); _ui.m_c1.selectedIndex = 1; _ui.m_listActivity.visible = true; _ui.m_listNotice.visible = true; _ui.m_buttonCom.visible = true; OnCtrlChange(); } protected override void OnHide() { base.OnHide(); } protected override void RemoveEventListener() { base.RemoveEventListener(); EventAgent.RemoveEventListener(ConstMessage.NOTICE_SYSTOM_ADD, OnCtrlChange); EventAgent.RemoveEventListener(ConstMessage.NOTICE_SYSTOM_REMOVE, OnCtrlChange); } private void AddEffect() { //邊框左上角特效 _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holderLeftTop, "ui_Activity", "Com_window_L_up"); //邊框右下角特效 _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_holderRightDowm, "ui_Activity", "Com_window_R_Down"); } private void OnCtrlChange() { if (_ui.m_c1.selectedIndex == 0) { _ui.m_listActivity.numItems = 0; _ui.m_txtTips.visible = _ui.m_listActivity.numItems == 0; } else if (_ui.m_c1.selectedIndex == 1) { _ui.m_listNotice.numItems = NoticeDataManager.Instance.NoticeInfos.Count; _ui.m_txtTips.visible = _ui.m_listNotice.numItems == 0; } } private void ListActivityItemRender(int index, GObject obj) { UI_ListActivityItem item = UI_ListActivityItem.Proxy(obj); item.m_loaShow.url = ResPathUtil.GetActivityPath(""); item.target.data = index; UI_ListActivityItem.ProxyEnd(); } private void OnListActivityClick(EventContext context) { // _ui.m_listActivity.visible = false; // _ui.m_listNotice.visible = false; // int noticeId = (int)(context.data as GObject).data; // ViewManager.Show(null, new object[] { typeof(NoticeView).Name, this.viewData }); } private void ListNoticeItemRender(int index, GObject obj) { NoticeInfo noticeInfo = NoticeDataManager.Instance.NoticeInfos[index]; UI_ListNoticeItem item = UI_ListNoticeItem.Proxy(obj); item.m_txtTitle.text = noticeInfo.title; item.m_txtTime.text = TimeUtil.FormattingTimeTo_yyyMMdd0(noticeInfo.time); // item.m_imgTips.visible = !noticeInfo.readStatus; RedDotController.Instance.SetComRedDot(item.target, !noticeInfo.readStatus, "gg_gg_hdhdgth", -40, 32); if (item.m_btnGo.data == null) { item.m_btnGo.onClick.Add(OnListNoticeBtnGoClick); } item.m_btnGo.data = noticeInfo; UI_ListNoticeItem.ProxyEnd(); } private async void OnListNoticeBtnGoClick(EventContext context) { _ui.m_listActivity.visible = false; _ui.m_listNotice.visible = false; _ui.m_buttonCom.visible = false; NoticeInfo noticeInfo = (context.sender as GObject).data as NoticeInfo; if (noticeInfo.content == "") { bool result = await NoticeSProxy.ReqSystemNotice(noticeInfo.noticeId); if (result) { ViewManager.Show(NoticeDataManager.Instance.GetNoticeInfoById(noticeInfo.noticeId), new object[] { typeof(NoticeView).Name, this.viewData }); } } else { ViewManager.Show(noticeInfo, new object[] { typeof(NoticeView).Name, this.viewData }); } } } }