StoryController.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using ET;
  2. using System.Collections.Generic;
  3. namespace GFGGame
  4. {
  5. public class StoryController
  6. {
  7. public static void ShowLevelView(int chapterID, int level)
  8. {
  9. int levelID = chapterID*GameConst.STORY_LEVEL_KEY_NUM + level;
  10. StoryDataManager.currentChapter = chapterID;
  11. StoryDataManager.currentLevelCfgId = levelID;
  12. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelID);
  13. StoryDataManager.currentLevel = level;
  14. if (levelCfg.fightID.Length > 0)
  15. {
  16. ViewManager.Show(ViewName.STORY_LEVEL_INFO_VIEW, levelID);
  17. }
  18. else if (levelCfg.storyStartID.Length > 0)
  19. {
  20. bool skipable = StoryDataManager.CheckCurrentLevelPass();
  21. ViewManager.Show(ViewName.STORY_DIALOG_VIEW, new object[] { levelCfg.storyStartID, skipable, new OnCompleteStoryDialogCall(OnCompleteChapterStoryDialog) }, null, true);
  22. }
  23. }
  24. public static void ShowCardStoryDialog(CardStoryCfg cardStoryCfg, CardData cardData)
  25. {
  26. ViewManager.Show(ViewName.STORY_DIALOG_VIEW, new object[] { cardStoryCfg.storyStartID, true, new OnCompleteStoryDialogCall(OnCompleteCardStoryDialog), cardData }, null, true);
  27. }
  28. public static void ShowPriorStoryDialog()
  29. {
  30. StoryDataManager.currentChapter = 1;
  31. StoryDataManager.currentLevelCfgId = 1001;
  32. ViewManager.Show(ViewName.STORY_DIALOG_VIEW, new object[] { StoryDataManager.priorId, false, new OnCompleteStoryDialogCall(OnCompleteChapterStoryDialog) }, null, true);
  33. }
  34. public static async ETTask CheckStoryFightResult()
  35. {
  36. var score = EquipDataCache.cacher.totalScore;
  37. //客户端先做判断,成功和失败处理不同
  38. var success = StoryDataManager.GetFightResult(score, out var npcScore);
  39. if(success)
  40. {
  41. await StorySProxy.FinishStoryFightLevel(StoryDataManager.currentLevelCfgId, score, npcScore, StoryDataManager.usedRecommend);
  42. }
  43. else
  44. {
  45. ViewManager.Show(ViewName.STORY_FIGHT_RESULT_VIEW, new StoryFightResultData
  46. {
  47. Result = false,
  48. Score = score,
  49. FirstPass = false,
  50. Star = 0
  51. }, null, true);
  52. //失败仅判断并更新最高分
  53. if(score > StoryDataManager.GetScoreHighest(StoryDataManager.currentCardId))
  54. {
  55. StorySProxy.StoryFightLevelFail(StoryDataManager.currentLevelCfgId, score).Coroutine();
  56. }
  57. }
  58. }
  59. public static void OnFinishStoryLevel(int levelCfgId, bool firstPass)
  60. {
  61. //判断是否是首次打通最后一关
  62. int nextLevelID = levelCfgId + 1;
  63. StoryLevelCfg nextLevelCfg = StoryLevelCfgArray.Instance.GetCfg(nextLevelID);
  64. var fistPassLastLvl = (nextLevelCfg == null) && firstPass;
  65. if (fistPassLastLvl)
  66. {
  67. ViewManager.Show(ViewName.STORY_CHAPTER_LIST_VIEW);
  68. }
  69. else
  70. {
  71. ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, StoryDataManager.currentChapter, ViewManager.GetGoBackDatas(ViewName.STORY_CHAPTER_VIEW));
  72. }
  73. }
  74. private static void OnCompleteChapterStoryDialog(bool isSkip, object param)
  75. {
  76. //List<ItemData> bonusList = null;
  77. bool _fistPassLastLvl = false;
  78. bool _curLvfirstPass = false;
  79. if (!StoryDataManager.CheckCurrentLevelPass())
  80. {
  81. //bonusList = StoryDataManager.PassCurrentLevel(out _fistPassLastLvl, out _curLvfirstPass);
  82. StorySProxy.FinishStoryDialogLevel(StoryDataManager.currentLevelCfgId).Coroutine();
  83. }
  84. //if (bonusList != null && bonusList.Count > 0)
  85. //{
  86. // ViewManager.Show(ViewName.GET_BONUS_VIEW, bonusList);
  87. //}
  88. }
  89. private static void OnCompleteCardStoryDialog(bool isSkip, object param)
  90. {
  91. CardData cardData = param as CardData;
  92. ViewManager.Show(ViewName.CARD_FOSTER_VIEW, cardData, new object[] { ViewName.CARD_DETAIL_VIEW }, true);
  93. ViewManager.Show(ViewName.CARD_STORY_VIEW, cardData);
  94. }
  95. }
  96. }