Quellcode durchsuchen

更新UI适配顶部距离根据UI缩放比例进行变化;
新增活动红点判断,实现活动红点实时刷新

leiyasi vor 1 Jahr
Ursprung
Commit
658a4e9dda

+ 1 - 0
GameClient/Assets/Game/HotUpdate/Constant/ConstMessage.cs

@@ -83,6 +83,7 @@ namespace GFGGame
 
         public const string FINSH_GUIDE_INDEX = "FINSH_GUIDE_INDEX"; //完成一步引导
         public const string RED_CHANGE = "RED_CHANGE"; //红点变化,新增或删除
+        public const string ACTIVITY_RED_CHANGE = "ACTIVITY_RED_CHANGE"; //红点变化,新增或删除
 
         public const string FRIEND_REFRESH = "FRIEND_REFRESH"; //刷新好友列表
         public const string FRIEND_ADD = "FRIEND_ADD"; //新增好友

+ 10 - 3
GameClient/Assets/Game/HotUpdate/Controller/RedDotController.cs

@@ -16,7 +16,7 @@ namespace GFGGame
             }
             comRedDotPool.Clear();
         }
-        public void SetComRedDot(GComponent parentCom, bool isRed, string res = "", int left = 0, int top = 0)
+        public void SetComRedDot(GComponent parentCom, bool isRed, string res = "", int left = 0, int top = 0, bool dispatchEvent = true)
         {
             GComponent comRedDot;
 
@@ -47,7 +47,11 @@ namespace GFGGame
                 string path = ResPathUtil.GetCommonGameResPath(res == "" ? "zx_hogndian" : res);
                 GLoader loaIcon = comRedDot.GetChild("loaIcon").asLoader;
                 loaIcon.url = path;
-                EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
+
+                if (dispatchEvent)
+                {
+                    EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
+                }
             }
             else
             {
@@ -56,7 +60,10 @@ namespace GFGGame
                     comRedDot = parentCom.GetChild("comResDot").asCom;
                     comRedDotPool.Add(comRedDot);
                     parentCom.RemoveChild(comRedDot);
-                    EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
+                    if (dispatchEvent)
+                    {
+                        EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
+                    }
 
                 }
             }

+ 2 - 9
GameClient/Assets/Game/HotUpdate/Data/ActivityDataManager.cs

@@ -29,15 +29,8 @@ namespace GFGGame
         /// <returns></returns>
         public int GetCurOpenActiveByType(int type)
         {
-            List<ActivityOpenCfg> activityOpenCfgs = ActivityOpenCfgArray.Instance.GetCfgsBytype(type);
-            for (int i = 0; i < activityOpenCfgs.Count; i++)
-            {
-                if (TimeUtil.IsBeforeCurTime(activityOpenCfgs[i].openTime) && TimeUtil.IsLaterCurTime(activityOpenCfgs[i].endTime))
-                {
-                    return activityOpenCfgs[i].id;
-                }
-            }
-            return 0;
+            ActivityInfo info = ActivityGlobalDataManager.Instance.GetActivityInfoOneByType(type);
+            return (info == null) ? 0 : info.ActivityId;
         }
         /**********************************************************活动弹窗*************************************************/
         public int todayActivityTips = 0;

+ 47 - 0
GameClient/Assets/Game/HotUpdate/Data/ActivityFYJYDataManager.cs

@@ -0,0 +1,47 @@
+using ET;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace GFGGame
+{
+    public class ActivityFYJYDataManager:SingletonBase<ActivityFYJYDataManager>
+    {
+        public List<GameInfoProto> gameinfoList = new List<GameInfoProto>();
+
+        public bool CheckOpen()
+        {
+            return (ActivityDataManager.Instance.GetCurOpenActiveByType(ActivityType.AfternoonLeisure) > 0);
+        }
+
+        public bool CheckRed()
+        {
+            if (ActivityDataManager.Instance.GetCurOpenActiveByType(ActivityType.AfternoonLeisure) == 0)
+            {
+                return false;
+            }
+            RoleLimitData limitData;
+            limitData = RoleLimitDataManager.GetLimitData(300);
+            int times = limitData.TotalPlayMax - limitData.PlayTimes;
+            if (times > 0)
+            {
+                //当有关卡没通过时
+                for (int i = 0; i < gameinfoList.Count; i++)
+                {
+                    if (gameinfoList[i].GameType == 3)
+                    {
+                        if (!gameinfoList[i].IsCleared)
+                        {
+                            return true;
+                        }
+                    }
+                }
+                return false;
+            }
+            else
+            {
+                return false;
+            }
+        }
+    }
+}

