StudioDataManager.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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 = "需通关前置关卡";
  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 OnFinishZCJBStoryLevel(int levelCfgId, bool firstPass, bool success)
  117. {
  118. ViewManager.Show<ActivityZCJBChapterView>(new object[] { 61001, 2 });
  119. }
  120. public void OnFinishTimeTracingLevel(int levelCfgId, bool firstPass, bool success)
  121. {
  122. ViewManager.Show<TimeTracingLevelView>(new object[] { TimeTracingDataManager._currentChapterId, TimeTracingDataManager.SuitID});
  123. }
  124. public void OnFinishFilingStoryLevel(int levelCfgId, bool firstPass, bool success)
  125. {
  126. ViewManager.Show<StudioFilingView>(MainStoryDataManager.currentChapterCfgId, true);
  127. }
  128. private float GetAdditionBySuitId(int suitId)
  129. {
  130. float addition = 0;
  131. SuitCfg cfg = SuitCfgArray.Instance.GetCfg(suitId);
  132. for (int i = 0; i < cfg.partsArr.Length; i++)
  133. {
  134. if (ItemDataManager.GetItemNum(cfg.partsArr[i]) > 0)
  135. {
  136. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.partsArr[i]);
  137. addition += itemCfg.addition;
  138. }
  139. }
  140. return addition;
  141. }
  142. private float GetAdditionBySuitIds(int[] suitIds)
  143. {
  144. float addition = 0;
  145. for (int i = 0; i < suitIds.Length; i++)
  146. {
  147. addition += GetAdditionBySuitId(suitIds[i]);
  148. }
  149. return addition;
  150. }
  151. public float GetAddition(int type = 0)
  152. {
  153. float addition;
  154. // 开服活动
  155. if (type == ConstInstanceZonesType.PureFight) {
  156. ActivityFightCfg fightCfg = ActivityFightCfgArray.Instance.GetCfg(filingChapterId);
  157. addition = GetAdditionBySuitIds(fightCfg.activitySuitIdArr);
  158. }
  159. else {
  160. StudioCfg filingCfg = StudioCfgArray.Instance.GetCfg(filingChapterId);
  161. // 活动
  162. if (IsluckyBoxFilingChapter())
  163. addition = GetAdditionBySuitIds(filingCfg.activitySuitIdArr);
  164. // 查阅建档
  165. else
  166. addition = GetAdditionBySuitId(filingCfg.suitId);
  167. }
  168. return addition;
  169. }
  170. public bool GetFilingRewardState(int chapterId)
  171. {
  172. StudioData studioData = GetStudioDataById(chapterId);
  173. if (studioData.RewardsStatus.Count == 0) return false;
  174. for (int i = 0; i < studioData.RewardsStatus.Count; i++)
  175. {
  176. if (studioData.RewardsStatus[i] == ConstBonusStatus.CAN_GET)
  177. {
  178. return true;
  179. }
  180. else if (studioData.RewardsStatus[i] == ConstBonusStatus.CAN_NOT_GET)
  181. {
  182. return false;//奖励按顺序领取,第一个不可领则没有可领奖励
  183. }
  184. }
  185. return false;
  186. }
  187. public int GetFilingRewardStateByIndex(int chapterId, int index)
  188. {
  189. StudioData studioData = GetStudioDataById(chapterId);
  190. return studioData.RewardsStatus.Count > index ? studioData.RewardsStatus[index] : 0;
  191. }
  192. public List<int> GetFilingRewardList(int id)
  193. {
  194. StudioData studioData = GetStudioDataById(id);
  195. return studioData.RewardsStatus;
  196. }
  197. public bool IsluckyBoxFilingChapter()
  198. {
  199. return filingChapterId == GetLuckyBoxActivityID();
  200. }
  201. public int GetLuckyBoxActivityID()
  202. {
  203. if (luckyBoxFilingChapterId == 0)
  204. {
  205. int activityId = ActivityDataManager.Instance.GetCurOpenActiveByType(ConstLimitTimeActivityType.ActLimitLuckyBox);
  206. ActivityOpenCfg activityCfg = ActivityOpenCfgArray.Instance.GetCfg(activityId);
  207. luckyBoxFilingChapterId = (activityCfg != null && activityCfg.params3Arr != null) ? activityCfg.params3Arr[0] : 0;
  208. }
  209. return luckyBoxFilingChapterId;
  210. }
  211. public bool GetStudioFilingRewardRed()
  212. {
  213. var rewardList = StudioDataManager.Instance.GetFilingRewardList(StudioDataManager.Instance.filingChapterId);
  214. for (int i = 0; i < rewardList.Count; i++) {
  215. if (i < rewardList.Count && rewardList[i] == ConstBonusStatus.CAN_GET)
  216. {
  217. return true;
  218. }
  219. }
  220. return false;
  221. }
  222. }
  223. }