InstanceZonesController.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. ViewManager.SetMaskAlpha(0.8f);
  24. }
  25. else if (!string.IsNullOrEmpty(levelCfg.storyStartID))
  26. {
  27. bool skipable = MainStoryDataManager.CheckCurrentLevelPass();
  28. ViewManager.Show(ViewName.STORY_DIALOG_VIEW, new object[] { levelCfg.storyStartID, skipable, new OnCompleteStoryDialogCall(OnCompleteChapterStoryDialog) }, null, true);
  29. }
  30. }
  31. public static void OnFinishStoryLevel(int levelCfgId, bool firstPass, bool success)
  32. {
  33. _onFinishStoryLevelCall?.Invoke(levelCfgId, firstPass, success);
  34. }
  35. public static async ETTask CheckStoryFightResult()
  36. {
  37. var score = EquipDataCache.cacher.totalScore;
  38. //客户端先做判断,成功和失败处理不同
  39. var success = InstanceZonesDataManager.GetFightResult(score, out var npcScore);
  40. if (success)
  41. {
  42. await InstanceZonesSProxy.FinishStoryFightLevel(InstanceZonesDataManager.currentLevelCfgId, score, npcScore, InstanceZonesDataManager.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 > InstanceZonesDataManager.GetScoreHighest(InstanceZonesDataManager.currentCardId))
  55. {
  56. InstanceZonesSProxy.StoryFightLevelFail(InstanceZonesDataManager.currentLevelCfgId, score).Coroutine();
  57. }
  58. }
  59. }
  60. private static void OnCompleteChapterStoryDialog(bool isSkip, object param)
  61. {
  62. if (!MainStoryDataManager.CheckCurrentLevelPass())
  63. {
  64. InstanceZonesSProxy.FinishStoryDialogLevel(InstanceZonesDataManager.currentLevelCfgId).Coroutine();
  65. }
  66. else
  67. {
  68. OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, false, false);
  69. }
  70. }
  71. }
  72. }