Ver código fonte

系统公告

zhaoyang 3 anos atrás
pai
commit
0dabc9922d

+ 1 - 2
FGUIProject/assets/Notice/NoticeSystemShowUI.xml

@@ -6,8 +6,7 @@
     <text id="n17_kjq3" name="txtTitle" xy="425,350" pivot="0.5,0" size="228,74" group="n28_kjq3" fontSize="56" color="#8f6e30" text="活动标题"/>
     <group id="n28_kjq3" name="n28" xy="280,350" size="519,85" group="n23_kjq3"/>
     <component id="n27_kjq3" name="ComContent" src="kjq3u" fileName="components/ComContent.xml" xy="87,455" size="905,862" group="n23_kjq3"/>
-    <text id="n24_kjq3" name="txtName" xy="791,1373" pivot="1,0" size="201,52" group="n23_kjq3" fontSize="38" color="#a09172" text="GFG工作室"/>
-    <group id="n23_kjq3" name="n23" xy="87,350" size="905,1075" advanced="true">
+    <group id="n23_kjq3" name="n23" xy="87,350" size="905,967" advanced="true">
       <relation target="" sidePair="top-middle"/>
     </group>
   </displayList>

+ 1 - 1
FGUIProject/assets/Notice/components/ComContent.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <component size="905,970" overflow="scroll">
   <displayList>
-    <text id="n27_kjq3" name="txtContent" xy="0,0" size="905,51" fontSize="38" color="#a09172" autoSize="height" text="GFG工作室"/>
+    <richtext id="n28_hmrw" name="txtContent" xy="0,0" size="905,52" fontSize="38" color="#a09172" ubb="true" autoSize="height" text=""/>
   </displayList>
 </component>

+ 19 - 0
GameClient/Assets/Game/HotUpdate/Controller/LoginController.cs

@@ -96,12 +96,31 @@ namespace GFGGame
 
         private static async ETTask OnLoginSuccess()
         {
+            ReqNoticeInfo();
             await GetServerInfos();
             ServerInfosComponent serverInfosComponent = GameGlobal.zoneScene.GetComponent<ServerInfosComponent>();
 
             ViewManager.Hide<ModalStatusView>();
             EventAgent.DispatchEvent(ConstMessage.SERVER_CHANGE, serverInfosComponent.CurrentServerId);
         }
