浏览代码

系统公告

zhaoyang 3 年之前
父节点
当前提交
16a58d2311

+ 1 - 0
GameClient/Assets/Game/HotUpdate/Controller/GameController.cs

@@ -204,6 +204,7 @@ namespace GFGGame
             RechargeSProxy.ReqExchangeInfo().Coroutine();
             DailyTaskSProxy.ReqDailyTaskInfos().Coroutine();
             ActivitySProxy.ReqDailyLoginInfos().Coroutine();
+            NoticeSProxy.ReqSystemNoticeList().Coroutine();
             EquipDataCache.cacher.autoPlay = StorageDataManager.Instance.GetStorageValue(ConstStorageId.STORAGE_AUTO_PLAY) <= 0 ? false : true;
             EquipDataCache.cacher.fightSpeed = StorageDataManager.Instance.GetStorageValue(ConstStorageId.STORAGE_AUTO_PLAY_SPEED) <= 1 ? 1 : StorageDataManager.Instance.GetStorageValue(ConstStorageId.STORAGE_AUTO_PLAY_SPEED);
             GameGlobal.skipCheckOpen = StorageDataManager.Instance.GetStorageValue(ConstStorageId.SKIP_CHECK_OPEN) <= 0 ? false : true;

+ 9 - 11
GameClient/Assets/Game/HotUpdate/Controller/LoginController.cs

@@ -99,25 +99,23 @@ namespace GFGGame
             await GetServerInfos();
             ServerInfosComponent serverInfosComponent = GameGlobal.zoneScene.GetComponent<ServerInfosComponent>();
             EventAgent.DispatchEvent(ConstMessage.SERVER_CHANGE, serverInfosComponent.CurrentServerId);
-            // await ReqNoticeInfo();
+            await ReqNoticeInfo();
 
             ViewManager.Hide<ModalStatusView>();
         }
         private static async ETTask ReqNoticeInfo()
         {
-            bool result = await NoticeSProxy.ReqSystemNoticeList();
+            bool result = await LoginHelper.ReqGetLatestNotice();
             if (result)
             {
-                NoticeInfo noticeInfo = NoticeDataManager.Instance.NoticeInfos[0];
-                bool result1 = await NoticeSProxy.ReqSystemNotice(noticeInfo.noticeId);
-                if (result1)
+                NoticeInfo noticeInfo = NoticeDataManager.Instance.LastNoticeInfo;
+
+                int noticeTime = TimeUtil.GetDayTimeBySec(noticeInfo.time, GlobalCfgArray.globalCfg.refreshTime);
+                int currentTime = TimeUtil.GetDayTimeBySec(TimeInfo.Instance.ServerNow() / 1000, GlobalCfgArray.globalCfg.refreshTime);
+                Debug.Log("noticeTime:" + noticeTime + "  currentTime:" + currentTime);
+                if ((currentTime - noticeTime) / TimeUtil.SECOND_PER_DAY < 3)
                 {
-                    int noticeTime = TimeUtil.GetDayTimeBySec(noticeInfo.time, GlobalCfgArray.globalCfg.refreshTime);
-                    int currentTime = TimeUtil.GetDayTimeBySec(TimeInfo.Instance.ServerNow(), GlobalCfgArray.globalCfg.refreshTime);
-                    if ((currentTime - noticeTime) / TimeUtil.SECOND_PER_DAY < 3)
-                    {
-                        ViewManager.Show<SystemNoticeView>();
-                    }
+                    ViewManager.Show<SystemNoticeView>();
                 }
             }
             return;

+ 14 - 1
GameClient/Assets/Game/HotUpdate/Data/NoticeDataManager.cs

@@ -8,11 +8,24 @@ namespace GFGGame
         public int noticeId;
         public string title;
         public long time;//时间戳,单位秒
-        public string content;
+        public string content = "";
         public bool readStatus;//对应的读取状态,true为已读
     }
     public class NoticeDataManager : SingletonBase<NoticeDataManager>
     {
+        private NoticeInfo _lastNoticeInfo;
+        public NoticeInfo LastNoticeInfo
+        {
+            get
+            {
+                return _lastNoticeInfo;
+            }
+            set
+            {
+                _lastNoticeInfo = value;
+            }
+        }
+
         private List<NoticeInfo> _noticeInfos = new List<NoticeInfo>();
         public List<NoticeInfo> NoticeInfos
         {

+ 30 - 1
GameClient/Assets/Game/HotUpdate/ETCodes/Hotfix/App/Login/LoginHelper.cs

@@ -101,7 +101,7 @@ namespace ET
             AccountInfoComponent accountInfoComponent = zoneScene.GetComponent<AccountInfoComponent>();
             accountInfoComponent.Token = a2CLoginAccount.Token;
             accountInfoComponent.AccountId = a2CLoginAccount.AccountId;
-            accountInfoComponent.NoticeAddress = a2CLoginAccount.NoticeAddress;
+
         }
 
 
@@ -389,5 +389,34 @@ namespace ET
             await ETTask.CompletedTask;
             return ErrorCode.ERR_Success;
         }
