StudioDataManager.cs 7.3 KB

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