StudioDataManager.cs 7.4 KB

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