InstanceZonesController.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using ET;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace GFGGame
  8. {
  9. //所有副本关卡通用类
  10. public class InstanceZonesController
  11. {
  12. public delegate void OnFinishStoryLevelCall(int levelCfgId, bool firstPass, bool success);
  13. private static OnFinishStoryLevelCall _onFinishStoryLevelCall;
  14. public static void ShowLevelView(int levelCfgId, OnFinishStoryLevelCall onFinishStoryLevelCall)
  15. {
  16. _onFinishStoryLevelCall = onFinishStoryLevelCall;
  17. InstanceZonesDataManager.currentLevelCfgId = levelCfgId;
  18. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId);
  19. if (levelCfg.fightID.Length > 0)
  20. {
  21. ViewManager.Show(ViewName.STORY_LEVEL_INFO_VIEW, levelCfgId);
  22. }
  23. else if (!string.IsNullOrEmpty(levelCfg.storyStartID))
  24. {
  25. bool skipable = MainStoryDataManager.CheckCurrentLevelPass();
  26. ViewManager.Show(ViewName.STORY_DIALOG_VIEW, new object[] { levelCfg.storyStartID, skipable, new OnCompleteStoryDialogCall(OnCompleteChapterStoryDialog) }, null, true);
  27. }
  28. }
  29. public static void OnFinishStoryLevel(int levelCfgId, bool firstPass, bool success)
  30. {
  31. _onFinishStoryLevelCall?.Invoke(levelCfgId, firstPass, success);
  32. }
  33. public static async ETTask CheckStoryFightResult()
  34. {
  35. var score = EquipDataCache.cacher.totalScore;
  36. //客户端先做判断,成功和失败处理不同
  37. var success = InstanceZonesDataManager.GetFightResult(score, out var npcScore);
  38. if (success)
  39. {
  40. await InstanceZonesSProxy.FinishStoryFightLevel(InstanceZonesDataManager.currentLevelCfgId, score, npcScore, InstanceZonesDataManager.usedRecommend);
  41. }
  42. else
  43. {
  44. ViewManager.Show(ViewName.STORY_FIGHT_RESULT_VIEW, new StoryFightResultData
  45. {
  46. Result = false,
  47. Score = score,
  48. FirstPass = false,
  49. Star = 0
  50. }, null, true);
  51. //失败仅判断并更新最高分
  52. if (score > InstanceZonesDataManager.GetScoreHighest(InstanceZonesDataManager.currentCardId))
  53. {
  54. InstanceZonesSProxy.StoryFightLevelFail(InstanceZonesDataManager.currentLevelCfgId, score).Coroutine();
  55. }
  56. }
  57. }
  58. private static void OnCompleteChapterStoryDialog(bool isSkip, object param)
  59. {
  60. if (!MainStoryDataManager.CheckCurrentLevelPass())
  61. {
  62. InstanceZonesSProxy.FinishStoryDialogLevel(InstanceZonesDataManager.currentLevelCfgId).Coroutine();
  63. }
  64. else
  65. {
  66. OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, false, false);
  67. }
  68. }
  69. }
  70. }