StudioDataManager.cs 10 KB

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