StudioDataManager.cs 10 KB

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