InstanceZonesController.cs 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
  23. if (storyFightCfg == null)
  24. {
  25. Debug.LogError(string.Format("战斗id:{0} 无配置", levelCfg.fightID));
  26. return;
  27. }
  28. ViewManager.Show(ViewName.STORY_LEVEL_INFO_VIEW, levelCfgId);
  29. }
  30. else if (!string.IsNullOrEmpty(levelCfg.storyStartID))
  31. {
  32. List<StoryDialogCfg> storyDialogCfg = StoryDialogCfgArray.Instance.GetCfgs(levelCfg.storyStartID);
  33. if (storyDialogCfg.Count <= 0)
  34. {
  35. Debug.LogError(string.Format("剧情id:{0} 无配置", levelCfg.storyStartID));
  36. return;
  37. }
  38. bool skipable = MainStoryDataManager.CheckCurrentLevelPass();
  39. ViewManager.Show(ViewName.STORY_DIALOG_VIEW, new object[] { levelCfg.storyStartID, skipable, new OnCompleteStoryDialogCall(OnCompleteChapterStoryDialog) }, new object[] { typeof(StoryChapterView).Name, MainStoryDataManager.currentChapterCfgId }, true);
  40. }
  41. }
  42. public static void OnFinishStoryLevel(int levelCfgId, bool firstPass, bool success)
  43. {
  44. _onFinishStoryLevelCall?.Invoke(levelCfgId, firstPass, success);
  45. }
  46. public static async ETTask CheckStoryFightResult()
  47. {
  48. var score = EquipDataCache.cacher.totalScore;
  49. //客户端先做判断,成功和失败处理不同
  50. var success = InstanceZonesDataManager.GetFightResult(score, out var npcScore);
  51. if (success)
  52. {
  53. await InstanceZonesSProxy.FinishStoryFightLevel(InstanceZonesDataManager.currentLevelCfgId, score, npcScore, InstanceZonesDataManager.usedRecommend);
  54. }
  55. else
  56. {
  57. ViewManager.Show(ViewName.STORY_FIGHT_RESULT_VIEW, new StoryFightResultData
  58. {
  59. Result = false,
  60. Score = score,
  61. FirstPass = false,
  62. Star = 0
  63. }, null, true);
  64. //失败仅判断并更新最高分
  65. if (score > InstanceZonesDataManager.GetScoreHighest(InstanceZonesDataManager.currentCardId))
  66. {
  67. InstanceZonesSProxy.StoryFightLevelFail(InstanceZonesDataManager.currentLevelCfgId, score).Coroutine();
  68. }
  69. }
  70. }
  71. private static void OnCompleteChapterStoryDialog(bool isSkip, object param)
  72. {
  73. if (!MainStoryDataManager.CheckCurrentLevelPass())
  74. {
  75. InstanceZonesSProxy.FinishStoryDialogLevel(InstanceZonesDataManager.currentLevelCfgId).Coroutine();
  76. }
  77. else
  78. {
  79. OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, false, false);
  80. }
  81. }
  82. }
  83. }