InstanceZonesController.cs 4.6 KB

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