| using System; | 
| using System.Collections; | 
| using System.Collections.Generic; | 
| using UnityEngine; | 
| using LitJson; | 
| using System.Text.RegularExpressions; | 
| using System.Text; | 
| using UnityEngine.Events; | 
| //任务信息的存储 | 
|   | 
| /** 任务结构 */ | 
| public class TaskDetailDates | 
| { | 
|     public int TaskGroup;    // 任务组,0-主线 | 
|     public int TaskID;        // 当前任务ID,可能为0,表示该分组暂时没有任务 | 
|     public int CurValue;        // 当前进度值 | 
|     public int State;        // 任务状态 1-进行中 2-可领取 | 
| } | 
|   | 
| public enum TaskTypenum//任务类型分类 | 
| { | 
|     MainlineTaskType = 0,//主线 | 
|     SideQuestsType = 1,//支线 | 
|   | 
| } | 
|   | 
| public class TaskManager : GameSystemManager<TaskManager> | 
| { | 
|     //任务组:任务信息;只有任务包没有删除包,可以认为一个任务组只有一个任务 | 
|     //public Dictionary<int, TaskDetailDates> allMissionDict = new Dictionary<int, TaskDetailDates>(); | 
|     //主线任务,暂且只处理主线任务 | 
|     public TaskDetailDates mainTask = new TaskDetailDates(); | 
|     public event Action OnTaskUpdate; | 
|     public event Action OnTaskClick; | 
|     public override void Init() | 
|     { | 
|         DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize; | 
|   | 
|     } | 
|   | 
|     public override void Release() | 
|     { | 
|         DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize; | 
|     } | 
|   | 
|     public void OnBeforePlayerDataInitialize() | 
|     { | 
|         mainTask = new TaskDetailDates(); | 
|     } | 
|   | 
|   | 
|     public void UpdateTask(HB110_tagMCTaskInfo netPack) | 
|     { | 
|         for (int i = 0; i < netPack.TaskList.Length; i++) | 
|         { | 
|             if (netPack.TaskList[i].TaskGroup == 0) | 
|             { | 
|                 mainTask.TaskGroup = netPack.TaskList[i].TaskGroup; | 
|                 mainTask.TaskID = (int)netPack.TaskList[i].TaskID; | 
|                 mainTask.CurValue = (int)netPack.TaskList[i].CurValue; | 
|                 mainTask.State = netPack.TaskList[i].State; | 
|                 break; | 
|             } | 
|         } | 
|   | 
|         OnTaskUpdate?.Invoke(); | 
|   | 
|     } | 
|   | 
|     public void ClickTask() | 
|     { | 
|         OnTaskClick?.Invoke(); | 
|     } | 
|   | 
|     // 任务状态 1-进行中 2-可领取 | 
|     public int GetMainTaskState() | 
|     { | 
|         return mainTask.State; | 
|     } | 
|   | 
|     //还需完成多少个任务 | 
|     public int GetNeedFinishTaskCount(int taskID) | 
|     { | 
|         var taskConfig = TaskConfig.Get(taskID); | 
|         return taskConfig.Index - TaskConfig.Get(mainTask.TaskID).Index + 1; | 
|     } | 
|   | 
|     public int GetMainTaskType() | 
|     { | 
|         if (mainTask.TaskID == 0) | 
|             return 0; | 
|         var taskConfig = TaskConfig.Get(mainTask.TaskID); | 
|         return taskConfig.TaskType; | 
|     } | 
| } |