1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- 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 = TaskActiveRewardCfgArray.Instance.GetCfgsByfuncType(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 = TaskActiveRewardCfgArray.Instance.GetCfg(t.Key);
- if (cfg == null) continue;
- if (taskFuncType != 0 && cfg.funcType != taskFuncType) continue;
- return true;
- }
- }
- return false;
- }
- }
- }
|