Browse Source

任务红点

zhaoyang 3 năm trước cách đây
mục cha
commit
85a3f9f55f

+ 22 - 4
GameClient/Assets/Game/HotUpdate/Controller/RedDotController.cs

@@ -1,16 +1,29 @@
 
 
+using System.Collections.Generic;
 using FairyGUI;
 using FairyGUI;
 
 
 namespace GFGGame
 namespace GFGGame
 {
 {
     public class RedDotController : SingletonBase<RedDotController>
     public class RedDotController : SingletonBase<RedDotController>
     {
     {
+        private List<GComponent> comRedDotPool = new List<GComponent>();
+
         public void SetComRedDot(GComponent parentCom, bool isRed)
         public void SetComRedDot(GComponent parentCom, bool isRed)
         {
         {
             GComponent comRedDot;
             GComponent comRedDot;
-            if (parentCom.GetChild("comResDot") == null)
+
+            if (isRed)
             {
             {
-                comRedDot = UIPackage.CreateObject("CommonGame", "ComRedDot").asCom;
+                if (parentCom.GetChild("comResDot") != null) return;
+                if (comRedDotPool.Count > 0)
+                {
+                    comRedDot = comRedDotPool[0];
+                    comRedDotPool.RemoveAt(0);
+                }
+                else
+                {
+                    comRedDot = UIPackage.CreateObject("CommonGame", "ComRedDot").asCom;
+                }
                 parentCom.AddChild(comRedDot);
                 parentCom.AddChild(comRedDot);
                 comRedDot.name = "comResDot";
                 comRedDot.name = "comResDot";
                 comRedDot.SetPosition(parentCom.width - comRedDot.width, 0, 0);
                 comRedDot.SetPosition(parentCom.width - comRedDot.width, 0, 0);
@@ -19,9 +32,14 @@ namespace GFGGame
             }
             }
             else
             else
             {
             {
-                comRedDot = parentCom.GetChild("comResDot").asCom;
+                if (parentCom.GetChild("comResDot") != null)
+                {
+                    comRedDot = parentCom.GetChild("comResDot").asCom;
+                    comRedDotPool.Add(comRedDot);
+                    parentCom.RemoveChild(comRedDot);
+                }
             }
             }
-            comRedDot.visible = isRed;
         }
         }
+
     }
     }
 }
 }

+ 16 - 2
GameClient/Assets/Game/HotUpdate/Data/DailyTaskDataManager.cs

@@ -12,8 +12,22 @@ namespace GFGGame
     public class DailyTaskDataManager : SingletonBase<DailyTaskDataManager>
     public class DailyTaskDataManager : SingletonBase<DailyTaskDataManager>
     {
     {
         private Dictionary<int, TaskInfo> _taskInfos = new Dictionary<int, TaskInfo>();
         private Dictionary<int, TaskInfo> _taskInfos = new Dictionary<int, TaskInfo>();
-        private Dictionary<int, int> _livenessBoxInfos = new Dictionary<int, int>();
+        public Dictionary<int, TaskInfo> TaskInfo
+        {
+            get
+            {
+                return _taskInfos;
+            }
+        }
 
 
+        private Dictionary<int, int> _livenessBoxInfos = new Dictionary<int, int>();
+        public Dictionary<int, int> LivenessBoxInfos
+        {
+            get
+            {
+                return _livenessBoxInfos;
+            }
+        }
 
 
         public void UpdateTaskInfo(int taskId, TaskInfo info)
         public void UpdateTaskInfo(int taskId, TaskInfo info)
         {
         {
@@ -89,7 +103,7 @@ namespace GFGGame
         }
         }
         /// <summary>
         /// <summary>
         /// 根据任务id获取任务进度
         /// 根据任务id获取任务进度
-        /// </summary>0未完成,1可领取,2已领取
+        /// </summary>
         /// <param name="taskId"></param>
         /// <param name="taskId"></param>
         /// <returns></returns>
         /// <returns></returns>
         public int GetTaskProgressById(int taskId)
         public int GetTaskProgressById(int taskId)

+ 26 - 0
GameClient/Assets/Game/HotUpdate/Data/RedDotDataManager.cs

@@ -4,6 +4,11 @@ namespace GFGGame
 {
 {
     public class RedDotDataManager : SingletonBase<RedDotDataManager>
     public class RedDotDataManager : SingletonBase<RedDotDataManager>
     {
     {
+        /// <summary>
+        /// 公告
+        /// 是否有未读公告
+        /// </summary>
+        /// <returns></returns>
         public bool GetNoticeRed()
         public bool GetNoticeRed()
         {
         {
             List<NoticeInfo> noticeInfos = NoticeDataManager.Instance.NoticeInfos;
             List<NoticeInfo> noticeInfos = NoticeDataManager.Instance.NoticeInfos;
@@ -13,6 +18,27 @@ namespace GFGGame
             }
             }
             return false;
             return false;
         }
         }
+        /// <summary>
+        /// 任务
+        /// 是否有任务奖励、任务宝箱奖励可领
+        /// </summary>
+        /// <returns></returns>
+        public bool GetTaskRed()
+        {
+            Dictionary<int, TaskInfo> taskInfo = DailyTaskDataManager.Instance.TaskInfo;
+            foreach (int key in taskInfo.Keys)
+            {
+                if (DailyTaskDataManager.Instance.GetTaskStateById(key) == ConstBonusStatus.CAN_GET) return true;
+            }
+            Dictionary<int, int> livenessBoxInfos = DailyTaskDataManager.Instance.LivenessBoxInfos;
+            foreach (int key in livenessBoxInfos.Keys)
+            {
+                if (DailyTaskDataManager.Instance.GetBoxStateById(key) == ConstBonusStatus.CAN_GET) return true;
+            }
+            return false;
+        }
+
+
 
 
     }
     }
 }
 }

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

@@ -343,6 +343,7 @@ namespace GFGGame
         private void UpdateRedDot()
         private void UpdateRedDot()
         {
         {
             RedDotController.Instance.SetComRedDot(_btnGongGao, RedDotDataManager.Instance.GetNoticeRed());
             RedDotController.Instance.SetComRedDot(_btnGongGao, RedDotDataManager.Instance.GetNoticeRed());
+            RedDotController.Instance.SetComRedDot(_btnRenWu, RedDotDataManager.Instance.GetTaskRed());
         }
         }