+        private static async void ReqNoticeInfo()
+        {
+            bool result = await NoticeSProxy.ReqSystemNoticeList();
+            if (result)
+            {
+                NoticeInfo noticeInfo = NoticeDataManager.Instance.NoticeInfos[0];
+                bool result1 = await NoticeSProxy.ReqSystemNotice(noticeInfo.noticeId);
+                if (result1)
+                {
+                    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>();
+                    }
+                }
+            }
+        }
 
         private static void OnLoginFail(int errorCode)
         {

+ 35 - 23
GameClient/Assets/Game/HotUpdate/Data/NoticeDataManager.cs

@@ -1,56 +1,68 @@
 using System.Collections.Generic;
+using System.Linq;
 
 namespace GFGGame
 {
-    public struct NoticeInfo
+    public class NoticeInfo
     {
         public int noticeId;
         public string title;
         public long time;//时间戳,单位秒
-        public string context;
+        public string content;
+        public bool readStatus;//对应的读取状态,true为已读
     }
     public class NoticeDataManager : SingletonBase<NoticeDataManager>
     {
-        public NoticeInfo noticeInfo = new NoticeInfo();
-
-        private List<NoticeInfo> _noticeIdList = new List<NoticeInfo>();
-        public List<NoticeInfo> NoticeIdList
+        private List<NoticeInfo> _noticeInfos = new List<NoticeInfo>();
+        public List<NoticeInfo> NoticeInfos
         {
             get
             {
-                return _noticeIdList;
+                return _noticeInfos;
             }
         }
+
         private Dictionary<int, NoticeInfo> _noticeInfoDic = new Dictionary<int, NoticeInfo>();
-        public void UpdateNoticeIdList(NoticeInfo noticeIdList)
+
+        public void UpdateNoticeIdList(NoticeInfo noticeInfo)
         {
-            // _noticeIdList = noticeIdList;
+
             if (!_noticeInfoDic.ContainsKey(noticeInfo.noticeId))
             {
-                _noticeInfoDic.Add(noticeIdList.noticeId, noticeInfo);
+                _noticeInfoDic.Add(noticeInfo.noticeId, noticeInfo);
             }
             else
             {
                 _noticeInfoDic[noticeInfo.noticeId] = noticeInfo;
             }
-            // SortNoticeIdList();
+            NoticeDicToList();
+
+        }
+        public void UpdateNoticeContent(int noticeId, string content)
+        {
+            _noticeInfoDic[noticeId].content = content;
+            _noticeInfoDic[noticeId].readStatus = true;
+            NoticeDicToList();
 
         }
-        public void UpdateSystemNoticeChanged(int noticeId, bool remove)
+        public void UpdateSystemNoticeRemove(int noticeId)
+        {
+            if (_noticeInfoDic.ContainsKey(noticeId)) _noticeInfoDic.Remove(noticeId);
+            NoticeDicToList();
+        }
+        private void NoticeDicToList()
         {
-            // if (remove)
-            // {
-            //     _noticeIdList.Remove(noticeId);
-            // }
-            // else
-            // {
-            //     _noticeIdList.Insert(0, noticeId);
-            // }
-            // SortNoticeIdList();
+            _noticeInfos = _noticeInfoDic.Values.ToList();
+            _noticeInfos.Sort((NoticeInfo a, NoticeInfo b) =>
+            {
+                return b.noticeId.CompareTo(a.noticeId);
+            });
         }
-        private void SortNoticeIdList()
+
+
+        public NoticeInfo GetNoticeInfoById(int noticeId)
         {
-            _noticeIdList.Sort((NoticeInfo a, NoticeInfo b) => { return b.noticeId.CompareTo(a.noticeId); });
+            return _noticeInfoDic[noticeId];
         }
     }
 }

+ 2 - 20
GameClient/Assets/Game/HotUpdate/ETCodes/Hotfix/App/Login/LoginHelper.cs

@@ -101,28 +101,10 @@ namespace ET
             AccountInfoComponent accountInfoComponent = zoneScene.GetComponent<AccountInfoComponent>();
             accountInfoComponent.Token = a2CLoginAccount.Token;
             accountInfoComponent.AccountId = a2CLoginAccount.AccountId;
-            accountInfoComponent.Age = a2CLoginAccount.Age;
-            GameGlobal.noticeAddress = a2CLoginAccount.NoticeAddress;
-            ReqNoticeInfo();
-        }
-        private static async void ReqNoticeInfo()
-        {
-            bool result = await NoticeSProxy.ReqSystemNoticeList();
-            if (result)
-            {
-                // bool result1 = await NoticeSProxy.ReqSystemNotice(NoticeDataManager.Instance.NoticeIdList[0]);
-                // if (result)
-                // {
-                //     int noticeTime = TimeUtil.GetDayTimeBySec(NoticeDataManager.Instance.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>();
-                //     }
-                // }
-            }
+            accountInfoComponent.NoticeAddress = a2CLoginAccount.NoticeAddress;
         }
 
