Browse Source

系统公告

zhaoyang 3 years ago
parent
commit
2a61fa5c8e

+ 1 - 1
FGUIProject/assets/Login/NoticeUI.xml

@@ -3,7 +3,7 @@
   <displayList>
     <loader id="n6_q08x" name="n6" xy="-4,0" size="939,982" url="ui://myoktu7pozsv4r" fill="scaleFree" autoSize="true"/>
     <text id="n3_q08x" name="txtTitle" xy="9,105" size="911,52" fontSize="38" color="#b28054" align="center" autoSize="none" text="公告公告"/>
-    <text id="n4_q08x" name="txtContent" xy="97,231" size="735,629" fontSize="32" color="#cba482" align="center" autoSize="none" text=""/>
     <image id="n7_ozsv" name="n7" src="ozsv4y" fileName="images/dl_xian_3.png" xy="83,127"/>
+    <component id="n8_hmrw" name="comContent" src="hmrw5g" fileName="components/ComContent.xml" xy="97,231" size="735,629"/>
   </displayList>
 </component>

+ 6 - 0
FGUIProject/assets/Login/components/ComContent.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<component size="735,629" overflow="scroll">
+  <displayList>
+    <richtext id="n8_hmrw" name="comContent" xy="0,0" size="735,19" fontSize="12" ubb="true" autoSize="height" text=""/>
+  </displayList>
+</component>

+ 1 - 0
FGUIProject/assets/Login/package.xml

@@ -41,6 +41,7 @@
     <image id="pcul5d" name="kqjm_zx.png" path="/images/"/>
     <component id="pcul5e" name="Button3.xml" path="/components/"/>
     <component id="pcul5f" name="Button4.xml" path="/components/"/>
+    <component id="hmrw5g" name="ComContent.xml" path="/components/"/>
   </resources>
   <publish name="" path="..\GameClient\Assets\ResIn\UI\Login" packageCount="2" genCode="true" extractAlpha="true"/>
 </packageDescription>

+ 3 - 0
FGUIProject/assets/Notice/NoticeUI.xml

@@ -28,5 +28,8 @@
       <Button checked="true" icon="ui://d8t5ezjbkjq33" selectedIcon="ui://d8t5ezjbkjq34" controller="c1" page="1"/>
     </component>
     <group id="n5_kjq3" name="n5" xy="154,1197" size="735,108" advanced="true" layout="hz" colGap="53" excludeInvisibles="true"/>
+    <text id="n6_hmrw" name="txtTips" xy="408,500" size="244,54" fontSize="40" color="#736b64" align="center" text="暂无系统公告">
+      <gearText controller="c1" pages="1" values="暂无系统公告" default="暂无活动公告"/>
+    </text>
   </displayList>
 </component>

+ 49 - 0
GameClient/Assets/Game/HotUpdate/Data/NoticeDataManager.cs

@@ -1,7 +1,56 @@
+using System.Collections.Generic;
+
 namespace GFGGame
 {
+    public struct NoticeInfo
+    {
+        public int noticeId;
+        public string title;
+        public long time;//时间戳,单位秒
+        public string context;
+    }
     public class NoticeDataManager : SingletonBase<NoticeDataManager>
     {
+        public NoticeInfo noticeInfo = new NoticeInfo();
+
+        private List<NoticeInfo> _noticeIdList = new List<NoticeInfo>();
+        public List<NoticeInfo> NoticeIdList
+        {
+            get
+            {
+                return _noticeIdList;
+            }
+        }
+        private Dictionary<int, NoticeInfo> _noticeInfoDic = new Dictionary<int, NoticeInfo>();
+        public void UpdateNoticeIdList(NoticeInfo noticeIdList)
+        {
+            // _noticeIdList = noticeIdList;
+            if (!_noticeInfoDic.ContainsKey(noticeInfo.noticeId))
+            {
+                _noticeInfoDic.Add(noticeIdList.noticeId, noticeInfo);
+            }
+            else
+            {
+                _noticeInfoDic[noticeInfo.noticeId] = noticeInfo;
+            }
+            // SortNoticeIdList();
 
+        }
+        public void UpdateSystemNoticeChanged(int noticeId, bool remove)
+        {
+            // if (remove)
+            // {
+            //     _noticeIdList.Remove(noticeId);
+            // }
+            // else
+            // {
+            //     _noticeIdList.Insert(0, noticeId);
+            // }
+            // SortNoticeIdList();
+        }
+        private void SortNoticeIdList()
+        {
+            _noticeIdList.Sort((NoticeInfo a, NoticeInfo b) => { return b.noticeId.CompareTo(a.noticeId); });
+        }
     }
 }

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

@@ -1,5 +1,5 @@
 using System;
-
+using GFGGame;
 
 namespace ET
 {
@@ -102,7 +102,25 @@ namespace ET
             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>();
+                //     }
+                // }
+            }
         }
 
         public static async ETTask<int> Register(Scene zoneScene, string address, string account, string password, string name, string identityNum, string code)

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

@@ -12,6 +12,7 @@ namespace UI.Notice
         public GList m_listNotice;
         public GButton m_btnActivity;
         public GButton m_btnNotice;
+        public GTextField m_txtTips;
         public const string URL = "ui://d8t5ezjbkjq3i";
         public const string PACKAGE_NAME = "Notice";
         public const string RES_NAME = "NoticeUI";
@@ -64,6 +65,7 @@ namespace UI.Notice
             m_listNotice = (GList)comp.GetChild("listNotice");
             m_btnActivity = (GButton)comp.GetChild("btnActivity");
             m_btnNotice = (GButton)comp.GetChild("btnNotice");
