FieldDataManager.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. using System.Collections.Generic;
  2. namespace GFGGame
  3. {
  4. public struct FieldInfos
  5. {
  6. /// <summary>
  7. /// 当前主题 由ConstItemAttributeType定义
  8. /// </summary>
  9. public int theme;
  10. /// <summary>
  11. /// 最高关卡记录列表,由简单到难
  12. /// </summary>
  13. public List<int> highestLvls;
  14. /// <summary>
  15. /// 每周已领奖励
  16. /// </summary>
  17. public int bonusWeekly;
  18. /// <summary>
  19. /// 奖励上限
  20. /// </summary>
  21. public int bonusMaxLimit;
  22. /// <summary>
  23. /// 任务奖励状态 由ConstBonusStatus定义
  24. /// </summary>
  25. public Dictionary<int, int> taskDic;
  26. /// <summary>
  27. /// 仅在上线时判断是否有奖励未结算
  28. /// </summary>
  29. public bool hasBonus;
  30. };
  31. public struct FieldResult
  32. {
  33. /// <summary>
  34. /// 完成关数
  35. /// </summary>
  36. public int passLvl;
  37. /// <summary>
  38. /// 奖励列表
  39. /// </summary>
  40. public List<ItemData> bonusList;
  41. /// <summary>
  42. /// 体力消耗
  43. /// </summary>
  44. public int costNum;
  45. /// <summary>
  46. /// 难度,由ConstInstanceZonesSubType定义
  47. /// </summary>
  48. public int hardLvl;
  49. }
  50. public class FieldDataManager : SingletonBase<FieldDataManager>
  51. {
  52. // private int _theme = 1; //当前主题 由ConstItemAttributeType定义
  53. // /// <summary>
  54. // /// 本期主题
  55. // /// </summary>
  56. // public int Theme
  57. // {
  58. // get { return _theme; }
  59. // set { _theme = value; }
  60. // }
  61. // private int _bonusWeekly = 0;//每周已领奖励
  62. // /// <summary>
  63. // /// 每周已领奖励
  64. // /// </summary>
  65. // /// <value></value>
  66. // public int BonusWeekly
  67. // {
  68. // get { return _bonusWeekly; }
  69. // set { _bonusWeekly = value; }
  70. // }
  71. // private int _bonusMaxLimit = 0;//奖励上限
  72. // /// <summary>
  73. // /// 奖励上限
  74. // /// </summary>
  75. // /// <value></value>
  76. // public int BonusMaxLimit
  77. // {
  78. // get { return _bonusMaxLimit; }
  79. // set { _bonusMaxLimit = value; }
  80. // }
  81. // private List<int> _highestLvls = new List<int>();//最高关卡记录列表,由简单到难
  82. // private Dictionary<int, int> _taskDic = new Dictionary<int, int>();//任务奖励状态 由ConstBonusStatus定义
  83. // private bool hasBonus = false;//仅在上线时判断是否有奖励未结算
  84. public FieldInfos fieldInfos = new FieldInfos();
  85. public FieldResult fieldResult = new FieldResult();
  86. /// <summary>
  87. /// 当前难度
  88. /// </summary>
  89. public int difficulty = 0;
  90. //当前关卡进度
  91. public int currFightIndex = 0;
  92. public void UpdateTask(int taskId, int state)
  93. {
  94. if (!fieldInfos.taskDic.ContainsKey(taskId))
  95. {
  96. fieldInfos.taskDic.Add(taskId, state);
  97. }
  98. else
  99. {
  100. fieldInfos.taskDic[taskId] = state;
  101. }
  102. }
  103. /// <summary>
  104. /// 根据挑战难度获取最高记录
  105. /// </summary>
  106. /// <param name="difficulty"></param>
  107. /// <returns></returns>
  108. public int GetHighestLvByDifficulty(int difficulty)
  109. {
  110. if (fieldInfos.highestLvls.IndexOf(difficulty) < 0)
  111. {
  112. return 0;
  113. }
  114. else
  115. {
  116. return fieldInfos.highestLvls[difficulty];
  117. }
  118. }
  119. /// <summary>
  120. /// 根据挑战难度获取副本配置
  121. /// </summary>
  122. /// <param name="difficulty"></param>
  123. /// <returns></returns>
  124. public FieldCfg GetFieldCfgByDifficulty(int difficulty)
  125. {
  126. return FieldCfgArray.Instance.GetCfgs(difficulty)[0];
  127. }
  128. /// <summary>
  129. /// 根据挑战难度获取当前战斗Id
  130. /// </summary>
  131. /// <returns></returns>
  132. public int GetLevelIdByDifficulty(int difficulty, int index)
  133. {
  134. FieldCfg cfg = GetFieldCfgByDifficulty(difficulty);
  135. return StoryLevelCfgArray.Instance.GetCfgs(cfg.type, cfg.subType, cfg.id)[index].id;
  136. }
  137. /// <summary>
  138. /// 获取任务列表
  139. /// </summary>
  140. /// <returns></returns>
  141. public List<FieldTaskCfg> GetTaskCfgs()
  142. {
  143. List<FieldTaskCfg> cfgs = new List<FieldTaskCfg>(FieldTaskCfgArray.Instance.dataArray);
  144. cfgs.Sort((FieldTaskCfg a, FieldTaskCfg b) =>
  145. {
  146. int stateA = GetTaskState(a.id);
  147. int stateB = GetTaskState(b.id);
  148. return stateA.CompareTo(stateB);
  149. });
  150. return cfgs;
  151. }
  152. /// <summary>
  153. /// 根据任务ID获取任务状态0可领取1未完成2已领取
  154. /// </summary>
  155. /// <param name="taskId"></param>
  156. /// <returns></returns>
  157. public int GetTaskState(int taskId)
  158. {
  159. return fieldInfos.taskDic.ContainsKey(taskId) ? fieldInfos.taskDic[taskId] : 1;
  160. }
  161. }
  162. }