Browse Source

添加内网显示服务器时间

zhangyuqian 1 year ago
parent
commit
5a25ab9459

+ 3 - 0
GameClient/Assets/Game/HotUpdate/FairyGUI/GenCode/Main/UI_MainUI.cs

@@ -32,6 +32,7 @@ namespace UI.Main
         public UI_BtnModle m_btnGiftBag1;
         public UI_BtnModle m_btnGiftBag2;
         public GGroup m_grpLeft;
+        public GTextField m_serverTime;
         public GGroup m_grpMove;
         public GLoader m_loaGuidestudio;
         public Transition m_openViewAction;
@@ -107,6 +108,7 @@ namespace UI.Main
             m_btnGiftBag1 = (UI_BtnModle)UI_BtnModle.Create(comp.GetChild("btnGiftBag1"));
             m_btnGiftBag2 = (UI_BtnModle)UI_BtnModle.Create(comp.GetChild("btnGiftBag2"));
             m_grpLeft = (GGroup)comp.GetChild("grpLeft");
+            m_serverTime = (GTextField)comp.GetChild("serverTime");
             m_grpMove = (GGroup)comp.GetChild("grpMove");
             m_loaGuidestudio = (GLoader)comp.GetChild("loaGuidestudio");
             m_openViewAction = comp.GetTransition("openViewAction");
@@ -155,6 +157,7 @@ namespace UI.Main
             m_btnGiftBag2.Dispose();
             m_btnGiftBag2 = null;
             m_grpLeft = null;
+            m_serverTime = null;
             m_grpMove = null;
             m_loaGuidestudio = null;
             m_openViewAction = null;

+ 22 - 0
GameClient/Assets/Game/HotUpdate/Views/MainUI/MainUIView.cs

@@ -6,6 +6,7 @@ using ET;
 using System.Linq;
 using Assets.Game.HotUpdate.Data;
 using System.Collections;
+using System;
 
 namespace GFGGame
 {
@@ -17,6 +18,8 @@ namespace GFGGame
         private SwipeGesture swipeGesture;
         private const int swipeDistance = 100;
         private bool isOpen = false;
+        DateTime dateTime;
+        DateTime unixStartTime;
 
 
         private List<AdCfg> _adIds = new List<AdCfg>();
@@ -140,6 +143,8 @@ namespace GFGGame
             _ui.m_btnChange.target.selected = true;
 
             firstIn = true;
+            //这个是东8时区的0时间戳
+            unixStartTime = new DateTime(1970, 1, 1, 8, 0, 0);
         }
 
         protected override void AddEventListener()
@@ -214,6 +219,16 @@ namespace GFGGame
             }
 
             //StorageSProxy.ReqSetClientValue(1012, 4).Coroutine();
+            // 临时设置内网显示时间
+            if (LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL)
+            {
+                _ui.m_serverTime.visible = true;
+                Timers.inst.AddUpdate(ServerTimeUpdate);
+            }
+            else
+            {
+                _ui.m_serverTime.visible = false;
+            }
         }
 
         protected override void OnHide()
@@ -229,6 +244,7 @@ namespace GFGGame
             Timers.inst.Remove(CheckGuide);
             Timers.inst.Remove(UpdateAdListTime);
             Timers.inst.Remove(OnShowLater);
+            Timers.inst.Remove(ServerTimeUpdate);
         }
 
         private void OnShowLater(object param)
@@ -1071,5 +1087,11 @@ namespace GFGGame
             AutoShowCompleted = true;
         }
 
+        private void ServerTimeUpdate(object param = null)
+        {
+                dateTime = unixStartTime.AddMilliseconds(TimeHelper.ServerNow());
+                _ui.m_serverTime.text = string.Format("服务器时间:{0}", dateTime);
+        }
+
     }
 }

BIN
GameClient/Assets/ResIn/UI/Main/Main_fui.bytes