EventSystemManager.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Common.Utility.CombatEvent;
  5. using Core.Language;
  6. using Excel2Json;
  7. using Fort23.Core;
  8. using Fort23.Mono;
  9. using Fort23.UTool;
  10. using GameLogic.Combat;
  11. using GameLogic.Combat.CombatTool;
  12. using UnityEngine;
  13. using Utility;
  14. using EventConfig = Excel2Json.EventConfig;
  15. using Random = UnityEngine.Random;
  16. public class EventSystemManager : Singleton<EventSystemManager>
  17. {
  18. List<EventConfig> eventConfigs = new List<EventConfig>();
  19. public AccountFileInfo.EventList CurrentEventList;
  20. public bool isTriggerEvent;
  21. List<DivineSenseConfig> divineSenseConfigs = new List<DivineSenseConfig>();
  22. List<int> qualitys = new List<int>() { 1, 2, 3, 4, 5, 6 };
  23. public bool isOpenUi;
  24. Action onCompleteCallback;
  25. // public Map<int, AccountFileInfo.EventConditionData> EventConditionDataMap = new Map<int, AccountFileInfo.EventConditionData>();
  26. public void CustomInit()
  27. {
  28. eventConfigs = ConfigComponent.Instance.GetAll<EventConfig>().ToList();
  29. divineSenseConfigs = ConfigComponent.Instance.GetAll<DivineSenseConfig>().ToList();
  30. // foreach (var playerDataEventConditionData in AccountFileInfo.Instance.playerData.eventConditionDatas)
  31. // {
  32. // EventConditionDataMap.Add(playerDataEventConditionData.guid, playerDataEventConditionData);
  33. // }
  34. StaticUpdater.Instance.AddRenderUpdateCallBack(Update);
  35. EventManager.Instance.AddEventListener(CustomEventType.DetectRandomEvent, RenfenceRandomEvent);
  36. EventManager.Instance.AddEventListener(CustomEventType.AddItem, ItemUpdate);
  37. EventManager.Instance.AddEventListener(CustomEventType.JingJieUpgrade, JingJieUpgrade);
  38. }
  39. private void JingJieUpgrade(IEventData e)
  40. {
  41. CeekEventCompletes(3, null);
  42. }
  43. private void ItemUpdate(IEventData e)
  44. {
  45. ItemUpdateData data = e as ItemUpdateData;
  46. CeekEventCompletes(1, new[] { data.ItemInfo.itemID });
  47. CeekEventCompletes(6, new[] { data.ItemInfo.itemID, data.Count });
  48. }
  49. private void RenfenceRandomEvent(IEventData e)
  50. {
  51. DetectRandomEvents();
  52. }
  53. private float timer = 0;
  54. private void Update()
  55. {
  56. timer += Time.deltaTime;
  57. if (timer > 1)
  58. {
  59. timer = 0;
  60. HeroPowerUpConfig heroPowerUpConfig = PlayerManager.Instance.myHero.powerUpConfig;
  61. if (AccountFileInfo.Instance.playerData.divineSensePoint < heroPowerUpConfig.ShenshiMax)
  62. {
  63. AccountFileInfo.Instance.playerData.divineSensePoint += 3;
  64. EventManager.Instance.Dispatch(CustomEventType.DivineSensePointChange, null);
  65. AccountFileInfo.Instance.SavePlayerData();
  66. }
  67. }
  68. }
  69. public List<AccountFileInfo.EventList> UseDivinesense()
  70. {
  71. HeroPowerUpConfig heroPowerUpConfig = PlayerManager.Instance.myHero.powerUpConfig;
  72. int count = AccountFileInfo.Instance.playerData.divineSensePoint / PlayerManager.Instance.gameConstantConfig.DetectEventCount;
  73. if (count <= 0)
  74. {
  75. //神识值不够
  76. return null;
  77. }
  78. int maxCount = heroPowerUpConfig.ShenshiMax / PlayerManager.Instance.gameConstantConfig.DetectEventCount;
  79. count = count + AccountFileInfo.Instance.playerData.eventList.Count > maxCount ? maxCount - AccountFileInfo.Instance.playerData.eventList.Count : count;
  80. EventManager.Instance.Dispatch(CustomEventType.DivineSensePointChange, null);
  81. // 神识升级逻辑
  82. UpDivinesense();
  83. var eventConfigs = DetectEvents(count);
  84. if (eventConfigs == null || eventConfigs.Count == 0)
  85. return default;
  86. //扣除神识值 增加神识经验
  87. int xiaoHao = eventConfigs.Count * PlayerManager.Instance.gameConstantConfig.DetectEventCount;
  88. AccountFileInfo.Instance.playerData.divineSenseexp += xiaoHao;
  89. AccountFileInfo.Instance.playerData.divineSensePoint -= xiaoHao;
  90. AccountFileInfo.Instance.playerData.eventList.AddRange(eventConfigs);
  91. AccountFileInfo.Instance.SavePlayerData();
  92. return eventConfigs;
  93. }
  94. private void UpDivinesense()
  95. {
  96. for (var i = AccountFileInfo.Instance.playerData.divineSenseLevel - 1; i < divineSenseConfigs.Count; i++)
  97. {
  98. if (AccountFileInfo.Instance.playerData.divineSenseexp >= divineSenseConfigs[i].exp)
  99. {
  100. AccountFileInfo.Instance.playerData.divineSenseexp -= divineSenseConfigs[i].exp;
  101. AccountFileInfo.Instance.playerData.divineSenseLevel = divineSenseConfigs[i].ID;
  102. }
  103. }
  104. AccountFileInfo.Instance.SavePlayerData();
  105. }
  106. public bool BagIsEvent(int eventID)
  107. {
  108. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  109. {
  110. if (eventList.eventID == eventID)
  111. {
  112. return true;
  113. }
  114. }
  115. return false;
  116. }
  117. public bool IsEventTrigger(int eventID)
  118. {
  119. foreach (var eventList in AccountFileInfo.Instance.playerData.completeEvents)
  120. {
  121. if (eventList.eventID == eventID)
  122. {
  123. return true;
  124. }
  125. }
  126. return false;
  127. }
  128. private List<AccountFileInfo.EventList> DetectEvents(int eventCount)
  129. {
  130. PlacesConfig bigMap = ConfigComponent.Instance.Get<PlacesConfig>(PlayerManager.Instance.CurrentPlaces.id);
  131. DivineSenseConfig divineSenseConfig = ConfigComponent.Instance.Get<DivineSenseConfig>(AccountFileInfo.Instance.playerData.divineSenseLevel);
  132. LogTool.Log($"使用神识,神识等级:{AccountFileInfo.Instance.playerData.divineSenseLevel}");
  133. List<AccountFileInfo.EventList> eventLists = new List<AccountFileInfo.EventList>();
  134. //找出可以刷新的支线任务
  135. if (bigMap.ZhixianActivatedPercentage != null)
  136. {
  137. List<EventConfig> zhiXianEvents = new List<EventConfig>();
  138. for (var i = 0; i < bigMap.ZhixianActivatedPercentage.Length; i++)
  139. {
  140. if (PlayerManager.Instance.PlacesBl >= bigMap.ZhixianActivatedPercentage[i])
  141. {
  142. if (!BagIsEvent(bigMap.ZhixianID[i]) && !IsEventTrigger(bigMap.ZhixianID[i]) && CanTriggerEvent(bigMap.ZhixianID[i]))
  143. {
  144. zhiXianEvents.Add(ConfigComponent.Instance.Get<EventConfig>(bigMap.ZhixianID[i]));
  145. }
  146. }
  147. }
  148. foreach (var c in zhiXianEvents)
  149. {
  150. AccountFileInfo.EventList eventList = AddEvent(c.ID);
  151. if (eventList != null)
  152. {
  153. eventLists.Add(eventList);
  154. eventCount--;
  155. if (eventCount == 0)
  156. {
  157. return eventLists;
  158. }
  159. }
  160. }
  161. }
  162. for (int i = 0; i < eventCount; i++)
  163. {
  164. //先掉落出品质
  165. int quality = UtilTools.GetRandomByWeight(qualitys, divineSenseConfig.QualityBonusChance);
  166. // 获取通用事件
  167. List<EventConfig> globalEvents = eventConfigs.Where(e => e.EventTriggerType == 1 && CanTriggerEvent(e.ID) && e.EventQuality == quality && !BagIsEvent(e.ID) && eventLists.FirstOrDefault(el => el.eventID == e.ID) == null).ToList();
  168. //场景特定事件
  169. List<EventConfig> candidateEvents = eventConfigs.Where(e => bigMap.SpecialTaskID.Contains(e.ID) && CanTriggerEvent(e.ID) && e.EventQuality == quality && !BagIsEvent(e.ID) && eventLists.FirstOrDefault(el => el.eventID == e.ID) == null).ToList();
  170. if (candidateEvents.Count == 0 && globalEvents.Count == 0)
  171. {
  172. continue;
  173. }
  174. int randomValue1 = Random.Range(0, 101);
  175. // 达到怪率刷新场景特定事件
  176. //不然刷新通用事件(每个地图都可以刷的)
  177. if (randomValue1 >= bigMap.DivineSenseGeneralProbability && candidateEvents.Count > 0)
  178. {
  179. int randomValue2 = Random.Range(0, candidateEvents.Count);
  180. eventLists.Add(AddEvent(candidateEvents[randomValue2].ID));
  181. }
  182. else if (globalEvents.Count > 0)
  183. {
  184. int randomValue2 = Random.Range(0, globalEvents.Count);
  185. eventLists.Add(AddEvent(globalEvents[randomValue2].ID));
  186. }
  187. }
  188. if (eventLists.Count == 0)
  189. {
  190. LogTool.Error("没有可以触发的事件");
  191. return null;
  192. }
  193. return eventLists;
  194. }
  195. //添加事件
  196. public AccountFileInfo.EventList AddEvent(int eventID)
  197. {
  198. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventID);
  199. AccountFileInfo.EventList eventList = null;
  200. AccountFileInfo.EventList e = AccountFileInfo.Instance.playerData.eventList.FirstOrDefault(e => e.eventID == eventID);
  201. if (e == null)
  202. {
  203. //主线任务只能刷一次
  204. if (eventConfig.EventTriggerType == 4)
  205. {
  206. e = AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(e => e.eventID == eventID);
  207. if (e == null)
  208. {
  209. eventList = new AccountFileInfo.EventList();
  210. eventList.eventID = eventID;
  211. }
  212. }
  213. else
  214. {
  215. eventList = new AccountFileInfo.EventList();
  216. eventList.eventID = eventID;
  217. }
  218. }
  219. //初始化神识链条,用于监听条件是否完成
  220. if (eventList != null && eventConfig.EventType != 2)
  221. {
  222. foreach (var i in eventConfig.EventLinksId)
  223. {
  224. EventLinkConfig eventLinkConfig = ConfigComponent.Instance.Get<EventLinkConfig>(i);
  225. AccountFileInfo.EventLinkData eventLinkData = new AccountFileInfo.EventLinkData();
  226. eventLinkData.eventId = eventID;
  227. eventLinkData.eventLinkId = i;
  228. if (eventLinkConfig.ConditionId != null)
  229. {
  230. foreach (var i1 in eventLinkConfig.ConditionId)
  231. {
  232. AccountFileInfo.EventConditionData eventConditionData = new AccountFileInfo.EventConditionData();
  233. eventConditionData.eventId = eventList.eventID;
  234. eventConditionData.eventCondition = i1;
  235. // AccountFileInfo.Instance.playerData.eventConditionDatas.Add(eventConditionData);
  236. eventLinkData.eventConditions.Add(eventConditionData);
  237. //初始化先检测一些条件
  238. CeekTaskComplete(eventConditionData, 1, null);
  239. CeekTaskComplete(eventConditionData, 3, null);
  240. }
  241. }
  242. eventList.eventLinks.Add(eventLinkData);
  243. }
  244. }
  245. return eventList;
  246. }
  247. /// <summary>
  248. /// 触发随机事件
  249. /// </summary>
  250. public void DetectRandomEvents()
  251. {
  252. if (isTriggerEvent)
  253. return;
  254. if (isOpenUi)
  255. return;
  256. // 获取随机事件
  257. List<EventConfig> randomEvents = eventConfigs.Where(e => e.EventTriggerType == 2 && CanTriggerEvent(e.ID)).ToList();
  258. if (randomEvents.Count == 0)
  259. {
  260. LogTool.Warning("没有可以刷新的事件");
  261. return;
  262. }
  263. int idex = Random.Range(0, randomEvents.Count);
  264. TriggerEvent(randomEvents[idex]);
  265. }
  266. /// <summary>
  267. /// 挂机事件触发
  268. /// </summary>
  269. public void TriggerEvent(EventConfig evt)
  270. {
  271. if (isTriggerEvent)
  272. return;
  273. isTriggerEvent = true;
  274. LogTool.Log($"触发事件: {evt.EventName} (ID: {evt.ID}, 品质: {evt.EventQuality})");
  275. CombatDrive.Instance.CombatController.ChangeState(CombatController.idle);
  276. DialogueManager.Instance.StartDialogue(null, evt.EventLinksId[0], evt.ID, () => { CompleteEvent(evt.ID); });
  277. }
  278. /// <summary>
  279. /// 其他类型事件触发
  280. /// </summary>
  281. public async CTask TriggerEvent(AccountFileInfo.EventList evt, Action oncompleteCallBack = null)
  282. {
  283. if (isTriggerEvent)
  284. return;
  285. CTask cTask = CTask.Create();
  286. this.onCompleteCallback = oncompleteCallBack;
  287. isTriggerEvent = true;
  288. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(evt.eventID);
  289. LogTool.Log($"触发事件: {LanguageManager.Instance.Text(eventConfig.EventName)} (ID: {eventConfig.ID}, 品质: {eventConfig.EventQuality})");
  290. int dialogueID = 0;
  291. if (evt.curStep == 0)
  292. {
  293. dialogueID = eventConfig.EventLinksId[0];
  294. }
  295. else
  296. {
  297. dialogueID = evt.curStep;
  298. }
  299. CurrentEventList = evt;
  300. CombatDrive.Instance.CombatController.ChangeState(CombatController.idle);
  301. DialogueManager.Instance.StartDialogue(CurrentEventList, dialogueID, eventConfig.ID, () =>
  302. {
  303. CompleteEvent(CurrentEventList);
  304. cTask.SetResult();
  305. }, () =>
  306. {
  307. CancelEvent(CurrentEventList);
  308. cTask.SetResult();
  309. });
  310. await cTask;
  311. }
  312. //任务是否完成
  313. public bool IsEvenkLinkComplete(AccountFileInfo.EventConditionData eventCondition)
  314. {
  315. EventConditionConfig eventConditionConfig = ConfigComponent.Instance.Get<EventConditionConfig>(eventCondition.eventCondition);
  316. if (eventCondition != null)
  317. {
  318. return eventCondition.fishCount >= eventConditionConfig.finishCount;
  319. }
  320. return false;
  321. }
  322. public bool CeekEventGroupComplete(List<AccountFileInfo.EventConditionData> eventConditions)
  323. {
  324. Map<int, List<AccountFileInfo.EventConditionData>> eventConditionDataGroup = new Map<int, List<AccountFileInfo.EventConditionData>>();
  325. foreach (var eventConditionData in eventConditions)
  326. {
  327. EventConditionConfig eventConditionConfig = ConfigComponent.Instance.Get<EventConditionConfig>(eventConditionData.eventCondition);
  328. if (!eventConditionDataGroup.ContainsKey(eventConditionConfig.Operation))
  329. {
  330. eventConditionDataGroup.Add(eventConditionConfig.Operation, new List<AccountFileInfo.EventConditionData>());
  331. }
  332. eventConditionDataGroup[eventConditionConfig.Operation].Add(eventConditionData);
  333. }
  334. bool isUlock = true;
  335. foreach (var keyValuePair in eventConditionDataGroup)
  336. {
  337. isUlock = true;
  338. foreach (var eventConditionData in keyValuePair.Value)
  339. {
  340. if (!IsEvenkLinkComplete(eventConditionData))
  341. {
  342. isUlock = false;
  343. }
  344. }
  345. if (isUlock)
  346. {
  347. return isUlock;
  348. }
  349. }
  350. return false;
  351. }
  352. public void CeekEventCompletes(int type, int[] value)
  353. {
  354. foreach (var playerDataEventLinkData in AccountFileInfo.Instance.playerData.eventList)
  355. {
  356. foreach (var eventLinkData in playerDataEventLinkData.eventLinks)
  357. {
  358. foreach (var eventConditionData in eventLinkData.eventConditions)
  359. {
  360. CeekTaskComplete(eventConditionData, type, value);
  361. }
  362. }
  363. }
  364. EventManager.Instance.Dispatch(CustomEventType.RemoveEvent, null);
  365. }
  366. public void CeekTaskComplete(AccountFileInfo.EventConditionData conditionData, int type, int[] value)
  367. {
  368. EventConditionConfig eventConditionConfig = ConfigComponent.Instance.Get<EventConditionConfig>(conditionData.eventCondition);
  369. if (IsEvenkLinkComplete(conditionData))
  370. return;
  371. switch (type)
  372. {
  373. //检测背包道具
  374. case 1:
  375. if (eventConditionConfig.ConditionType == 1)
  376. {
  377. conditionData.fishCount += (int)PlayerManager.Instance.BagController.GetItemCount(eventConditionConfig.ConditionPara[0]);
  378. if (IsEvenkLinkComplete(conditionData))
  379. {
  380. // CompleteTask(conditionData.guid);
  381. }
  382. }
  383. break;
  384. //境界检测
  385. case 3:
  386. if (eventConditionConfig.ConditionType == 3 && PlayerManager.Instance.myHero.powerUpConfig.ID >= eventConditionConfig.ConditionPara[0])
  387. {
  388. conditionData.fishCount++;
  389. if (IsEvenkLinkComplete(conditionData))
  390. {
  391. // CompleteTask(conditionData.guid);
  392. }
  393. }
  394. break;
  395. //战斗胜利
  396. case 5:
  397. if (eventConditionConfig.ConditionType == 5 && eventConditionConfig.ConditionPara[0] == value[0])
  398. {
  399. conditionData.fishCount++;
  400. if (IsEvenkLinkComplete(conditionData))
  401. {
  402. // CompleteEvent(conditionData.guid);
  403. }
  404. }
  405. break;
  406. //获得道具
  407. case 6:
  408. if (eventConditionConfig.ConditionType == 6 && eventConditionConfig.ConditionPara[0] == value[0])
  409. {
  410. conditionData.fishCount += value[1];
  411. if (IsEvenkLinkComplete(conditionData))
  412. {
  413. // CompleteEvent(conditionData.guid);
  414. }
  415. }
  416. break;
  417. }
  418. AccountFileInfo.Instance.SavePlayerData();
  419. }
  420. private void CompleteTask(object taskID)
  421. {
  422. }
  423. /// <summary>
  424. /// 检查事件是否满足触发条件。
  425. /// </summary>
  426. private bool CanTriggerEvent(int eventID)
  427. {
  428. var evt = eventConfigs.Find(e => e.ID == eventID);
  429. if (evt.ID == 0)
  430. return false;
  431. switch (evt.EventConditionId)
  432. {
  433. //背包道具检测
  434. case 1:
  435. return PlayerManager.Instance.BagController.GetItemCount(evt.EventValue[0]) >= evt.EventCount;
  436. //境界判断
  437. case 2:
  438. return PlayerManager.Instance.myHero.level >= evt.EventCount;
  439. //概率判断
  440. case 3:
  441. int randomValue1 = Random.Range(0, 1001);
  442. return randomValue1 <= evt.EventCount;
  443. }
  444. return true;
  445. }
  446. /// <summary>
  447. /// 完成事件
  448. /// </summary>
  449. /// <param name="eventID">事件ID</param>
  450. public void CompleteEvent(int evtId)
  451. {
  452. isTriggerEvent = false;
  453. LogTool.Log($"完成挂机事件{evtId}");
  454. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(evtId);
  455. AccountFileInfo.EventList eventList = new AccountFileInfo.EventList();
  456. eventList.eventID = evtId;
  457. AccountFileInfo.Instance.playerData.completeEvents.Add(eventList);
  458. if (PlayerManager.Instance.CurrentPlaces.progress < 100)
  459. PlayerManager.Instance.CurrentPlaces.progress += eventConfig.Score;
  460. AccountFileInfo.Instance.SavePlayerData();
  461. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  462. EventManager.Instance.Dispatch(CustomEventType.CompleteEvent, null);
  463. }
  464. /// <summary>
  465. /// 完成事件
  466. /// </summary>
  467. /// <param name="eventID">事件ID</param>
  468. public void CompleteEvent(AccountFileInfo.EventList eventList, bool isTriggerEvent = false)
  469. {
  470. this.isTriggerEvent = isTriggerEvent;
  471. LogTool.Log($"完成事件{eventList.eventID}");
  472. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  473. AccountFileInfo.EventList ceventList = AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce => ce.eventID == eventList.eventID);
  474. if (ceventList == null)
  475. {
  476. PlacesConfig[] placesConfigs = ConfigComponent.Instance.GetAll<PlacesConfig>();
  477. int pId = 0;
  478. for (var i = 0; i < placesConfigs.Length; i++)
  479. {
  480. if (placesConfigs[i].MainTaskID == null || placesConfigs[i].ZhixianID == null)
  481. continue;
  482. if (placesConfigs[i].MainTaskID.Contains(eventConfig.ID) ||
  483. placesConfigs[i].ZhixianID.Contains(eventConfig.ID))
  484. {
  485. pId = placesConfigs[i].ID;
  486. break;
  487. }
  488. }
  489. if (pId == 0)
  490. {
  491. PlayerManager.Instance.CurrentPlaces.progress += eventConfig.Score;
  492. }
  493. else
  494. {
  495. PlayerManager.Instance.GetPlacesData(pId).progress += eventConfig.Score;
  496. }
  497. }
  498. AccountFileInfo.Instance.playerData.completeEvents.Add(eventList);
  499. // if (PlayerManager.Instance.CurrentPlaces.progress < 100)
  500. //
  501. AccountFileInfo.Instance.playerData.eventList.Remove(eventList);
  502. AccountFileInfo.Instance.SavePlayerData();
  503. if (eventConfig.EventTriggerType == 4)
  504. {
  505. TaskInfoPanel.OpenPanel(eventList.eventID, "任务完成");
  506. }
  507. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  508. EventManager.Instance.Dispatch(CustomEventType.CompleteEvent, null);
  509. onCompleteCallback?.Invoke();
  510. onCompleteCallback = null;
  511. }
  512. /// <summary>
  513. /// 完成事件
  514. /// </summary>
  515. /// <param name="eventID">事件ID</param>
  516. public void CompleteEvent(AccountFileInfo.EventLinkData eventLinkData)
  517. {
  518. }
  519. /// <summary>
  520. /// 取消事件
  521. /// </summary>
  522. /// <param name="eventID">事件ID</param>
  523. public void CancelEvent(AccountFileInfo.EventList eventList)
  524. {
  525. LogTool.Log($"取消事件{eventList.eventID}");
  526. isTriggerEvent = false;
  527. EventManager.Instance.Dispatch(CustomEventType.CompleteEvent, null);
  528. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  529. onCompleteCallback?.Invoke();
  530. onCompleteCallback = null;
  531. }
  532. public void RemoveEvent(AccountFileInfo.EventList eventList)
  533. {
  534. AccountFileInfo.Instance.playerData.eventList.Remove(eventList);
  535. AccountFileInfo.Instance.SavePlayerData();
  536. EventManager.Instance.Dispatch(CustomEventType.RemoveEvent, null);
  537. }
  538. /// <summary>
  539. /// 获得主线事件
  540. /// </summary>
  541. /// <returns></returns>
  542. public AccountFileInfo.EventList GetMainEventDta()
  543. {
  544. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  545. {
  546. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  547. if (eventConfig.EventTriggerType == 4)
  548. {
  549. return eventList;
  550. }
  551. }
  552. return null;
  553. }
  554. }