FieldDataManager.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System.Collections.Generic;
  2. namespace GFGGame
  3. {
  4. public class FieldDataManager : SingletonBase<FieldDataManager>
  5. {
  6. /// <summary>
  7. /// 本期主题
  8. /// </summary>
  9. public int scoreType = 1;
  10. public Dictionary<int, int> _levelIdDic = new Dictionary<int, int>();
  11. private Dictionary<int, int> _taskDic = new Dictionary<int, int>();
  12. public void UpdateTask(int taskId, int state)
  13. {
  14. if (!_taskDic.ContainsKey(taskId))
  15. {
  16. _taskDic.Add(taskId, state);
  17. }
  18. else
  19. {
  20. _taskDic[taskId] = state;
  21. }
  22. }
  23. /// <summary>
  24. /// 根据挑战难度获取副本配置
  25. /// </summary>
  26. /// <param name="difficulty"></param>
  27. /// <returns></returns>
  28. public FieldCfg GetFieldCfgByDifficulty(int difficulty)
  29. {
  30. return FieldCfgArray.Instance.GetCfgs(difficulty)[0];
  31. }
  32. /// <summary>
  33. /// 根据挑战难度获取当前战斗Id
  34. /// </summary>
  35. /// <returns></returns>
  36. public int GetLevelIdByDifficulty(int difficulty)
  37. {
  38. if (_levelIdDic.ContainsKey(difficulty))
  39. {
  40. return _levelIdDic[difficulty];
  41. }
  42. else
  43. {
  44. FieldCfg cfg = GetFieldCfgByDifficulty(difficulty);
  45. return StoryLevelCfgArray.Instance.GetCfgs(cfg.type, cfg.subType, cfg.id)[0].id;
  46. }
  47. }
  48. /// <summary>
  49. /// 获取任务列表
  50. /// </summary>
  51. /// <returns></returns>
  52. public List<FieldTaskCfg> GetTaskCfgs()
  53. {
  54. List<FieldTaskCfg> cfgs = new List<FieldTaskCfg>(FieldTaskCfgArray.Instance.dataArray);
  55. cfgs.Sort((FieldTaskCfg a, FieldTaskCfg b) =>
  56. {
  57. int stateA = GetTaskState(a.id);
  58. int stateB = GetTaskState(b.id);
  59. return stateA.CompareTo(stateB);
  60. });
  61. return cfgs;
  62. }
  63. /// <summary>
  64. /// 根据任务ID获取任务状态0可领取1未完成2已领取
  65. /// </summary>
  66. /// <param name="taskId"></param>
  67. /// <returns></returns>
  68. public int GetTaskState(int taskId)
  69. {
  70. return _taskDic.ContainsKey(taskId) ? _taskDic[taskId] : 0;
  71. }
  72. }
  73. }