InstanceZonesController.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. using UnityEngine;
  8. namespace GFGGame
  9. {
  10. //所有副本关卡通用类
  11. public class InstanceZonesController
  12. {
  13. public delegate void OnFinishStoryLevelCall(int levelCfgId, bool firstPass, bool success);
  14. private static OnFinishStoryLevelCall _onFinishStoryLevelCall;
  15. public static void ShowLevelView(int levelCfgId, OnFinishStoryLevelCall onFinishStoryLevelCall)
  16. {
  17. _onFinishStoryLevelCall = onFinishStoryLevelCall;
  18. InstanceZonesDataManager.currentLevelCfgId = levelCfgId;
  19. StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId);
  20. if (levelCfg.fightID.Length > 0)
  21. {
  22. ViewManager.Show(ViewName.STORY_LEVEL_INFO_VIEW, levelCfgId);
  23. }
  24. else if (!string.IsNullOrEmpty(levelCfg.storyStartID))
  25. {
  26. bool skipable = MainStoryDataManager.CheckCurrentLevelPass();
  27. ViewManager.Show(ViewName.STORY_DIALOG_VIEW, new object[] { levelCfg.storyStartID, skipable, new OnCompleteStoryDialogCall(OnCompleteChapterStoryDialog) }, null, true);
  28. }
  29. }
  30. public static void OnFinishStoryLevel(int levelCfgId, bool firstPass, bool success)
  31. {
  32. _onFinishStoryLevelCall?.Invoke(levelCfgId, firstPass, success);
  33. }
  34. public static async ETTask CheckStoryFightResult()
  35. {
  36. var score = EquipDataCache.cacher.totalScore;
  37. //客户端先做判断,成功和失败处理不同
  38. var success = InstanceZonesDataManager.GetFightResult(score, out var npcScore);
  39. if (success)
  40. {
  41. await InstanceZonesSProxy.FinishStoryFightLevel(InstanceZonesDataManager.currentLevelCfgId, score, npcScore, InstanceZonesDataManager.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 > InstanceZonesDataManager.GetScoreHighest(InstanceZonesDataManager.currentCardId))
  54. {
  55. InstanceZonesSProxy.StoryFightLevelFail(InstanceZonesDataManager.currentLevelCfgId, score).Coroutine();
  56. }
  57. }
  58. }
  59. private static void OnCompleteChapterStoryDialog(bool isSkip, object param)
  60. {
  61. if (!MainStoryDataManager.CheckCurrentLevelPass())
  62. {
  63. InstanceZonesSProxy.FinishStoryDialogLevel(InstanceZonesDataManager.currentLevelCfgId).Coroutine();
  64. }
  65. else
  66. {
  67. OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, false, false);
  68. }
  69. }
  70. }
  71. }