+
+        public static async ETTask<bool> ReqGetLatestNotice()
+        {
+            A2C_GetLatestNotice response = null;
+            try
+            {
+                response = (A2C_GetLatestNotice)await GameGlobal.zoneScene.GetComponent<SessionComponent>().Session.Call(new C2A_GetLatestNotice());
+            }
+            catch (Exception e)
+            {
+                Log.Error(e.ToString());
+                return false;
+            }
+
+            if (response.Error != ErrorCode.ERR_Success)
+            {
+                Log.Error(response.Error.ToString());
+                return false;
+            }
+            NoticeInfo noticeInfo = new NoticeInfo();
+            noticeInfo.noticeId = response.NoticeId;
+            noticeInfo.title = response.Title;
+            noticeInfo.time = response.TimeSec;
+            noticeInfo.content = response.Content;
+
+            NoticeDataManager.Instance.LastNoticeInfo = noticeInfo;
+
+            return true;
+        }
     }
 }

+ 0 - 1
GameClient/Assets/Game/HotUpdate/ETCodes/Model/App/Account/AccountInfoComponent.cs

@@ -7,6 +7,5 @@
         public string RealmKey;
         public string RealmAddress;
         public int Age;
-        public string NoticeAddress;
     }
 }

+ 27 - 51
GameClient/Assets/Game/HotUpdate/ServerProxy/NoticeSProxy.cs

@@ -28,6 +28,7 @@ namespace ET
             await ETTask.CompletedTask;
         }
     }
+
 }
 
 namespace GFGGame
@@ -37,65 +38,40 @@ namespace GFGGame
 
         public static async ETTask<bool> ReqSystemNoticeList()
         {
-            N2C_GetSystemNoticeList response = null;
-            Session session = null;
-            try
-            {
-                AccountInfoComponent accountInfoComponent = GameGlobal.zoneScene.GetComponent<AccountInfoComponent>();
-                session = GameGlobal.zoneScene.GetComponent<NetKcpComponent>().Create(NetworkHelper.ToIPEndPoint(accountInfoComponent.NoticeAddress));
-                response = (N2C_GetSystemNoticeList)await session.Call(new C2N_GetSystemNoticeList() { AccountId = (int)accountInfoComponent.AccountId });
-            }
-            catch (Exception e)
-            {
-                Log.Error(e.ToString());
-                return false;
-            }
-            finally
-            {
-                session?.Dispose();
-            }
-            if (response.Error != ErrorCode.ERR_Success)
-            {
-                return false;
-            }
-            for (int i = 0; i < response.NoticeList.Count; i++)
+            M2C_GetSystemNoticeList response = null;
+            response = (M2C_GetSystemNoticeList)await MessageHelper.SendToServer(new C2M_GetSystemNoticeList());
+            if (response != null)
             {
-                NoticeInfo noticeInfo = new NoticeInfo();
-                noticeInfo.noticeId = response.NoticeList[i].NoticeId;
-                noticeInfo.title = response.NoticeList[i].Title;
-                noticeInfo.time = response.NoticeList[i].TimeSec;
+                if (response.Error == ErrorCode.ERR_Success)
+                {
+                    for (int i = 0; i < response.NoticeList.Count; i++)
+                    {
+                        NoticeInfo noticeInfo = new NoticeInfo();
+                        noticeInfo.noticeId = response.NoticeList[i].NoticeId;
+                        noticeInfo.title = response.NoticeList[i].Title;
+                        noticeInfo.time = response.NoticeList[i].TimeSec;
 
-                NoticeDataManager.Instance.UpdateNoticeIdList(noticeInfo);
+                        NoticeDataManager.Instance.UpdateNoticeIdList(noticeInfo);
+                    }
+                    return true;
+                }
             }
-            return true;
+            return false;
         }
