yyl
5 小时以前 0b15db60b38265335e97f934fdcfe21f164504af
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using LitJson;
 
 
public class DailyQuestModel : GameSystemManager<DailyQuestModel>
{
    const int EVERYDAY_REDPOINTID = 78001;
    const int DAILYQUEST_REDPOINTIDBASE = 78100;
    const int ACTIVEVALUE_REDPOINT = 78004;
 
    Redpoint activeValueRedpoint = new Redpoint(EVERYDAY_REDPOINTID, ACTIVEVALUE_REDPOINT); //活跃度奖励红点
 
    int m_DailyQuestTotalActiveValue = 0;
    public int dailyQuestTotalActiveValue
    {
        get { return m_DailyQuestTotalActiveValue; }
    }
 
    Dictionary<int, DailyQuestTimes> dailyQuestTimes = new Dictionary<int, DailyQuestTimes>();//除了副本的其他任务放在这里
    Dictionary<int, int> dailyActionToDailyQuestTable = new Dictionary<int, int>();
    List<int> DailyQuestLVList = new List<int>();
    Dictionary<int, DailyQuestOpenTime> dailyQuestOpenTimes = new Dictionary<int, DailyQuestOpenTime>();
    Dictionary<int, DailyQuestData> dailyQuests = new Dictionary<int, DailyQuestData>();
    List<DailyQuestActiveValueReward> dailyQuestActiveValueRewards = new List<DailyQuestActiveValueReward>();
 
 
    int m_CurrentRewardStageIndex = 0;
    public int currentRewardStageIndex
    {
        get { return m_CurrentRewardStageIndex; }
        private set { m_CurrentRewardStageIndex = value; }
    }
 
    int m_CurrentActiveValue = 0;
    public int currentActiveValue
    {
        get { return m_CurrentActiveValue; }
        private set
        {
            if (m_CurrentActiveValue != value)
            {
                m_CurrentActiveValue = value;
 
                if (currentActiveValueUpdateEvent != null)
                {
                    currentActiveValueUpdateEvent();
                }
            }
        }
    }
 
    public event Action<int> dailyQuestProgressUpdateEvent;
    public event Action currentActiveValueUpdateEvent;
 
    public override void Init()
    {
        ParseConfig();
    }
 
    public override void Release()
    {
    }
 
    private void ParseConfig()
    {
        var allConfigs = DailyQuestConfig.GetValues();
        var redpointIndex = 1;
        foreach (var config in allConfigs)
        {
            if (VersionConfig.Get().isBanShu && config.ID == 12)
            {
                continue;
            }
 
            var openTime = default(DailyQuestOpenTime);
 
            switch (config.RelatedType)
            {
                case 1:
                    var NeedLV = GetDailyQuestLV(config.ID);
                    if (!DailyQuestLVList.Contains(NeedLV))
                    {
                        bool bIsAdd = false;
                        for (int i = 0; i < DailyQuestLVList.Count; i++)
                        {
                            if (NeedLV < DailyQuestLVList[i])
                            {
                                DailyQuestLVList.Insert(i, NeedLV);
                                bIsAdd = true;
                                break;
                            }
                        }
                        if (!bIsAdd)
                        {
                            DailyQuestLVList.Add(NeedLV);
                        }
 
                    }
 
                    var activityOpenTime = DailyQuestOpenTimeConfig.Get(config.RelatedID);
                    openTime = dailyQuestOpenTimes[config.ID] = new DailyQuestOpenTime(config.ID);
                    openTime.ParseQuestNormalOpenTime(activityOpenTime);
                    dailyActionToDailyQuestTable[config.RelatedID] = config.ID;
                    break;
                case 2:
 
                    break;
            }
 
            dailyQuests[config.ID] = new DailyQuestData(config.ID, DAILYQUEST_REDPOINTIDBASE + redpointIndex++, EVERYDAY_REDPOINTID);
        }
 
        var allRewardKeys = DailyLivenessRewardConfig.GetKeys();
        m_DailyQuestTotalActiveValue = DailyLivenessRewardConfig.Get(allRewardKeys[allRewardKeys.Count - 1]).Liveness;
 
        var values = DailyLivenessRewardConfig.GetValues();
        for (int i = 0; i < allRewardKeys.Count; i++)
        {
            var config = DailyLivenessRewardConfig.Get(allRewardKeys[i]);
            dailyQuestActiveValueRewards.Add(new DailyQuestActiveValueReward(config.id));
        }
 
        dailyQuestActiveValueRewards.Sort((x, y) => { return x.id.CompareTo(y.id); });
 
    }
 
 
 
 
    public void OnDailyQuestCompletedTimesUpdate(HA315_tagMCDailyActionCnt _serverInfo)
    {
        for (int i = 0; i < _serverInfo.Count; i++)
        {
            var dailyAction = _serverInfo.ActionInfo[i];
            if (dailyAction.DayFinishCnt > 0)
            {
                dailyQuestTimes[(int)dailyAction.ActionID] = new DailyQuestTimes()
                {
                    completeTimes = dailyAction.DayFinishCnt,
                    dayBuyTimes = dailyAction.DayBuyTimes,
                    dayUseItemTimes = dailyAction.DayItemTimes,
                };
            }
            else
            {
                dailyQuestTimes[(int)dailyAction.ActionID] = new DailyQuestTimes()
                {
                    completeTimes = (int)dailyAction.WeekFinishCnt,
                };
            }
 
            if (dailyActionToDailyQuestTable.ContainsKey((int)dailyAction.ActionID))
            {
                var dailyQuestId = dailyActionToDailyQuestTable[(int)dailyAction.ActionID];
                //UpdateDailyActionRedpoint(dailyQuestId);
            }
 
            if (dailyQuestProgressUpdateEvent != null)
            {
                dailyQuestProgressUpdateEvent((int)dailyAction.ActionID);
            }
        }
    }
 
    public int GetDailyQuestLV(int id)
    {
        var QuestConfig = DailyQuestConfig.Get(id);
        var LVConfig = FuncOpenLVConfig.Get(QuestConfig.UnLockFuncID);
        if (LVConfig == null)
        { 
            Debug.LogError($"DailyQuestConfig.Get({id}) == null");
            return 9999999;
        }
        int NeedLV = 0;
        if (LVConfig.LimitLV != 0)
        {
            NeedLV = LVConfig.LimitLV;
        }
        else if (LVConfig.LimitMissionID != 0)
        {
 
        }
        return NeedLV;
    }
 
    public void OnDailyQuestActiveValueInfoUpdate(HA333_tagMCDailyActivityInfoList _activeValueInfo)
    {
        int OldCurrentActiveValue = currentActiveValue;
        currentActiveValue = (int)_activeValueInfo.CurValue;
        currentRewardStageIndex = (int)_activeValueInfo.StageIndex;
 
        UpdateActiveValueRedpoint();
    }
    
    private void UpdateActiveValueRedpoint()
    {
        var count = dailyQuestActiveValueRewards.Count;
        var anyAwardable = false;
        for (int i = 0; i < count; i++)
        {
            var reward = dailyQuestActiveValueRewards[i];
            if (!reward.got)
            {
                var config = DailyLivenessRewardConfig.Get(reward.id);
                if (currentActiveValue >= config.Liveness)
                {
                    anyAwardable = true;
                    break;
                }
            }
        }
 
        activeValueRedpoint.state = anyAwardable ? RedPointState.Simple : RedPointState.None;
    }
 
 
}