FieldDataManager.cs 2.5 KB

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