StoryController.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using System.Collections;
  4. using ET;
  5. namespace GFGGame
  6. {
  7. //主线剧情专用类
  8. public class StoryController
  9. {
  10. public static void ShowLevelView(int levelCfgId, int needitemId = 0, int needItemCount = 0)
  11. {
  12. InstanceZonesController.ShowLevelView(levelCfgId, OnFinishStoryLevel, needitemId, needItemCount);
  13. }
  14. public static void OnFinishStoryLevel(int levelCfgId, bool firstPass, bool success)
  15. {
  16. if (success)
  17. {
  18. //判断是否是首次打通最后一关
  19. int nextLevelID = levelCfgId + 1;
  20. StoryLevelCfg nextLevelCfg = StoryLevelCfgArray.Instance.GetCfg(nextLevelID);
  21. var fistPassLastLvl = (nextLevelCfg == null) && firstPass;
  22. if (fistPassLastLvl)
  23. {
  24. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId);
  25. StoryChapterCfg nextStoryChapterCfg = StoryChapterCfgArray.Instance.GetCfg(levelCfg.chapterId + 1);
  26. if (nextStoryChapterCfg != null)
  27. {
  28. StoryLevelCfg nextChapterLevelCfg = StoryLevelCfgArray.Instance.GetCfgsBytypeAndsubTypeAndchapterId(nextStoryChapterCfg.type, nextStoryChapterCfg.subType, nextStoryChapterCfg.id)[0];
  29. int LevelID = nextChapterLevelCfg.id;
  30. MainStoryDataManager.currentLevelCfgId = LevelID;
  31. }
  32. else
  33. {
  34. MainStoryDataManager.currentLevelCfgId = 0;
  35. }
  36. int index = 0;
  37. if (levelCfg.type == ConstInstanceZonesType.Story && levelCfg.subType == ConstInstanceZonesSubType.Hard)
  38. {
  39. index = 1;
  40. }
  41. //当副本表内最后一章通关时
  42. if (nextStoryChapterCfg == null)
  43. {
  44. StoryChapterCfg lastChapter = StoryChapterCfgArray.Instance.GetCfg(levelCfg.chapterId);
  45. ViewManager.Show<StoryChapterListView>(new object[] { index, lastChapter.order }, true);
  46. return;
  47. }
  48. else
  49. {
  50. //ViewManager.Show<StoryChapterListView>(new object[] { index, nextStoryChapterCfg.order }, true);
  51. StoryChapterCfg previousChapterCfg = StoryChapterCfgArray.Instance.GetCfg(levelCfg.chapterId);
  52. StoryChapterCfg nextChapterCfg = StoryChapterCfgArray.Instance.GetCfg(levelCfg.chapterId + 1);
  53. bool lv = nextChapterCfg.lvl < GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  54. if (CheckSuitGot(previousChapterCfg.suitId) && MainStoryDataManager.CheckChapterUnlock(levelCfg.chapterId) && lv)
  55. {
  56. ViewManager.Show<StoryChapterListView>(new object[] { index, nextStoryChapterCfg.order }, true);
  57. }
  58. else
  59. {
  60. //MainStoryDataManager.currentChapterCfgId = previousChapterCfg.id;
  61. ViewManager.Show<StoryChapterView>(new object[] { previousChapterCfg.id, 0 }, true);
  62. }
  63. }
  64. }
  65. else
  66. {
  67. ViewManager.Show<StoryChapterView>(MainStoryDataManager.currentChapterCfgId);
  68. }
  69. }
  70. else
  71. {
  72. //异常返回到关卡列表界面
  73. ViewManager.Show<StoryChapterView>(MainStoryDataManager.currentChapterCfgId);
  74. }
  75. }
  76. public static bool CheckSuitGot(int suitID = 0)
  77. {
  78. if(suitID == 0)
  79. {
  80. return true;
  81. }
  82. int count;
  83. int totalCount;
  84. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitID, out count, out totalCount);
  85. if(count >= totalCount)
  86. {
  87. return true;
  88. }
  89. return false;
  90. }
  91. public static void ShowCardStoryDialog(CardStoryCfg cardStoryCfg, CardData cardData)
  92. {
  93. ViewManager.Show<StoryDialogView>(new object[] { cardStoryCfg.storyStartID, true, new OnCompleteStoryDialogCall(OnCompleteCardStoryDialog), cardData ,false}, true);
  94. }
  95. private static void OnCompleteCardStoryDialog(bool isSkip, object param)
  96. {
  97. //CardData cardData = param as CardData;
  98. //ViewManager.Show<CardFosterView>(cardData, new object[] { typeof(CardDetailView).FullName}, true);
  99. //ViewManager.Show<CardStoryView>(cardData);
  100. }
  101. public static void ShowPriorStoryDialog()
  102. {
  103. InstanceZonesDataManager.currentLevelCfgId = 100001001;
  104. string stroyStartID = "1";
  105. // string stroyStartID = MainStoryDataManager.priorId;
  106. ViewManager.Show<StoryDialogView>(new object[] { stroyStartID, false, new OnCompleteStoryDialogCall(OnCompletePriorStoryDialog),null,false }, true);
  107. }
  108. private static void OnCompletePriorStoryDialog(bool done, object param)
  109. {
  110. //ViewManager.Show<StoryChapterView>(MainStoryDataManager.currentChapterCfgId, ViewManager.GetGoBackDatas(typeof(StoryChapterView).FullName), true);
  111. }
  112. public static void ShowFilingStoryDialog(StoryLevelCfg storyLevelCfg)
  113. {
  114. InstanceZonesDataManager.currentLevelCfgId = storyLevelCfg.id;
  115. ViewManager.Show<StoryDialogView>(new object[] { storyLevelCfg.storyStartID, false, new OnCompleteStoryDialogCall(OnCompleteFilingStoryDialog) ,null,false}, true);
  116. }
  117. private static void OnCompleteFilingStoryDialog(bool isSkip, object param)
  118. {
  119. //InstanceZonesController.OnCompleteChapterStoryDialog(isSkip, param);
  120. //ViewManager.Show<StudioFilingView>(MainStoryDataManager.currentChapterCfgId, null, true);
  121. //, ViewManager.GetGoBackDatas(typeof(StudioFilingView).FullName)
  122. }
  123. }
  124. }