StoryController.cs 4.1 KB

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