Jae 2 жил өмнө
parent
commit
b0fb311312

+ 8 - 5
GameClient/Assets/Game/HotUpdate/Data/ActivityDay7DataManager.cs

@@ -6,7 +6,9 @@ namespace GFGGame
     {
         public int GetActivityDay7Day()
         {
-            return GameGlobal.myNumericComponent.GetAsInt(NumericType.Day7Activity);
+            //获取7日任务活动
+            var activityInfo = ActivityGlobalDataManager.Instance.GetActivityInfoOneByType(ActivityType.Day7);
+            return activityInfo == null ? 0 : TimeUtil.GetDayByTime(activityInfo.StartTime, activityInfo.EndTime);
         }
 
         public long GetScore()
@@ -23,14 +25,15 @@ namespace GFGGame
 
         public bool CheckOpen()
         {
-            return GetEndTime() > TimeHelper.ServerNow();
+            var activityInfo = ActivityGlobalDataManager.Instance.GetActivityInfoOneByType(ActivityType.Day7);
+            return activityInfo != null && activityInfo.StartTime <= TimeHelper.ServerNow() &&
+                   activityInfo.EndTime > TimeHelper.ServerNow();
         }
 
         public long GetEndTime()
         {
-            return TimeUtil.TodayRestTime() +
-                   (GlobalCfgArray.globalCfg.Activity7DaysLastTime - GetActivityDay7Day() + 1)
-                   * TimeUtil.SECOND_PER_DAY * 1000;
+            var activityInfo = ActivityGlobalDataManager.Instance.GetActivityInfoOneByType(ActivityType.Day7);
+            return activityInfo.EndTime;
         }
     }
 }

+ 8 - 0
GameClient/Assets/Game/HotUpdate/Data/ActivityGlobalDataManager.cs

@@ -96,6 +96,14 @@ namespace GFGGame
             return activityInfoIds.Select(GetActivityInfo).Where(activityInfo => activityInfo != null).ToList();
         }
 
+        //获取活动数据根据类型
+        public ActivityInfo GetActivityInfoOneByType(int activityType)
+        {
+            var activityInfoIds = GetActivityInfoIdsByType(activityType);
+            return activityInfoIds.Select(GetActivityInfo).FirstOrDefault(activityInfo =>
+                activityInfo != null && activityInfo.EndTime <= TimeHelper.ServerNow());
+        }
+
         //添加活动奖励获取数据
         public void AddActivityRewardInfo(int activityId, int rewardId)
         {

+ 21 - 3
GameClient/Assets/Game/HotUpdate/Data/TaskDataManager.cs

@@ -54,6 +54,24 @@ namespace GFGGame
             }
         }
 
+        //RemoveTaskInfo
+        public void RemoveTaskInfo(int taskId)
+        {
+            TaskInfosDic.Remove(taskId);
+            //获取任务配置
+            var cfg = TaskCfgArray.Instance.GetCfg(taskId);
+            if (cfg == null)
+            {
+                Log.Error($"出现了没有配置的任务id{taskId}");
+                return;
+            }
+            var taskType = cfg.taskType;
+            TaskType2TaskIdListDic.TryGetValue(taskType, out var taskIds);
+            if (taskIds == null) return;
+            taskIds.Remove(taskId);
+            if (taskIds.Count == 0) TaskType2TaskIdListDic.Remove(taskType);
+        }
+
         public void UpdateTaskState(int taskId, int state)
         {
             TaskInfosDic.TryGetValue(taskId, out var taskInfo);
@@ -153,9 +171,9 @@ namespace GFGGame
                     return string.Format(activeRewardCfg.desc, taskCfg.paramsArr[0], taskCfg.paramsArr[1]);
                 case ConstTaskType.FinishStory:
                 case ConstTaskType.FinishInstanceZones:
-                    {
-                        return string.Format(activeRewardCfg.desc, taskCfg.paramsArr[0]);
-                    }
+                {
+                    return string.Format(activeRewardCfg.desc, taskCfg.paramsArr[0]);
+                }
                 default: return string.Format(activeRewardCfg.desc, taskCfg.GetTargetCount());
             }
         }

+ 11 - 1
GameClient/Assets/Game/HotUpdate/ServerProxy/TaskSProxy.cs

@@ -9,7 +9,6 @@ namespace ET
     {
         protected override async ETTask Run(Session session, M2C_TaskInfoChange message)
         {
-            // Log.Info($"M2C_TaskInfoChangeHandler");
             var taskInfo = new TaskInfo
             {
                 ID = message.TaskInfo.Id,
@@ -21,6 +20,17 @@ namespace ET
             await ETTask.CompletedTask;
         }
     }
+
+    //M2C_TaskClose
+    public class M2C_TaskCloseHandler : AMHandler<M2C_TaskClose>
+    {
+        protected override async ETTask Run(Session session, M2C_TaskClose message)
+        {
+            TaskDataManager.Instance.RemoveTaskInfo(message.TaskId);
+            EventAgent.DispatchEvent(ConstMessage.NOTICE_TASK_STATE_CHANGE, message.TaskId);
+            await ETTask.CompletedTask;
+        }
+    }
 }
 
 namespace GFGGame