DailyTaskDataManager.cs 2.4 KB

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