+
         public static async ETTask<int> Register(Scene zoneScene, string address, string account, string password, string name, string identityNum, string code)
         {
             A2C_Register r2C_Register = null;

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

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

+ 2 - 2
GameClient/Assets/Game/HotUpdate/FairyGUI/GenCode/Notice/UI_ComContent.cs

@@ -7,7 +7,7 @@ namespace UI.Notice
     public partial class UI_ComContent
     {
         public GComponent target;
-        public GTextField m_txtContent;
+        public GRichTextField m_txtContent;
         public const string URL = "ui://d8t5ezjbkjq3u";
         public const string PACKAGE_NAME = "Notice";
         public const string RES_NAME = "ComContent";
@@ -55,7 +55,7 @@ namespace UI.Notice
 
         private void Init(GComponent comp)
         {
-            m_txtContent = (GTextField)comp.GetChild("txtContent");
+            m_txtContent = (GRichTextField)comp.GetChild("txtContent");
         }
         public void Dispose(bool disposeTarget = false)
         {

+ 0 - 3
GameClient/Assets/Game/HotUpdate/FairyGUI/GenCode/Notice/UI_NoticeSystemShowUI.cs

@@ -10,7 +10,6 @@ namespace UI.Notice
         public GButton m_btnBack;
         public GTextField m_txtTitle;
         public UI_ComContent m_ComContent;
-        public GTextField m_txtName;
         public const string URL = "ui://d8t5ezjbkjq3t";
         public const string PACKAGE_NAME = "Notice";
         public const string RES_NAME = "NoticeSystemShowUI";
@@ -61,7 +60,6 @@ namespace UI.Notice
             m_btnBack = (GButton)comp.GetChild("btnBack");
             m_txtTitle = (GTextField)comp.GetChild("txtTitle");
             m_ComContent = (UI_ComContent)UI_ComContent.Create(comp.GetChild("ComContent"));
-            m_txtName = (GTextField)comp.GetChild("txtName");
         }
         public void Dispose(bool disposeTarget = false)
         {
@@ -69,7 +67,6 @@ namespace UI.Notice
             m_txtTitle = null;
             m_ComContent.Dispose();
             m_ComContent = null;
-            m_txtName = null;
             if(disposeTarget && target != null)
             {
                 target.RemoveFromParent();

+ 0 - 1
GameClient/Assets/Game/HotUpdate/GameGlobal.cs

@@ -26,7 +26,6 @@ namespace GFGGame
         public static string gameApiUrlTest;
 
         //ET
-        public static string noticeAddress;
         public static Scene zoneScene;
         public static Unit myUnit;
         public static NumericComponent myNumericComponent;

+ 29 - 13
GameClient/Assets/Game/HotUpdate/ServerProxy/NoticeSProxy.cs

@@ -7,9 +7,23 @@ namespace ET
 
     public class NoticeSystemNoticeChanged : AMHandler<M2C_SystemNoticeChanged>
     {
-        protected override async ETTask Run(Session session, M2C_SystemNoticeChanged message)
+        protected override async ETTask Run(Session session, M2C_SystemNoticeChanged response)
         {
-            NoticeDataManager.Instance.UpdateSystemNoticeChanged(message.NoticeId, message.Remove);
+            NoticeInfo noticeInfo = new NoticeInfo();
+            noticeInfo.noticeId = response.Notice.NoticeId;
+            noticeInfo.title = response.Notice.Title;
+            noticeInfo.time = response.Notice.TimeSec;
+            noticeInfo.readStatus = response.Notice.ReadStatus;
+            NoticeDataManager.Instance.UpdateNoticeIdList(noticeInfo);
+            await ETTask.CompletedTask;
+        }
+    }
+    public class NoticeSystemNoticeRemove : AMHandler<M2C_SystemNoticeRemoved>
+    {
+        protected override async ETTask Run(Session session, M2C_SystemNoticeRemoved response)
+        {
+
+            NoticeDataManager.Instance.UpdateSystemNoticeRemove(response.NoticeId);
             await ETTask.CompletedTask;
         }
     }
@@ -26,8 +40,9 @@ namespace GFGGame
             Session session = null;
             try
             {
-                session = GameGlobal.zoneScene.GetComponent<NetKcpComponent>().Create(NetworkHelper.ToIPEndPoint(GameGlobal.noticeAddress));
-                response = (N2C_GetSystemNoticeList)await session.Call(new C2N_GetSystemNoticeList() { });
+                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)
             {
@@ -42,13 +57,15 @@ namespace GFGGame
             {
                 return false;
             }
-            List<NoticeInfo> noticeInfos = new List<NoticeInfo>();
-            for (int i = 0; i < response.NoticeIdList.Count; i++)
+            for (int i = 0; i < response.NoticeList.Count; i++)
             {
                 NoticeInfo noticeInfo = new NoticeInfo();
-                noticeInfos.Add(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(noticeInfos);
             return true;
         }
         public static async ETTask<bool> ReqSystemNotice(int noticeId)
@@ -57,7 +74,9 @@ namespace GFGGame
             Session session = null;
             try
             {
-                session = GameGlobal.zoneScene.GetComponent<NetKcpComponent>().Create(NetworkHelper.ToIPEndPoint(GameGlobal.noticeAddress));
+                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 });
             }
             catch (Exception e)
@@ -73,10 +92,7 @@ namespace GFGGame
             {
                 return false;
             }
-            NoticeDataManager.Instance.noticeInfo.noticeId = response.NoticeId;
-            NoticeDataManager.Instance.noticeInfo.title = response.Title;
-            NoticeDataManager.Instance.noticeInfo.time = response.TimeSec;
-            NoticeDataManager.Instance.noticeInfo.context = response.Content;
+            NoticeDataManager.Instance.UpdateNoticeContent(response.NoticeId, response.Content);
 
             return true;
         }

+ 11 - 0
GameClient/Assets/Game/HotUpdate/Utils/TimeUtil.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections;
+using ET;
 using UnityEngine;
 
 namespace GFGGame
@@ -54,5 +55,15 @@ namespace GFGGame
             num = minutes;
             str = "秒";
         }
+        /// <summary>
+        /// 将时间戳转换成yyyy/m/d格式
+        /// </summary>
+        /// <param name="timeSec"></param>
+        public static string FormattingTime(int timeSec)
+        {
+            DateTime date = TimeInfo.Instance.ToDateTime(timeSec);
+            string str = date.ToString("yyyy/M/d ");
+            return str;
+        }
     }
 }

