DailyTaskDataManager.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using ET;
  4. namespace GFGGame
  5. {
  6. public class DailyTaskDataManager : SingletonBase<DailyTaskDataManager>
  7. {
  8. private Dictionary<int, int> _livenessBoxInfos = new Dictionary<int, int>();
  9. public void Clear()
  10. {
  11. _livenessBoxInfos.Clear();
  12. }
  13. public void UpdateLivenessBoxInfo(int boxId, int state)
  14. {
  15. if (!_livenessBoxInfos.ContainsKey(boxId))
  16. {
  17. _livenessBoxInfos.Add(boxId, state);
  18. }
  19. else
  20. {
  21. _livenessBoxInfos[boxId] = state;
  22. }
  23. }
  24. /// <summary>
  25. /// 根据宝箱id获取宝箱状态
  26. /// </summary>0不可领取,1可领取,2已领取
  27. /// <param name="boxId"></param>
  28. /// <returns></returns>
  29. public int GetBoxStateById(int boxId)
  30. {
  31. _livenessBoxInfos.TryGetValue(boxId, out var state);
  32. return state;
  33. }
  34. /// <summary>
  35. /// 获取下一个奖励宝箱的活跃度
  36. /// </summary>
  37. /// <returns></returns>
  38. public int GetShowLivenessBoxNum(int taskFuncType)
  39. {
  40. var cfgs = CommonDataManager.Tables.TblTaskActiveRewardCfg.GetGroup1ByFuncType(taskFuncType);
  41. foreach (var t in cfgs)
  42. {
  43. if (!_livenessBoxInfos.ContainsKey(t.Id) || _livenessBoxInfos[t.Id] != ConstBonusStatus.GOT)
  44. {
  45. return t.Count;
  46. }
  47. }
  48. var index = cfgs.Count - 1;
  49. return cfgs[index].Count;
  50. }
  51. public bool GetHadGetRewardNum(int taskFuncType)
  52. {
  53. foreach (var t in _livenessBoxInfos)
  54. {
  55. if (t.Value == ConstBonusStatus.CAN_GET)
  56. {
  57. var cfg = CommonDataManager.Tables.TblTaskActiveRewardCfg.DataList.Where(a => a.FuncType == t.Key)
  58. .ToList()[0];
  59. if (cfg == null) continue;
  60. if (taskFuncType != 0 && cfg.FuncType != taskFuncType) continue;
  61. return true;
  62. }
  63. }
  64. return false;
  65. }
  66. }
  67. }