StudioDataManager.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. using System;
  2. using System.Collections.Generic;
  3. using ET;
  4. using GFGGame;
  5. namespace GFGGame
  6. {
  7. public class StudioDataManager : SingletonBase<StudioDataManager>
  8. {
  9. private Dictionary<int, StudioData> _StudioInfoById = new Dictionary<int, StudioData>();
  10. // public int TYPE_SELECT_INDEX = 0;//界面类型0无属性选择,1有属性选择
  11. public int PROPERTY_SELECT_INDEX = 0;//属性类型
  12. public string VIEW_NAME = "";//界面名称
  13. public int filingChapterId;//查阅建档当前副本Id
  14. public int npcFilingChapterId;//记录查阅建档工作室入口id,为与限时活动章节做区分。
  15. private int luckyBoxFilingChapterId;//查阅建档这个章节是限时抽奖活动专属
  16. public int PorcelainTheme = 1;//瓷器修复当天主题
  17. public List<StudioCfg> FilingDatas
  18. {
  19. get
  20. {
  21. return StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioFilingView).Name);
  22. }
  23. }
  24. public void Clear()
  25. {
  26. _StudioInfoById.Clear();
  27. }
  28. public void RspStudioInfos(StudioData studioData)
  29. {
  30. if (!_StudioInfoById.ContainsKey(studioData.ChapterId))
  31. {
  32. _StudioInfoById.Add(studioData.ChapterId, studioData);
  33. }
  34. _StudioInfoById[studioData.ChapterId] = studioData;
  35. }
  36. public void RspFilingScoreReward(int chapterId, int index)
  37. {
  38. _StudioInfoById[chapterId].RewardsStatus[index] = ConstBonusStatus.GOT;
  39. }
  40. public void NoticeFilingScoreBonusChanged(int chapterId, int chapterScore, List<int> rewardsStatus)
  41. {
  42. _StudioInfoById[chapterId].ChapterScore = chapterScore;
  43. _StudioInfoById[chapterId].RewardsStatus = rewardsStatus;
  44. }
  45. public StudioData GetStudioDataById(int id)
  46. {
  47. if (_StudioInfoById.ContainsKey(id))
  48. {
  49. return _StudioInfoById[id];
  50. }
  51. else
  52. {
  53. StudioData studioData = new StudioData() { ChapterId = id };
  54. RspStudioInfos(studioData);
  55. return studioData;
  56. }
  57. }
  58. public void IsCanFight(List<StoryLevelCfg> storyLevelCfgs, int index, out bool canFight, out string content)
  59. {
  60. StoryLevelCfg storyLevelCfg = storyLevelCfgs[index];
  61. bool isPass = InstanceZonesDataManager.CheckLevelPass(storyLevelCfg.needStoryLevelId);
  62. bool isRoleLv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= storyLevelCfg.needRoleLv;
  63. bool isLastPast = true;
  64. if (index > 0 && index < storyLevelCfgs.Count)
  65. {
  66. isLastPast = InstanceZonesDataManager.CheckLevelPass(storyLevelCfgs[index - 1].id);
  67. }
  68. content = "";
  69. if (!isRoleLv) content = string.Format("主角等级达到{0}级解锁", storyLevelCfg.needRoleLv);
  70. if (!isLastPast) content = string.Format("需通关{0}", storyLevelCfgs[index - 1].name);
  71. StoryLevelCfg needStoryLevelCfg = StoryLevelCfgArray.Instance.GetCfg(storyLevelCfg.needStoryLevelId);
  72. if (!isPass) content = string.Format("完成主线{0}-{1}解锁", needStoryLevelCfg.chapterId, needStoryLevelCfg.order);
  73. canFight = isPass && isRoleLv && isLastPast;
  74. }
  75. public void IsCanFight(int levelId, out bool canFight, out string content)
  76. {
  77. StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(levelId);
  78. StudioCfg cfg = StudioCfgArray.Instance.GetCfg(storyLevelCfg.chapterId);
  79. int needStoryLevelId = 0;
  80. if (cfg.funId == typeof(StudioFilingView).Name)
  81. {
  82. needStoryLevelId = cfg.storyLevelId;
  83. }
  84. else
  85. {
  86. needStoryLevelId = storyLevelCfg.needStoryLevelId;
  87. }
  88. bool isPass;
  89. if (needStoryLevelId == 0)
  90. {
  91. isPass = true;
  92. }
  93. else
  94. {
  95. isPass = InstanceZonesDataManager.CheckLevelPass(needStoryLevelId);
  96. }
  97. StoryLevelCfg needStoryLevelCfg = StoryLevelCfgArray.Instance.GetCfg(needStoryLevelId);
  98. if (!isPass && needStoryLevelCfg != null) content = string.Format("完成主线{0}-{1}解锁", needStoryLevelCfg.chapterId, needStoryLevelCfg.order);
  99. bool isRoleLv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= storyLevelCfg.needRoleLv;
  100. if (!isRoleLv) content = string.Format("主角等级达到{0}级解锁", storyLevelCfg.needRoleLv);
  101. bool isLastPast = true;
  102. int lastIndex = storyLevelCfg.order - 1 - 1;
  103. List<StoryLevelCfg> storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(storyLevelCfg.type, storyLevelCfg.subType, storyLevelCfg.chapterId);
  104. if (lastIndex >= 0)
  105. {
  106. isLastPast = InstanceZonesDataManager.CheckLevelPass(storyLevelCfgs[lastIndex].id);
  107. }
  108. if (!isLastPast) content = string.Format("需通关{0}", storyLevelCfgs[lastIndex].name);
  109. content = "";
  110. canFight = isPass && isRoleLv && isLastPast;
  111. }
  112. public void OnFinishStudioStoryLevel(int levelCfgId, bool firstPass, bool success)
  113. {
  114. ViewManager.Show(VIEW_NAME, PROPERTY_SELECT_INDEX);
  115. }
  116. public void OnFinishFilingStoryLevel(int levelCfgId, bool firstPass, bool success)
  117. {
  118. ViewManager.Show<StudioFilingView>(MainStoryDataManager.currentChapterCfgId, true);
  119. }
  120. private float GetAdditionBySuitId(int suitId)
  121. {
  122. float addition = 0;
  123. SuitCfg cfg = SuitCfgArray.Instance.GetCfg(suitId);
  124. for (int i = 0; i < cfg.partsArr.Length; i++)
  125. {
  126. if (ItemDataManager.GetItemNum(cfg.partsArr[i]) > 0)
  127. {
  128. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.partsArr[i]);
  129. addition += itemCfg.addition;
  130. }
  131. }
  132. return addition;
  133. }
  134. private float GetAdditionBySuitIds(int[] suitIds)
  135. {
  136. float addition = 0;
  137. for (int i = 0; i < suitIds.Length; i++)
  138. {
  139. addition += GetAdditionBySuitId(suitIds[i]);
  140. }
  141. return addition;
  142. }
  143. public float GetAddition()
  144. {
  145. float addition;
  146. StudioCfg filingCfg = StudioCfgArray.Instance.GetCfg(filingChapterId);
  147. // 活动
  148. if (IsluckyBoxFilingChapter())
  149. {
  150. addition = GetAdditionBySuitIds(filingCfg.activitySuitIdArr);
  151. }
  152. // 查阅建档
  153. else
  154. {
  155. addition = GetAdditionBySuitId(filingCfg.suitId);
  156. }
  157. return addition;
  158. }
  159. public bool GetFilingRewardState(int chapterId)
  160. {
  161. StudioData studioData = GetStudioDataById(chapterId);
  162. if (studioData.RewardsStatus.Count == 0) return false;
  163. for (int i = 0; i < studioData.RewardsStatus.Count; i++)
  164. {
  165. if (studioData.RewardsStatus[i] == ConstBonusStatus.CAN_GET)
  166. {
  167. return true;
  168. }
  169. else if (studioData.RewardsStatus[i] == ConstBonusStatus.CAN_NOT_GET)
  170. {
  171. return false;//奖励按顺序领取,第一个不可领则没有可领奖励
  172. }
  173. }
  174. return false;
  175. }
  176. public int GetFilingRewardStateByIndex(int chapterId, int index)
  177. {
  178. StudioData studioData = GetStudioDataById(chapterId);
  179. return studioData.RewardsStatus.Count > index ? studioData.RewardsStatus[index] : 0;
  180. }
  181. public List<int> GetFilingRewardList(int id)
  182. {
  183. StudioData studioData = GetStudioDataById(id);
  184. return studioData.RewardsStatus;
  185. }
  186. public bool IsluckyBoxFilingChapter()
  187. {
  188. return filingChapterId == GetLuckyBoxActivityID();
  189. }
  190. public int GetLuckyBoxActivityID()
  191. {
  192. if (luckyBoxFilingChapterId == 0)
  193. {
  194. int activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(ConstLimitTimeActivityType.ActLimitLuckyBox);
  195. ActivityOpenCfg activityCfg = ActivityOpenCfgArray.Instance.GetCfg(activityId);
  196. luckyBoxFilingChapterId = (activityCfg != null && activityCfg.params3Arr != null) ? activityCfg.params3Arr[0] : 0;
  197. }
  198. return luckyBoxFilingChapterId;
  199. }
  200. }
  201. }