InstanceZonesController.cs 4.7 KB

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