DailyTaskDataManager.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 = TaskActiveRewardCfgArray.Instance.GetCfgsByfuncType(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 = TaskActiveRewardCfgArray.Instance.GetCfg(t.Key);
  58. if (cfg == null) continue;
  59. if (taskFuncType != 0 && cfg.funcType != taskFuncType) continue;
  60. return true;
  61. }
  62. }
  63. return false;
  64. }
  65. }
  66. }