1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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 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();
 
    }
 
    // 任务状态 1-进行中 2-可领取
    public int GetMainTaskState()
    { 
        return mainTask.State;
    }
 
 
}