+            m_txtTips = (GTextField)comp.GetChild("txtTips");
         }
         public void Dispose(bool disposeTarget = false)
         {
@@ -72,6 +74,7 @@ namespace UI.Notice
             m_listNotice = null;
             m_btnActivity = null;
             m_btnNotice = null;
+            m_txtTips = null;
             if(disposeTarget && target != null)
             {
                 target.RemoveFromParent();

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

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

+ 70 - 10
GameClient/Assets/Game/HotUpdate/ServerProxy/NoticeSProxy.cs

@@ -1,25 +1,85 @@
+using System;
 using System.Collections.Generic;
 using ET;
 using GFGGame;
+namespace ET
+{
 
+    public class NoticeSystemNoticeChanged : AMHandler<M2C_SystemNoticeChanged>
+    {
+        protected override async ETTask Run(Session session, M2C_SystemNoticeChanged message)
+        {
+            NoticeDataManager.Instance.UpdateSystemNoticeChanged(message.NoticeId, message.Remove);
+            await ETTask.CompletedTask;
+        }
+    }
+}
 
 namespace GFGGame
 {
     public static class NoticeSProxy
     {
-        public static async ETTask<bool> ClothingDecompose(List<int> itemIds, List<int> itemNums)
+
+        public static async ETTask<bool> ReqSystemNoticeList()
         {
-            M2C_ClothingDecompose response = null;
-            response = (M2C_ClothingDecompose)await MessageHelper.SendToServer(new C2M_ClothingDecompose() { itemIds = itemIds, itemNums = itemNums });
-            if (response != null)
+            N2C_GetSystemNoticeList response = null;
+            Session session = null;
+            try
             {
-                if (response.Error == ErrorCode.ERR_Success)
-                {
-                    BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(response.bonusList));
-                    return true;
-                }
+                session = GameGlobal.zoneScene.GetComponent<NetKcpComponent>().Create(NetworkHelper.ToIPEndPoint(GameGlobal.noticeAddress));
+                response = (N2C_GetSystemNoticeList)await session.Call(new C2N_GetSystemNoticeList() { });
             }
-            return false;
+            catch (Exception e)
+            {
+                Log.Error(e.ToString());
+                return false;
+            }
+            finally
+            {
+                session?.Dispose();
+            }
+            if (response.Error != ErrorCode.ERR_Success)
+            {
+                return false;
+            }
+            List<NoticeInfo> noticeInfos = new List<NoticeInfo>();
+            for (int i = 0; i < response.NoticeIdList.Count; i++)
+            {
+                NoticeInfo noticeInfo = new NoticeInfo();
+                noticeInfos.Add(noticeInfo);
+            }
+            // NoticeDataManager.Instance.UpdateNoticeIdList(noticeInfos);
+            return true;
         }
+        public static async ETTask<bool> ReqSystemNotice(int noticeId)
+        {
+            N2C_GetSystemNotice response = null;
+            Session session = null;
+            try
+            {
+                session = GameGlobal.zoneScene.GetComponent<NetKcpComponent>().Create(NetworkHelper.ToIPEndPoint(GameGlobal.noticeAddress));
+                response = (N2C_GetSystemNotice)await session.Call(new C2N_GetSystemNotice() { NoticeId = noticeId });
+            }
+            catch (Exception e)
+            {
+                Log.Error(e.ToString());
+                return false;
+            }
+            finally
+            {
+                session?.Dispose();
+            }
+            if (response.Error != ErrorCode.ERR_Success)
+            {
+                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;
+
+            return true;
+        }
+
     }
 }

+ 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 = "公 告";
-            _ui.m_txtContent.text = "玩命开发中,敬请期待!";
+            _ui.m_txtTitle.text = NoticeDataManager.Instance.noticeInfo.title;
+            _ui.m_txtContent.text = NoticeDataManager.Instance.noticeInfo.context;
         }
 
         protected override void OnShown()

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

@@ -34,11 +34,14 @@ namespace GFGGame
             _ui.m_listActivity.onClick.Add(OnListActivityClick);
 
             _ui.m_listNotice.itemRenderer = ListNoticeItemRender;
+
+            _ui.m_c1.onChanged.Add(OnCtrlChange);
         }
 
         protected override void OnShown()
         {
             base.OnShown();
+            _ui.m_c1.selectedIndex = 1;
             _ui.m_listActivity.visible = true;
             _ui.m_listNotice.visible = true;
         }
@@ -47,6 +50,18 @@ namespace GFGGame
         {
             base.OnHide();
         }
+        private void OnCtrlChange()
+        {
+            if (_ui.m_c1.selectedIndex == 0)
+            {
+
+            }
+            else if (_ui.m_c1.selectedIndex == 1)
+            {
+                _ui.m_listNotice.numItems = NoticeDataManager.Instance.NoticeIdList.Count;
+                _ui.m_txtTips.visible = _ui.m_listNotice.numItems == 0;
+            }
+        }
 
         private void ListActivityItemRender(int index, GObject obj)
         {
@@ -66,6 +81,7 @@ namespace GFGGame
         private void ListNoticeItemRender(int index, GObject obj)
         {
             UI_ListNoticeItem item = UI_ListNoticeItem.Proxy(obj);
+            // item.m_txtTitle.text =
             if (item.m_btnGo.data == null)
             {
 

BIN
GameClient/Assets/ResIn/UI/Login/Login_fui.bytes


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