using System.Collections.Generic; using System.Linq; using cfg.GfgCfg; using ET; namespace GFGGame { public class DailyTaskDataManager : SingletonBase { private Dictionary _livenessBoxInfos = new Dictionary(); public void Clear() { _livenessBoxInfos.Clear(); } public void UpdateLivenessBoxInfo(int boxId, int state) { if (!_livenessBoxInfos.ContainsKey(boxId)) { _livenessBoxInfos.Add(boxId, state); } else { _livenessBoxInfos[boxId] = state; } } /// /// 根据宝箱id获取宝箱状态 /// 0不可领取,1可领取,2已领取 /// /// public int GetBoxStateById(int boxId) { _livenessBoxInfos.TryGetValue(boxId, out var state); return state; } /// /// 获取下一个奖励宝箱的活跃度 /// /// 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 cfgs = CommonDataManager.Tables.TblTaskActiveRewardCfg.DataList.Where(a => a.FuncType == t.Key) .ToList(); if (cfgs.Count == 0) { continue; } TaskActiveRewardCfg cfg = cfgs[0]; if (cfg == null) continue; if (taskFuncType != 0 && cfg.FuncType != taskFuncType) continue; return true; } } return false; } } }