StudioDataManager.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 PorcelainTheme = 1;//瓷器修复当天主题
  15. public List<StudioCfg> FilingDatas
  16. {
  17. get
  18. {
  19. return StudioCfgArray.Instance.GetCfgsByfunId(typeof(StudioFilingView).Name);
  20. }
  21. }
  22. public void Clear()
  23. {
  24. _StudioInfoById.Clear();
  25. }
  26. public void RspStudioInfos(StudioData studioData)
  27. {
  28. if (!_StudioInfoById.ContainsKey(studioData.ChapterId))
  29. {
  30. _StudioInfoById.Add(studioData.ChapterId, studioData);
  31. }
  32. _StudioInfoById[studioData.ChapterId] = studioData;
  33. }
  34. public void RspFilingScoreReward(int chapterId, int index)
  35. {
  36. _StudioInfoById[chapterId].RewardsStatus[index] = ConstBonusStatus.GOT;
  37. }
  38. public void NoticeFilingScoreBonusChanged(int chapterId, int chapterScore, List<int> rewardsStatus)
  39. {
  40. _StudioInfoById[chapterId].ChapterScore = chapterScore;
  41. _StudioInfoById[chapterId].RewardsStatus = rewardsStatus;
  42. }
  43. public StudioData GetStudioDataById(int id)
  44. {
  45. if (_StudioInfoById.ContainsKey(id))
  46. {
  47. return _StudioInfoById[id];
  48. }
  49. else
  50. {
  51. StudioData studioData = new StudioData() { ChapterId = id };
  52. RspStudioInfos(studioData);
  53. return studioData;
  54. }
  55. }
  56. public void IsCanFight(List<StoryLevelCfg> storyLevelCfgs, int index, out bool canFight, out string content)
  57. {
  58. StoryLevelCfg storyLevelCfg = storyLevelCfgs[index];
  59. bool isPass = InstanceZonesDataManager.CheckLevelPass(storyLevelCfg.needStoryLevelId);
  60. bool isRoleLv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= storyLevelCfg.needRoleLv;
  61. bool isLastPast = true;
  62. if (index > 0 && index < storyLevelCfgs.Count)
  63. {
  64. isLastPast = InstanceZonesDataManager.CheckLevelPass(storyLevelCfgs[index - 1].id);
  65. }
  66. content = "";
  67. if (!isRoleLv) content = string.Format("主角等级达到{0}级解锁", storyLevelCfg.needRoleLv);
  68. if (!isLastPast) content = string.Format("需通关{0}", storyLevelCfgs[index - 1].name);
  69. StoryLevelCfg needStoryLevelCfg = StoryLevelCfgArray.Instance.GetCfg(storyLevelCfg.needStoryLevelId);
  70. if (!isPass) content = string.Format("完成主线{0}-{1}解锁", needStoryLevelCfg.chapterId, needStoryLevelCfg.order);
  71. canFight = isPass && isRoleLv && isLastPast;
  72. }
  73. public void IsCanFight(int levelId, out bool canFight, out string content)
  74. {
  75. StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(levelId);
  76. StudioCfg cfg = StudioCfgArray.Instance.GetCfg(storyLevelCfg.chapterId);
  77. int needStoryLevelId = 0;
  78. if (cfg.funId == typeof(StudioFilingView).Name)
  79. {
  80. needStoryLevelId = cfg.storyLevelId;
  81. }
  82. else
  83. {
  84. needStoryLevelId = storyLevelCfg.needStoryLevelId;
  85. }
  86. bool isPass = InstanceZonesDataManager.CheckLevelPass(needStoryLevelId);
  87. StoryLevelCfg needStoryLevelCfg = StoryLevelCfgArray.Instance.GetCfg(needStoryLevelId);
  88. if (!isPass && needStoryLevelCfg != null) content = string.Format("完成主线{0}-{1}解锁", needStoryLevelCfg.chapterId, needStoryLevelCfg.order);
  89. bool isRoleLv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= storyLevelCfg.needRoleLv;
  90. if (!isRoleLv) content = string.Format("主角等级达到{0}级解锁", storyLevelCfg.needRoleLv);
  91. bool isLastPast = true;
  92. int lastIndex = storyLevelCfg.order - 1 - 1;
  93. List<StoryLevelCfg> storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(storyLevelCfg.type, storyLevelCfg.subType, storyLevelCfg.chapterId);
  94. if (lastIndex >= 0)
  95. {
  96. isLastPast = InstanceZonesDataManager.CheckLevelPass(storyLevelCfgs[lastIndex].id);
  97. }
  98. if (!isLastPast) content = string.Format("需通关{0}", storyLevelCfgs[lastIndex].name);
  99. content = "";
  100. canFight = isPass && isRoleLv && isLastPast;
  101. }
  102. public void OnFinishStudioStoryLevel(int levelCfgId, bool firstPass, bool success)
  103. {
  104. ViewManager.Show(VIEW_NAME, PROPERTY_SELECT_INDEX, ViewManager.GetGoBackDatas(VIEW_NAME));
  105. }
  106. public void OnFinishFilingStoryLevel(int levelCfgId, bool firstPass, bool success)
  107. {
  108. ViewManager.Show<StudioFilingView>(MainStoryDataManager.currentChapterCfgId, ViewManager.GetGoBackDatas(typeof(StudioFilingView).FullName), true);
  109. }
  110. public float GetAdditionBySuitId(int suitId)
  111. {
  112. float addition = 0;
  113. SuitCfg cfg = SuitCfgArray.Instance.GetCfg(suitId);
  114. for (int i = 0; i < cfg.partsArr.Length; i++)
  115. {
  116. if (ItemDataManager.GetItemNum(cfg.partsArr[i]) > 0)
  117. {
  118. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.partsArr[i]);
  119. addition += itemCfg.addition;
  120. }
  121. }
  122. return addition;
  123. }
  124. public bool GetFilingRewardState(int chapterId)
  125. {
  126. StudioData studioData = GetStudioDataById(chapterId);
  127. if (studioData.RewardsStatus.Count == 0) return false;
  128. for (int i = 0; i < studioData.RewardsStatus.Count; i++)
  129. {
  130. if (studioData.RewardsStatus[i] == ConstBonusStatus.CAN_GET)
  131. {
  132. return true;
  133. }
  134. else if (studioData.RewardsStatus[i] == ConstBonusStatus.CAN_NOT_GET)
  135. {
  136. return false;//奖励按顺序领取,第一个不可领则没有可领奖励
  137. }
  138. }
  139. return false;
  140. }
  141. public int GetFilingRewardStateByIndex(int chapterId, int index)
  142. {
  143. StudioData studioData = GetStudioDataById(chapterId);
  144. return studioData.RewardsStatus[index];
  145. }
  146. }
  147. }