+
         public static async ETTask<bool> ReqSystemNotice(int noticeId)
         {
-            N2C_GetSystemNotice response = null;
-            Session session = null;
-            try
+            M2C_GetSystemNotice response = null;
+            response = (M2C_GetSystemNotice)await MessageHelper.SendToServer(new C2M_GetSystemNotice() { NoticeId = noticeId });
+            if (response != null)
             {
-                AccountInfoComponent accountInfoComponent = GameGlobal.zoneScene.GetComponent<AccountInfoComponent>();
-
-                session = GameGlobal.zoneScene.GetComponent<NetKcpComponent>().Create(NetworkHelper.ToIPEndPoint(accountInfoComponent.NoticeAddress));
-                response = (N2C_GetSystemNotice)await session.Call(new C2N_GetSystemNotice() { NoticeId = noticeId });
+                if (response.Error == ErrorCode.ERR_Success)
+                {
+                    NoticeDataManager.Instance.UpdateNoticeContent(response.NoticeId, response.Content);
+                    return true;
+                }
             }
-            catch (Exception e)
-            {
-                Log.Error(e.ToString());
-                return false;
-            }
-            finally
-            {
-                session?.Dispose();
-            }
-            if (response.Error != ErrorCode.ERR_Success)
-            {
-                return false;
-            }
-            NoticeDataManager.Instance.UpdateNoticeContent(response.NoticeId, response.Content);
-
-            return true;
+            return false;
         }
 
     }

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Views/Login/LoginView.cs

@@ -107,7 +107,7 @@ namespace GFGGame
         }
         private void OnClickBtnNotice()
         {
-            if (NoticeDataManager.Instance.NoticeInfos.Count == 0)
+            if (NoticeDataManager.Instance.LastNoticeInfo.noticeId == 0)
             {
                 PromptController.Instance.ShowFloatTextPrompt("暂无公告发布");
                 return;

+ 2 - 2
GameClient/Assets/Game/HotUpdate/Views/Login/SystemNoticeView.cs

@@ -20,8 +20,8 @@ namespace GFGGame
             this.viewCom.Center();
             this.modal = true;
 
-            _ui.m_txtTitle.text = NoticeDataManager.Instance.NoticeInfos[0].title;
-            _ui.m_txtContent.text = NoticeDataManager.Instance.NoticeInfos[0].content;
+            _ui.m_txtTitle.text = NoticeDataManager.Instance.LastNoticeInfo.title;
+            _ui.m_txtContent.text = NoticeDataManager.Instance.LastNoticeInfo.content;
         }
 
         protected override void OnShown()

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Views/Notice/NoticeView.cs

@@ -96,7 +96,7 @@ namespace GFGGame
         {
             _ui.m_listActivity.visible = false;
             _ui.m_listNotice.visible = false;
-            NoticeInfo noticeInfo = (context.data as GObject).data as NoticeInfo;
+            NoticeInfo noticeInfo = (context.sender as GObject).data as NoticeInfo;
             if (noticeInfo.content == "")
             {
                 bool result = await NoticeSProxy.ReqSystemNotice(noticeInfo.noticeId);