+ 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.noticeInfo.title;
-            _ui.m_txtContent.text = NoticeDataManager.Instance.noticeInfo.context;
+            _ui.m_txtTitle.text = NoticeDataManager.Instance.NoticeInfos[0].title;
+            _ui.m_txtContent.text = NoticeDataManager.Instance.NoticeInfos[0].content;
         }
 
         protected override void OnShown()

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

@@ -35,7 +35,9 @@ namespace GFGGame
         protected override void OnShown()
         {
             base.OnShown();
-
+            NoticeInfo noticeInfo = this.viewData as NoticeInfo;
+            _ui.m_txtTitle.text = noticeInfo.title;
+            _ui.m_ComContent.m_txtContent.text = noticeInfo.content;
         }
 
         protected override void OnHide()

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

@@ -58,7 +58,7 @@ namespace GFGGame
             }
             else if (_ui.m_c1.selectedIndex == 1)
             {
-                _ui.m_listNotice.numItems = NoticeDataManager.Instance.NoticeIdList.Count;
+                _ui.m_listNotice.numItems = NoticeDataManager.Instance.NoticeInfos.Count;
                 _ui.m_txtTips.visible = _ui.m_listNotice.numItems == 0;
             }
         }
@@ -74,26 +74,43 @@ namespace GFGGame
         {
             _ui.m_listActivity.visible = false;
             _ui.m_listNotice.visible = false;
-            //(context.data as GObject).data
+            // int noticeId = (int)(context.data as GObject).data;
+
             ViewManager.Show<NoticeActivityShowView>(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 =
+            item.m_txtTitle.text = noticeInfo.title;
+            item.m_txtTime.text = TimeUtil.FormattingTime((int)noticeInfo.time);
+            item.m_imgTips.visible = !noticeInfo.readStatus;
             if (item.m_btnGo.data == null)
             {
-
                 item.m_btnGo.onClick.Add(OnListNoticeBtnGoClick);
             }
+            item.m_btnGo.data = noticeInfo;
         }
-        private void OnListNoticeBtnGoClick(EventContext context)
+        private async void OnListNoticeBtnGoClick(EventContext context)
         {
             _ui.m_listActivity.visible = false;
             _ui.m_listNotice.visible = false;
-            //(context.data as GObject).data
-            ViewManager.Show<NoticeSystemShowView>(null, new object[] { typeof(NoticeView).Name, this.viewData });
+            NoticeInfo noticeInfo = (context.data as GObject).data as NoticeInfo;
+            if (noticeInfo.content == "")
+            {
+                bool result = await NoticeSProxy.ReqSystemNotice(noticeInfo.noticeId);
+                if (result)
+                {
+                    ViewManager.Show<NoticeSystemShowView>(NoticeDataManager.Instance.GetNoticeInfoById(noticeInfo.noticeId), new object[] { typeof(NoticeView).Name, this.viewData });
+
+                }
+            }
+            else
+            {
+
+                ViewManager.Show<NoticeSystemShowView>(noticeInfo, new object[] { typeof(NoticeView).Name, this.viewData });
+            }
         }
     }
 }

BIN
GameClient/Assets/ResIn/UI/Notice/Notice_fui.bytes