StudioDataManager.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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 { return CommonDataManager.Tables.TblStudioCfg.GetGroup1ByFunId(typeof(StudioFilingView).Name); }
  22. }
  23. public void Clear()
  24. {
  25. _StudioInfoById.Clear();
  26. }
  27. public void RspStudioInfos(StudioData studioData)
  28. {
  29. if (!_StudioInfoById.ContainsKey(studioData.ChapterId))
  30. {
  31. _StudioInfoById.Add(studioData.ChapterId, studioData);
  32. }
  33. _StudioInfoById[studioData.ChapterId] = studioData;
  34. }
  35. public void RspFilingScoreReward(int chapterId, int index)
  36. {
  37. _StudioInfoById[chapterId].RewardsStatus[index] = ConstBonusStatus.GOT;
  38. }
  39. public void NoticeFilingScoreBonusChanged(int chapterId, int chapterScore, List<int> rewardsStatus)
  40. {
  41. _StudioInfoById[chapterId].ChapterScore = chapterScore;
  42. _StudioInfoById[chapterId].RewardsStatus = rewardsStatus;
  43. }
  44. public StudioData GetStudioDataById(int id)
  45. {
  46. if (_StudioInfoById.ContainsKey(id))
  47. {
  48. return _StudioInfoById[id];
  49. }
  50. else
  51. {
  52. StudioData studioData = new StudioData() { ChapterId = id };
  53. RspStudioInfos(studioData);
  54. return studioData;
  55. }
  56. }
  57. public void IsCanFight(List<StoryLevelCfg> storyLevelCfgs, int index, out bool canFight, out string content)
  58. {
  59. StoryLevelCfg storyLevelCfg = storyLevelCfgs[index];
  60. bool isPass = InstanceZonesDataManager.CheckLevelPass(storyLevelCfg.NeedStoryLevelId);
  61. bool isRoleLv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= storyLevelCfg.NeedRoleLv;
  62. bool isLastPast = true;
  63. if (index > 0 && index < storyLevelCfgs.Count)
  64. {
  65. isLastPast = InstanceZonesDataManager.CheckLevelPass(storyLevelCfgs[index - 1].Id);
  66. }
  67. content = "";
  68. if (!isRoleLv) content = string.Format("主角等级达到{0}级解锁", storyLevelCfg.NeedRoleLv);
  69. if (!isLastPast) content = "需通关前置关卡";
  70. StoryLevelCfg needStoryLevelCfg =
  71. CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(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 = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(levelId);
  78. StudioCfg cfg = CommonDataManager.Tables.TblStudioCfg.GetOrDefault(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 = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(needStoryLevelId);
  98. if (!isPass && needStoryLevelCfg != null)
  99. 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 = CommonDataManager.Tables.TblStoryLevelCfg.DataList.Where(a =>
  105. a.Type == storyLevelCfg.Type && a.SubType == storyLevelCfg.SubType &&
  106. a.ChapterId == storyLevelCfg.ChapterId).ToList();
  107. if (lastIndex >= 0)
  108. {
  109. isLastPast = InstanceZonesDataManager.CheckLevelPass(storyLevelCfgs[lastIndex].Id);
  110. }
  111. if (!isLastPast) content = string.Format("需通关{0}", storyLevelCfgs[lastIndex].Name);
  112. content = "";
  113. canFight = isPass && isRoleLv && isLastPast;
  114. }
  115. public void OnFinishStudioStoryLevel(int levelCfgId, bool firstPass, bool success)
  116. {
  117. ViewManager.Show(VIEW_NAME, PROPERTY_SELECT_INDEX);
  118. }
  119. public void OnFinishZCJBStoryLevel(int levelCfgId, bool firstPass, bool success)
  120. {
  121. ViewManager.Show<ActivityZCJBChapterView>(new object[] { ActivityDataManager.Instance.activityZCJBId, 2 });
  122. }
  123. public void OnFinishTimeTracingLevel(int levelCfgId, bool firstPass, bool success)
  124. {
  125. ViewManager.Show<TimeTracingLevelView>(new object[]
  126. { TimeTracingDataManager._currentChapterId, TimeTracingDataManager.SuitID });
  127. }
  128. public void OnFinishFilingStoryLevel(int levelCfgId, bool firstPass, bool success)
  129. {
  130. ViewManager.Show<StudioFilingView>(MainStoryDataManager.currentChapterCfgId, true);
  131. }
  132. private float GetAdditionBySuitId(int suitId)
  133. {
  134. float addition = 0;
  135. SuitCfg cfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(suitId);
  136. for (int i = 0; i < cfg.Parts.Count; i++)
  137. {
  138. if (ItemDataManager.GetItemNum(cfg.Parts[i]) > 0)
  139. {
  140. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(cfg.Parts[i]);
  141. addition += itemCfg.Addition;
  142. }
  143. }
  144. return addition;
  145. }
  146. private float GetAdditionBySuitIds(List<int> suitIds)
  147. {
  148. float addition = 0;
  149. for (int i = 0; i < suitIds.Count; i++)
  150. {
  151. addition += GetAdditionBySuitId(suitIds[i]);
  152. }
  153. return addition;
  154. }
  155. public float GetAddition(int type = 0)
  156. {
  157. float addition;
  158. // 开服活动
  159. if (type == ConstInstanceZonesType.PureFight)
  160. {
  161. ActivityFightCfg fightCfg = CommonDataManager.Tables.TblActivityFightCfg.GetOrDefault(filingChapterId);
  162. addition = GetAdditionBySuitIds(fightCfg.ActivitySuitId);
  163. }
  164. else
  165. {
  166. StudioCfg filingCfg = CommonDataManager.Tables.TblStudioCfg.GetOrDefault(filingChapterId);
  167. // 活动
  168. if (IsluckyBoxFilingChapter())
  169. addition = GetAdditionBySuitIds(filingCfg.ActivitySuitId);
  170. // 查阅建档
  171. else
  172. addition = GetAdditionBySuitId(filingCfg.SuitId);
  173. }
  174. return addition;
  175. }
  176. public bool GetFilingRewardState(int chapterId)
  177. {
  178. StudioData studioData = GetStudioDataById(chapterId);
  179. if (studioData.RewardsStatus.Count == 0) return false;
  180. for (int i = 0; i < studioData.RewardsStatus.Count; i++)
  181. {
  182. if (studioData.RewardsStatus[i] == ConstBonusStatus.CAN_GET)
  183. {
  184. return true;
  185. }
  186. else if (studioData.RewardsStatus[i] == ConstBonusStatus.CAN_NOT_GET)
  187. {
  188. return false; //奖励按顺序领取,第一个不可领则没有可领奖励
  189. }
  190. }
  191. return false;
  192. }
  193. public int GetFilingRewardStateByIndex(int chapterId, int index)
  194. {
  195. StudioData studioData = GetStudioDataById(chapterId);
  196. return studioData.RewardsStatus.Count > index ? studioData.RewardsStatus[index] : 0;
  197. }
  198. public List<int> GetFilingRewardList(int id)
  199. {
  200. StudioData studioData = GetStudioDataById(id);
  201. return studioData.RewardsStatus;
  202. }
  203. public bool IsluckyBoxFilingChapter()
  204. {
  205. return filingChapterId == GetLuckyBoxActivityID();
  206. }
  207. public int GetLuckyBoxActivityID()
  208. {
  209. if (luckyBoxFilingChapterId == 0)
  210. {
  211. int activityId =
  212. ActivityDataManager.Instance.GetCurOpenActiveByType(ConstLimitTimeActivityType.ActLimitLuckyBox);
  213. ActivityOpenCfg activityCfg = CommonDataManager.Tables.TblActivityOpenCfg.GetOrDefault(activityId);
  214. luckyBoxFilingChapterId =
  215. (activityCfg != null && activityCfg.Params3 != null) ? activityCfg.Params3[0] : 0;
  216. }
  217. return luckyBoxFilingChapterId;
  218. }
  219. public bool GetStudioFilingRewardRed()
  220. {
  221. var rewardList = StudioDataManager.Instance.GetFilingRewardList(StudioDataManager.Instance.filingChapterId);
  222. for (int i = 0; i < rewardList.Count; i++)
  223. {
  224. if (i < rewardList.Count && rewardList[i] == ConstBonusStatus.CAN_GET)
  225. {
  226. return true;
  227. }
  228. }
  229. return false;
  230. }
  231. }
  232. }