+ 11 - 0
GameClient/Assets/Game/HotUpdate/Data/ActivityFYJYDataManager.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 449b8608052a06643955664ef23ffb43
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Data/RedDotDataManager.cs

@@ -1091,7 +1091,7 @@ namespace GFGGame
 
         public bool GetActivityFYJYRed()
         {
-            return ActivityTeaDataManager.Instance.CheckHRDRed();
+            return ActivityFYJYDataManager.Instance.CheckRed();
         }
 
         /// <summary>

+ 2 - 1
GameClient/Assets/Game/HotUpdate/ServerProxy/ActivityFYJYProxy.cs

@@ -15,7 +15,8 @@ namespace GFGGame
 
             var response = (S2C_GetActivityGameInfos)await MessageHelper.SendToServer(new C2S_GetActivityGameInfos { ActivityId = activityId });
             if (!(response is { Error: ErrorCode.ERR_Success })) return false;
-            
+
+            ActivityFYJYDataManager.Instance.gameinfoList = response.GameInfoList;
             return true;
         }
     }

+ 17 - 2
GameClient/Assets/Game/HotUpdate/Views/ActivityHuaRongDao/ActivityHuaRongDaoEntryView.cs

@@ -58,11 +58,13 @@ namespace GFGGame
             _ui.m_activityID.selectedPage = _activityID.ToString();
             isReturnView = _ui.m_btnBack.touchable;
 
-            await InitInfo();
+            await UpdateUIAsync();
+
             if (!isShowing)
             {
                 return;
             }
+
             _ui.m_show.Play();
             UpdateTime(null);
             Timers.inst.Remove(UpdateTime);
@@ -108,7 +110,14 @@ namespace GFGGame
 
         private void UpdateUI()
         {
-            InitInfo();
+            UpdateUIAsync();
+        }
+
+        private async Task<bool> UpdateUIAsync()
+        {
+            await InitInfo();
+            UpdateRedDots();
+            return true;
         }
 
         private async Task InitInfo()
@@ -242,5 +251,11 @@ namespace GFGGame
                 _ui.m_txtTime.text = "剩余" + TimeUtil.FormattingTimeTo_DDHHmm(endTime - curTime);
             }
         }
+
+        private void UpdateRedDots()
+        {
+            RedDotController.Instance.SetComRedDot(_ui.m_btnStart, RedDotDataManager.Instance.GetActivityFYJYRed(), "", -16, -8, false);
+            EventAgent.DispatchEvent(ConstMessage.ACTIVITY_RED_CHANGE, ActivityType.AfternoonLeisure);
+        }
     }
 }

+ 28 - 2
GameClient/Assets/Game/HotUpdate/Views/MainUI/MainUIView.cs

@@ -157,6 +157,7 @@ namespace GFGGame
             EventAgent.AddEventListener(ConstMessage.VIEW_CLOSED, CheckAutoShowViews);
             EventAgent.AddEventListener(ConstMessage.AFTER_DATA_INITED, OnAfterDataInited);
             EventAgent.AddEventListener(ConstMessage.NEW_YEAR_RED_ENVELOPE_INFO, RefreshBtnNewYearRedEnvelope);
+            EventAgent.AddEventListener(ConstMessage.ACTIVITY_RED_CHANGE, UpdateActivityRedDot);
         }
 
         protected override void RemoveEventListener()
