| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using System.Collections.Generic;
- using System.Linq;
- using ET;
- namespace GFGGame
- {
- public class DailyTaskDataManager : SingletonBase<DailyTaskDataManager>
- {
- private Dictionary<int, int> _livenessBoxInfos = new Dictionary<int, int>();
- public void Clear()
- {
- _livenessBoxInfos.Clear();
- }
- public void UpdateLivenessBoxInfo(int boxId, int state)
- {
- if (!_livenessBoxInfos.ContainsKey(boxId))
- {
- _livenessBoxInfos.Add(boxId, state);
- }
- else
- {
- _livenessBoxInfos[boxId] = state;
- }
- }
- /// <summary>
- /// 根据宝箱id获取宝箱状态
- /// </summary>0不可领取,1可领取,2已领取
- /// <param name="boxId"></param>
- /// <returns></returns>
- public int GetBoxStateById(int boxId)
- {
- _livenessBoxInfos.TryGetValue(boxId, out var state);
- return state;
- }
- /// <summary>
- /// 获取下一个奖励宝箱的活跃度
- /// </summary>
- /// <returns></returns>
- public int GetShowLivenessBoxNum(int taskFuncType)
- {
- var cfgs = CommonDataManager.Tables.TblTaskActiveRewardCfg.GetGroup1ByFuncType(taskFuncType);
- foreach (var t in cfgs)
- {
- if (!_livenessBoxInfos.ContainsKey(t.Id) || _livenessBoxInfos[t.Id] != ConstBonusStatus.GOT)
- {
- return t.Count;
- }
- }
- var index = cfgs.Count - 1;
- return cfgs[index].Count;
- }
- public bool GetHadGetRewardNum(int taskFuncType)
- {
- foreach (var t in _livenessBoxInfos)
- {
- if (t.Value == ConstBonusStatus.CAN_GET)
- {
- var cfg = CommonDataManager.Tables.TblTaskActiveRewardCfg.DataList.Where(a => a.FuncType == t.Key)
- .ToList()[0];
- if (cfg == null) continue;
- if (taskFuncType != 0 && cfg.FuncType != taskFuncType) continue;
- return true;
- }
- }
- return false;
- }
- }
- }
|