InstanceZonesController.cs 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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, int needitemId = 0, int needItemCount = 0)
  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, new object[] { levelCfgId, needitemId, needItemCount });
  29. }
  30. else if (!string.IsNullOrEmpty(levelCfg.storyStartID))
  31. {
  32. List<StoryDialogCfg> storyDialogCfg = StoryDialogCfgArray.Instance.GetCfgsByid(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).FullName, MainStoryDataManager.currentChapterCfgId }, true);
  40. }
  41. }
  42. public static async ETTask CheckStoryFightResult()
  43. {
  44. var score = EquipDataCache.cacher.totalScore;
  45. //客户端先做判断,成功和失败处理不同
  46. var success = InstanceZonesDataManager.GetFightResult(score, out var npcScore);
  47. if (success)
  48. {
  49. await InstanceZonesSProxy.FinishStoryFightLevel(InstanceZonesDataManager.currentLevelCfgId, score, npcScore, InstanceZonesDataManager.usedRecommend);
  50. }
  51. else
  52. {
  53. ViewManager.Show(ViewName.STORY_FIGHT_RESULT_VIEW, new StoryFightResultData
  54. {
  55. Result = false,
  56. Score = score,
  57. FirstPass = false,
  58. Star = 0
  59. }, null, true);
  60. //失败仅判断并更新最高分
  61. if (score > InstanceZonesDataManager.GetScoreHighest(InstanceZonesDataManager.currentCardId))
  62. {
  63. InstanceZonesSProxy.StoryFightLevelFail(InstanceZonesDataManager.currentLevelCfgId, score).Coroutine();
  64. }
  65. }
  66. }
  67. public static void OnCompleteChapterStoryDialog(bool isSkip, object param)
  68. {
  69. if (!MainStoryDataManager.CheckCurrentLevelPass())
  70. {
  71. InstanceZonesSProxy.FinishStoryDialogLevel(InstanceZonesDataManager.currentLevelCfgId).Coroutine();
  72. }
  73. else
  74. {
  75. OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, false, false);
  76. }
  77. }
  78. public static void OnFinishStoryLevel(int levelCfgId, bool firstPass, bool success)
  79. {
  80. _onFinishStoryLevelCall?.Invoke(levelCfgId, firstPass, success);
  81. }
  82. }
  83. }