@@ -170,6 +171,7 @@ namespace GFGGame
             EventAgent.RemoveEventListener(ConstMessage.VIEW_CLOSED, CheckAutoShowViews);
             EventAgent.RemoveEventListener(ConstMessage.AFTER_DATA_INITED, OnAfterDataInited);
             EventAgent.RemoveEventListener(ConstMessage.NEW_YEAR_RED_ENVELOPE_INFO, RefreshBtnNewYearRedEnvelope);
+            EventAgent.RemoveEventListener(ConstMessage.ACTIVITY_RED_CHANGE, UpdateActivityRedDot);
         }
 
         protected override void OnShown()
@@ -258,15 +260,15 @@ namespace GFGGame
         private void OnAfterDataInited()
         {
             GetAdIds();
+            UpdateButtons();
             OnRedDotChanged();
             CheckAutoShowViews();
-            UpdateButtons();
         }
 
         private async void UpdateButtons()
         {
             // 刚进游戏请求数据
-            if (!MainDataManager.Instance.needUpdateProxyData)
+            if (MainDataManager.Instance.needUpdateProxyData)
             {
                 MainDataManager.Instance.needUpdateProxyData = false;
                 var result = await NewYearRedEnvelopeSProxy.ReqGetRedPacketInfo();
@@ -285,6 +287,11 @@ namespace GFGGame
                 if (result)
                 {
                     RefreshBtnActivityFYJY();
+                    if (_ui.m_btnActivityFYJY.target.visible)
+                    {
+                        RedDotController.Instance.SetComRedDot(_ui.m_btnActivityFYJY.target
+    , RedDotDataManager.Instance.GetActivityFYJYRed(), "", -15, -1);
+                    }
                 }
             }
             // 后续活动按钮的刷新检测
@@ -926,6 +933,7 @@ namespace GFGGame
             //LogUtil.LogEditor($"MainUIView OnRedDotChanged GameGlobal.AfterDataInited {GameGlobal.AfterDataInited} AutoShowCompleted {GameGlobal.AutoShowCompleted}");
             //暂时用这种方法优化下,红点的实现要重构!!!
             //LogUtil.LogEditor("MainUIView UpdateRedDot OnRedDotChanged");
+            
             redPointUpdateFrame = 0;
         }
 
@@ -1064,6 +1072,24 @@ namespace GFGGame
             }
         }
 
+        /// <summary>
+        /// 刷新指定活动的红点
+        /// </summary>
+        /// <param name="context"></param>
+        private void UpdateActivityRedDot(EventContext context)
+        {
+            int activityType = (int)context.data;
+            switch (activityType)
+            {
+                case ActivityType.AfternoonLeisure:
+                    if (_ui.m_btnActivityFYJY.target.visible)
+                    {
+                        RedDotController.Instance.SetComRedDot(_ui.m_btnActivityFYJY.target, RedDotDataManager.Instance.GetActivityFYJYRed(), "", -15, -1);
+                    }
+                    break;
+            }
+        }
+
         private void CheckProbabilityUp()
         {
             //long curTime = TimeHelper.ServerNow();

+ 5 - 2
GameClient/Assets/Game/HotUpdate/Views/ViewGlobal.cs

@@ -38,8 +38,11 @@ namespace GFGGame
         /// <returns></returns>
         static float GetTopOffset()
         {
-            int designOffset = ((Screen.safeArea.height + Screen.safeArea.y) == Screen.height ? 0 : 80);
-            Debug.Log(Screen.height - Screen.safeArea.height - Screen.safeArea.y);
+            // 标准分辨率下 设计图顶部留了80像素的偏移
+            int designOffset = ((Screen.safeArea.height + Screen.safeArea.y) 
+                == Screen.height ? 0 : (int)Mathf.Round(80 * UIContentScaler.scaleFactor));
+            
+            // 设置最低偏移是设计图顶部的偏移量
             return Mathf.Max(0, Screen.height - Screen.safeArea.height - Screen.safeArea.y - designOffset);
         }