StudioDataManager.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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, List<int> rewardsStatus)
  39. {
  40. _StudioInfoById[chapterId].RewardsStatus = rewardsStatus;
  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, int type = ConstInstanceZonesType.Studio)
  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. bool isPass = InstanceZonesDataManager.CheckLevelPass(storyLevelCfg.needStoryLevelId);
  90. bool isRoleLv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= storyLevelCfg.needRoleLv;
  91. bool isLastPast = true;
  92. List<StoryLevelCfg> storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(storyLevelCfg.type, storyLevelCfg.subType, storyLevelCfg.chapterId);
  93. int index = storyLevelCfgs.IndexOf(storyLevelCfg);
  94. if (index > 0 && index < storyLevelCfgs.Count)
  95. {
  96. isLastPast = InstanceZonesDataManager.CheckLevelPass(storyLevelCfgs[index - 1].id);
  97. }
  98. content = "";
  99. if (!isRoleLv) content = string.Format("主角等级达到{0}级解锁", storyLevelCfg.needRoleLv);
  100. if (!isLastPast) content = string.Format("需通关{0}", storyLevelCfgs[index].name);
  101. StoryLevelCfg needStoryLevelCfg = StoryLevelCfgArray.Instance.GetCfg(storyLevelCfg.needStoryLevelId);
  102. if (!isPass) content = string.Format("完成主线{0}-{1}解锁", needStoryLevelCfg.chapterId, needStoryLevelCfg.order);
  103. canFight = isPass && isRoleLv && isLastPast;
  104. }
  105. public void OnFinishStudioStoryLevel(int levelCfgId, bool firstPass, bool success)
  106. {
  107. ViewManager.Show(VIEW_NAME, new object[] { TYPE_SELECT_INDEX, PROPERTY_SELECT_INDEX }, ViewManager.GetGoBackDatas(VIEW_NAME));
  108. }
  109. public void OnFinishFilingStoryLevel(int levelCfgId, bool firstPass, bool success)
  110. {
  111. ViewManager.Show<StudioFilingView>(MainStoryDataManager.currentChapterCfgId, ViewManager.GetGoBackDatas(typeof(StudioFilingView).FullName), true);
  112. }
  113. public float GetAdditionBySuitId(int suitId)
  114. {
  115. float addition = 0;
  116. SuitCfg cfg = SuitCfgArray.Instance.GetCfg(suitId);
  117. for (int i = 0; i < cfg.partsArr.Length; i++)
  118. {
  119. if (ItemDataManager.GetItemNum(cfg.partsArr[i]) > 0)
  120. {
  121. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.partsArr[i]);
  122. addition += itemCfg.addition;
  123. }
  124. }
  125. return addition;
  126. }
  127. }
  128. }