using UnityEngine; using FairyGUI; using UI.Notice; using System.Collections.Generic; using ET; namespace GFGGame { public class NoticeView : BaseWindow { private UI_NoticeUI _ui; private EffectUI _effectUI1; private EffectUI _effectUI2; private AdCfg[] activitydata; private List showActivity = new List(); 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) { UpdateInfo(); _ui.m_listActivity.numItems = showActivity.Count; _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.m_txtName.text = showActivity[index].res; switch (showActivity[index].jumpId) { //后续添加其他活动 case "LuckyBoxView": item.m_imgTips.visible = RedDotDataManager.Instance.GetActLuckyBoxRewardRed(ConstLimitTimeActivityType.ActLimitTsy) || RedDotDataManager.Instance.GetLuckyBoxFreeTimes(); break; default: break; } long endTime = 0; long curTime = TimeHelper.ServerNow(); if (showActivity[0] != null || showActivity != null) { endTime = TimeUtil.DateTimeToTimestamp(showActivity[0].endTime); } item.m_txtTime.text = string.Format("剩余时间:{0}", TimeUtil.FormattingTimeTo_DDHHmm(endTime - curTime)); item.target.onClick.Add(OnListActivityClick); item.target.data = showActivity[index]; UI_ListActivityItem.ProxyEnd(); } private void OnListActivityClick(EventContext context) { AdCfg adCfg = (AdCfg)(context.data as GObject).data; object[] param = null; int jumpIndex = 0; if (adCfg.jumpId == nameof(LimitChargeView)) { param = new object[] { adCfg.activityId }; } if (adCfg.jumpId == nameof(NewLimitChargeView)) { param = new object[] { adCfg.activityId }; } if (adCfg.jumpId == nameof(LuckyBoxView)) { jumpIndex = adCfg.jumpParamArr[0]; } if (jumpIndex != 0) ViewManager.Show($"GFGGame.{adCfg.jumpId}", jumpIndex); else ViewManager.Show($"GFGGame.{adCfg.jumpId}", param); } 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)); } } else { ViewManager.Show(noticeInfo); } } private void UpdateInfo() { if(activitydata == null) { activitydata = AdCfgArray.Instance.dataArray; } showActivity.Clear(); for (int i = 0; i < activitydata.Length; i++) { AdCfg adCfg = activitydata[i]; if (adCfg.activityId > 0) { if (ActivityGlobalDataManager.Instance.GetActivityInfo(adCfg.activityId) == null) continue; ActivityInfo activityInfo = ActivityGlobalDataManager.Instance.GetActivityInfo(adCfg.activityId); if (TimeHelper.ServerNow() < activityInfo.StartTime || TimeHelper.ServerNow() > activityInfo.EndTime) continue; } if (adCfg.startTime != "" && adCfg.startTime != null) { long startTime = TimeUtil.DateTimeToTimestamp(adCfg.startTime); long endTime = TimeUtil.DateTimeToTimestamp(adCfg.endTime); if (TimeHelper.ServerNow() < startTime || TimeHelper.ServerNow() > endTime) { continue; } else { showActivity.Add(adCfg); } } } } } }