StoryController.cs 4.0 KB

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