StudioDataManager.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. public int luckyBoxFilingChapterId = 31000;//查阅建档这个章节是限时抽奖活动专属,为测试能快速更新先临时写死,后边再改
  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 = InstanceZonesDataManager.CheckLevelPass(needStoryLevelId);
  89. StoryLevelCfg needStoryLevelCfg = StoryLevelCfgArray.Instance.GetCfg(needStoryLevelId);
  90. if (!isPass && needStoryLevelCfg != null) content = string.Format("完成主线{0}-{1}解锁", needStoryLevelCfg.chapterId, needStoryLevelCfg.order);
  91. bool isRoleLv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= storyLevelCfg.needRoleLv;
  92. if (!isRoleLv) content = string.Format("主角等级达到{0}级解锁", storyLevelCfg.needRoleLv);
  93. bool isLastPast = true;
  94. int lastIndex = storyLevelCfg.order - 1 - 1;
  95. List<StoryLevelCfg> storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(storyLevelCfg.type, storyLevelCfg.subType, storyLevelCfg.chapterId);
  96. if (lastIndex >= 0)
  97. {
  98. isLastPast = InstanceZonesDataManager.CheckLevelPass(storyLevelCfgs[lastIndex].id);
  99. }
  100. if (!isLastPast) content = string.Format("需通关{0}", storyLevelCfgs[lastIndex].name);
  101. content = "";
  102. canFight = isPass && isRoleLv && isLastPast;
  103. }
  104. public void OnFinishStudioStoryLevel(int levelCfgId, bool firstPass, bool success)
  105. {
  106. ViewManager.Show(VIEW_NAME, PROPERTY_SELECT_INDEX, ViewManager.GetGoBackDatas(VIEW_NAME));
  107. }
  108. public void OnFinishFilingStoryLevel(int levelCfgId, bool firstPass, bool success)
  109. {
  110. ViewManager.Show<StudioFilingView>(MainStoryDataManager.currentChapterCfgId, ViewManager.GetGoBackDatas(typeof(StudioFilingView).FullName), true);
  111. }
  112. public float GetAdditionBySuitId(int suitId)
  113. {
  114. float addition = 0;
  115. SuitCfg cfg = SuitCfgArray.Instance.GetCfg(suitId);
  116. for (int i = 0; i < cfg.partsArr.Length; i++)
  117. {
  118. if (ItemDataManager.GetItemNum(cfg.partsArr[i]) > 0)
  119. {
  120. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.partsArr[i]);
  121. addition += itemCfg.addition;
  122. }
  123. }
  124. return addition;
  125. }
  126. public bool GetFilingRewardState(int chapterId)
  127. {
  128. StudioData studioData = GetStudioDataById(chapterId);
  129. if (studioData.RewardsStatus.Count == 0) return false;
  130. for (int i = 0; i < studioData.RewardsStatus.Count; i++)
  131. {
  132. if (studioData.RewardsStatus[i] == ConstBonusStatus.CAN_GET)
  133. {
  134. return true;
  135. }
  136. else if (studioData.RewardsStatus[i] == ConstBonusStatus.CAN_NOT_GET)
  137. {
  138. return false;//奖励按顺序领取,第一个不可领则没有可领奖励
  139. }
  140. }
  141. return false;
  142. }
  143. public int GetFilingRewardStateByIndex(int chapterId, int index)
  144. {
  145. StudioData studioData = GetStudioDataById(chapterId);
  146. return studioData.RewardsStatus.Count > index ? studioData.RewardsStatus[index] : 0;
  147. }
  148. }
  149. }