InstanceZonesController.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 cfg.GfgCfg;
  8. using UnityEngine;
  9. namespace GFGGame
  10. {
  11. //所有副本关卡通用类
  12. public class InstanceZonesController
  13. {
  14. public delegate void OnFinishStoryLevelCall(int levelCfgId, bool firstPass, bool success);
  15. private static OnFinishStoryLevelCall _onFinishStoryLevelCall;
  16. public static void ShowLevelView(int levelCfgId, OnFinishStoryLevelCall onFinishStoryLevelCall,
  17. int needitemId = 0, int needItemCount = 0)
  18. {
  19. _onFinishStoryLevelCall = onFinishStoryLevelCall;
  20. InstanceZonesDataManager.currentLevelCfgId = levelCfgId;
  21. StoryLevelCfg levelCfg = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(levelCfgId);
  22. if (levelCfg.FightID.Length > 0)
  23. {
  24. StoryFightCfg storyFightCfg =
  25. CommonDataManager.Tables.TblStoryFightCfg.GetOrDefault(int.Parse(levelCfg.FightID));
  26. if (storyFightCfg == null)
  27. {
  28. Debug.LogError(string.Format("战斗id:{0} 无配置", levelCfg.FightID));
  29. return;
  30. }
  31. if (levelCfg.Type == 6 && levelCfg.SubType == 2)
  32. {
  33. ViewManager.Show<TimeTracingLevelInfoView>(new object[] { levelCfgId, needitemId, needItemCount });
  34. }
  35. else
  36. {
  37. ViewManager.Show<StoryLevelInfoView>(new object[] { levelCfgId, needitemId, needItemCount });
  38. }
  39. }
  40. else if (!string.IsNullOrEmpty(levelCfg.StoryStartID))
  41. {
  42. List<StoryDialogCfg> storyDialogCfg = CommonDataManager.Tables.TblStoryDialogCfg.DataList
  43. .Where(a => a.Id == int.Parse(levelCfg.StoryStartID)).ToList();
  44. if (storyDialogCfg.Count <= 0)
  45. {
  46. Debug.LogError(string.Format("剧情id:{0} 无配置", levelCfg.StoryStartID));
  47. return;
  48. }
  49. //, new object[] { typeof(StoryChapterView).FullName, MainStoryDataManager.currentChapterCfgId }
  50. bool skipable = MainStoryDataManager.CheckCurrentLevelPass();
  51. ViewManager.Show<StoryDialogView>(
  52. new object[]
  53. {
  54. levelCfg.StoryStartID, skipable, new OnCompleteStoryDialogCall(OnCompleteChapterStoryDialog),
  55. null, false
  56. }, true, false);
  57. }
  58. }
  59. public static async ETTask CheckStoryFightResult()
  60. {
  61. //StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
  62. //if (storyLevelCfg.type == ConstInstanceZonesType.Studio && storyLevelCfg.subType == ConstInstanceZonesSubType.Hard3)
  63. //{
  64. // float addition = StudioDataManager.Instance.GetAddition();
  65. // addition = addition / 10000 * FightDataManager.Instance.totalScore;
  66. // FightDataManager.Instance.totalScore += (int)Math.Round(addition);
  67. //}
  68. var score = FightDataManager.Instance.totalScore;
  69. //客户端先做判断,成功和失败处理不同
  70. var success = InstanceZonesDataManager.GetFightResult(score, out var npcScore);
  71. if (success)
  72. {
  73. await InstanceZonesSProxy.FinishStoryFightLevel(InstanceZonesDataManager.currentLevelCfgId, score,
  74. npcScore, InstanceZonesDataManager.usedRecommend);
  75. }
  76. else
  77. {
  78. ViewManager.Show<StroyFightResultView>(new StoryFightResultData
  79. {
  80. Result = false,
  81. Score = score,
  82. FirstPass = false,
  83. Star = 0
  84. }, true);
  85. //失败仅判断并更新最高分
  86. if (score > InstanceZonesDataManager.GetScoreHighest(InstanceZonesDataManager.currentCardId))
  87. {
  88. InstanceZonesSProxy.StoryFightLevelFail(InstanceZonesDataManager.currentLevelCfgId, score)
  89. .Coroutine();
  90. }
  91. }
  92. }
  93. public static void OnCompleteChapterStoryDialog(bool isSkip, object param)
  94. {
  95. if (!MainStoryDataManager.CheckCurrentLevelPass() && isSkip)
  96. {
  97. InstanceZonesSProxy.FinishStoryDialogLevel(InstanceZonesDataManager.currentLevelCfgId).Coroutine();
  98. }
  99. else
  100. {
  101. //OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, false, false);
  102. }
  103. }
  104. public static void OnFinishStoryLevel(int levelCfgId, bool firstPass, bool success)
  105. {
  106. _onFinishStoryLevelCall?.Invoke(levelCfgId, firstPass, success);
  107. }
  108. }
  109. }