StudioDataManager.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 void Clear()
  15. {
  16. _StudioInfoById.Clear();
  17. }
  18. public void RspStudioInfos(StudioData studioData)
  19. {
  20. if (!_StudioInfoById.ContainsKey(studioData.ChapterId))
  21. {
  22. _StudioInfoById.Add(studioData.ChapterId, studioData);
  23. }
  24. _StudioInfoById[studioData.ChapterId] = studioData;
  25. }
  26. public void RspBuyStudioPlayTimes(int chapterId, int buyTimes, int totalPlayTimes)
  27. {
  28. _StudioInfoById[chapterId].BuyTimes = buyTimes;
  29. _StudioInfoById[chapterId].TotalPlayTimes = totalPlayTimes;
  30. }
  31. public void NoticeStudioPlayTimes(M2C_NoticeStudioPlayTimes message)
  32. {
  33. _StudioInfoById[message.ChapterId].PlayTimes = message.PlayTimes;
  34. }
  35. public StudioData GetStudioDataById(int id, int type = ConstInstanceZonesType.Studio)
  36. {
  37. if (_StudioInfoById.ContainsKey(id))
  38. {
  39. return _StudioInfoById[id];
  40. }
  41. else
  42. {
  43. int totalPlayTimes = 0;
  44. if (type == ConstInstanceZonesType.Studio)
  45. {
  46. totalPlayTimes = StudioCfgArray.Instance.GetCfg(id).num;
  47. }
  48. else if (type == ConstInstanceZonesType.Filing)
  49. {
  50. totalPlayTimes = FilingCfgArray.Instance.GetCfg(id).num;
  51. }
  52. StudioData studioData = new StudioData() { ChapterId = id, BuyTimes = 0, PlayTimes = 0, TotalPlayTimes = totalPlayTimes };
  53. RspStudioInfos(studioData);
  54. return studioData;
  55. }
  56. }
  57. public void IsCanFight(List<StoryLevelCfg> storyLevelCfgs, int index, out bool canFight, out string content)
  58. {
  59. StoryLevelCfg storyLevelCfg = storyLevelCfgs[index];
  60. bool isPass = InstanceZonesDataManager.CheckLevelPass(storyLevelCfg.needStoryLevelId);
  61. bool isRoleLv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= storyLevelCfg.needRoleLv;
  62. bool isLastPast = true;
  63. if (index > 0 && index < storyLevelCfgs.Count)
  64. {
  65. isLastPast = InstanceZonesDataManager.CheckLevelPass(storyLevelCfgs[index - 1].id);
  66. }
  67. content = "";
  68. if (!isRoleLv) content = string.Format("主角等级达到{0}级解锁", storyLevelCfg.needRoleLv);
  69. if (!isLastPast) content = string.Format("需通关{0}", storyLevelCfgs[index - 1].name);
  70. StoryLevelCfg needStoryLevelCfg = StoryLevelCfgArray.Instance.GetCfg(storyLevelCfg.needStoryLevelId);
  71. if (!isPass) content = string.Format("完成主线{0}-{1}解锁", needStoryLevelCfg.chapterId, needStoryLevelCfg.order);
  72. canFight = isPass && isRoleLv && isLastPast;
  73. }
  74. public void IsCanFight(int levelId, out bool canFight, out string content)
  75. {
  76. StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(levelId);
  77. bool isPass = InstanceZonesDataManager.CheckLevelPass(storyLevelCfg.needStoryLevelId);
  78. bool isRoleLv = GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl) >= storyLevelCfg.needRoleLv;
  79. bool isLastPast = true;
  80. List<StoryLevelCfg> storyLevelCfgs = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(storyLevelCfg.type, storyLevelCfg.subType, storyLevelCfg.chapterId);
  81. int index = storyLevelCfgs.IndexOf(storyLevelCfg);
  82. if (index > 0 && index < storyLevelCfgs.Count)
  83. {
  84. isLastPast = InstanceZonesDataManager.CheckLevelPass(storyLevelCfgs[index - 1].id);
  85. }
  86. content = "";
  87. if (!isRoleLv) content = string.Format("主角等级达到{0}级解锁", storyLevelCfg.needRoleLv);
  88. if (!isLastPast) content = string.Format("需通关{0}", storyLevelCfgs[index].name);
  89. StoryLevelCfg needStoryLevelCfg = StoryLevelCfgArray.Instance.GetCfg(storyLevelCfg.needStoryLevelId);
  90. if (!isPass) content = string.Format("完成主线{0}-{1}解锁", needStoryLevelCfg.chapterId, needStoryLevelCfg.order);
  91. canFight = isPass && isRoleLv && isLastPast;
  92. }
  93. public void OnFinishStudioStoryLevel(int levelCfgId, bool firstPass, bool success)
  94. {
  95. ViewManager.Show(VIEW_NAME, new object[] { TYPE_SELECT_INDEX, PROPERTY_SELECT_INDEX }, ViewManager.GetGoBackDatas(VIEW_NAME));
  96. }
  97. public void OnFinishFilingStoryLevel(int levelCfgId, bool firstPass, bool success)
  98. {
  99. ViewManager.Show<StudioFilingView>(MainStoryDataManager.currentChapterCfgId, ViewManager.GetGoBackDatas(typeof(StudioFilingView).FullName), true);
  100. }
  101. }
  102. }