EventSystemManager.cs 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288
  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.Bag;
  11. using GameLogic.Combat;
  12. using GameLogic.Combat.CombatTool;
  13. using GameLogic.Player;
  14. using UnityEngine;
  15. using Utility;
  16. using EventConfig = Excel2Json.EventConfig;
  17. using Random = UnityEngine.Random;
  18. public class EventSystemManager : Singleton<EventSystemManager>
  19. {
  20. List<EventConfig> eventConfigs = new List<EventConfig>();
  21. public AccountFileInfo.EventList CurrentEventList;
  22. public bool isTriggerEvent;
  23. List<DivineSenseConfig> divineSenseConfigs = new List<DivineSenseConfig>();
  24. List<int> qualitys = new List<int>() { 1, 2, 3, 4, 5, 6 };
  25. public bool isOpenUi;
  26. Action onCompleteCallback;
  27. public Map<int, List<EventConfig>> eventConfigsMap = new Map<int, List<EventConfig>>();
  28. // public Map<int, AccountFileInfo.EventConditionData> EventConditionDataMap = new Map<int, AccountFileInfo.EventConditionData>();
  29. public void CustomInit()
  30. {
  31. eventConfigs = ConfigComponent.Instance.GetAll<EventConfig>().ToList();
  32. divineSenseConfigs = ConfigComponent.Instance.GetAll<DivineSenseConfig>().ToList();
  33. foreach (var eventConfig in eventConfigs)
  34. {
  35. if (eventConfig.XiantuID != 0)
  36. {
  37. if (eventConfigsMap.ContainsKey(eventConfig.XiantuID))
  38. {
  39. eventConfigsMap[eventConfig.XiantuID].Add(eventConfig);
  40. }
  41. else
  42. {
  43. eventConfigsMap.Add(eventConfig.XiantuID, new List<EventConfig>() { eventConfig });
  44. }
  45. }
  46. }
  47. //进入游戏全部检测一次
  48. foreach (var playerDataEventLinkData in AccountFileInfo.Instance.playerData.eventList)
  49. {
  50. foreach (var eventLinkData in playerDataEventLinkData.eventLinks)
  51. {
  52. CeekEventGroupComplete(eventLinkData.eventConditions);
  53. }
  54. }
  55. StaticUpdater.Instance.AddRenderUpdateCallBack(Update);
  56. EventManager.Instance.AddEventListener(CustomEventType.DetectRandomEvent, RenfenceRandomEvent);
  57. EventManager.Instance.AddEventListener(CustomEventType.AddItem, ItemUpdate);
  58. EventManager.Instance.AddEventListener(CustomEventType.JingJieUpgrade, JingJieUpgrade);
  59. EventManager.Instance.AddEventListener(CustomEventType.CancelEvent, Cancel);
  60. }
  61. private void Cancel(IEventData e)
  62. {
  63. CancelEvent();
  64. }
  65. private void JingJieUpgrade(IEventData e)
  66. {
  67. CeekEventCompletes(3, null);
  68. }
  69. private void ItemUpdate(IEventData e)
  70. {
  71. ItemUpdateData data = e as ItemUpdateData;
  72. CeekEventCompletes(1, new[] { data.ItemInfo.itemID });
  73. CeekEventCompletes(6, new[] { data.ItemInfo.itemID, data.Count });
  74. }
  75. private void RenfenceRandomEvent(IEventData e)
  76. {
  77. DetectRandomEvents();
  78. }
  79. private float timer = 0;
  80. private void Update()
  81. {
  82. timer += Time.deltaTime;
  83. if (timer > 1)
  84. {
  85. timer = 0;
  86. HeroPowerUpConfig heroPowerUpConfig = PlayerManager.Instance.myHero.powerUpConfig;
  87. if (AccountFileInfo.Instance.playerData.divineSensePoint < heroPowerUpConfig.ShenshiMax)
  88. {
  89. if (AccountFileInfo.Instance.playerData.todayDivineSensePoint <
  90. PlayerManager.Instance.gameConstantConfig.shenshiPointRecSPD[0])
  91. {
  92. AccountFileInfo.Instance.playerData.todayDivineSensePoint +=
  93. PlayerManager.Instance.gameConstantConfig.shenshiPointRecSPD[1];
  94. AccountFileInfo.Instance.playerData.divineSensePoint +=
  95. PlayerManager.Instance.gameConstantConfig.shenshiPointRecSPD[1];
  96. }
  97. else
  98. {
  99. AccountFileInfo.Instance.playerData.divineSensePoint +=
  100. PlayerManager.Instance.gameConstantConfig.shenshiPointRecSPD[2];
  101. }
  102. EventManager.Instance.Dispatch(CustomEventType.DivineSensePointChange, null);
  103. AccountFileInfo.Instance.SavePlayerData();
  104. }
  105. }
  106. }
  107. public List<AccountFileInfo.EventList> UseDivinesense(int useCount, List<ItemInfo> useItems)
  108. {
  109. //使用神识先移除完成的事件
  110. List<AccountFileInfo.EventList> removeEvents = new List<AccountFileInfo.EventList>();
  111. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  112. {
  113. if (eventList.isCompleted)
  114. {
  115. removeEvents.Add(eventList);
  116. }
  117. }
  118. foreach (var removeEvent in removeEvents)
  119. {
  120. AccountFileInfo.Instance.playerData.completeEvents.Add(removeEvent);
  121. AccountFileInfo.Instance.playerData.eventList.Remove(removeEvent);
  122. }
  123. AccountFileInfo.Instance.SavePlayerData();
  124. HeroPowerUpConfig heroPowerUpConfig = PlayerManager.Instance.myHero.powerUpConfig;
  125. int count = (int)(AccountFileInfo.Instance.playerData.divineSensePoint /
  126. PlayerManager.Instance.gameConstantConfig.DetectEventCount);
  127. if (count <= 0)
  128. {
  129. //神识值不够
  130. return null;
  131. }
  132. int maxCount = heroPowerUpConfig.ShenshiMax / PlayerManager.Instance.gameConstantConfig.DetectEventCount;
  133. count = count + GetShenShiCount() > maxCount ? maxCount - GetShenShiCount() : count;
  134. if (useCount > count)
  135. {
  136. LogTool.Error("神识值不够");
  137. return null;
  138. }
  139. CeekEventCompletes(8, new[] { 1 });
  140. EventManager.Instance.Dispatch(CustomEventType.DivineSensePointChange, null);
  141. var eventConfigs = DetectEvents(useCount, useItems);
  142. if (eventConfigs == null || eventConfigs.Count == 0)
  143. {
  144. TipMessagePanel.OpenTipMessagePanel("没有可以触发的事件");
  145. return default;
  146. }
  147. //扣除神识值 增加神识经验
  148. int xiaoHao = eventConfigs.Count * PlayerManager.Instance.gameConstantConfig.DetectEventCount;
  149. AccountFileInfo.Instance.playerData.divineSenseexp += xiaoHao;
  150. AccountFileInfo.Instance.playerData.divineSensePoint -= xiaoHao;
  151. // 神识升级逻辑
  152. UpDivinesense();
  153. AccountFileInfo.Instance.playerData.eventList.AddRange(eventConfigs);
  154. UpdateZuizhongEventData();
  155. AccountFileInfo.Instance.SavePlayerData();
  156. return eventConfigs;
  157. }
  158. public void UpdateZuizhongEventData()
  159. {
  160. AccountFileInfo.EventList eventList = AccountFileInfo.Instance.playerData.eventList.FirstOrDefault(e =>
  161. e.guid == AccountFileInfo.Instance.playerData.CurrentZuiZhongEventListId);
  162. if (eventList == null || eventList.guid == 0)
  163. {
  164. var mainEventData = GetMainEventDta();
  165. if (mainEventData != null)
  166. {
  167. AccountFileInfo.Instance.playerData.CurrentZuiZhongEventListId = mainEventData.guid;
  168. }
  169. else if (AccountFileInfo.Instance.playerData.eventList.Count > 0)
  170. {
  171. AccountFileInfo.Instance.playerData.CurrentZuiZhongEventListId =
  172. AccountFileInfo.Instance.playerData.eventList[0].guid;
  173. }
  174. }
  175. }
  176. private void UpDivinesense()
  177. {
  178. if (AccountFileInfo.Instance.playerData.divineSenseLevel >= divineSenseConfigs.Count)
  179. {
  180. return;
  181. }
  182. for (var i = AccountFileInfo.Instance.playerData.divineSenseLevel - 1; i < divineSenseConfigs.Count; i++)
  183. {
  184. if (AccountFileInfo.Instance.playerData.divineSenseexp >= divineSenseConfigs[i].exp)
  185. {
  186. AccountFileInfo.Instance.playerData.divineSenseexp -= divineSenseConfigs[i].exp;
  187. AccountFileInfo.Instance.playerData.divineSenseLevel = divineSenseConfigs[i + 1].ID;
  188. }
  189. }
  190. AccountFileInfo.Instance.SavePlayerData();
  191. }
  192. public int GetShenShiCount()
  193. {
  194. int count = 0;
  195. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  196. {
  197. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  198. if (eventList == null || eventList.eventID == 0 || eventList.isCompleted ||
  199. eventConfig.EventTriggerType == 4)
  200. continue;
  201. if (eventConfig.EventTriggerType != 5)
  202. {
  203. count++;
  204. }
  205. }
  206. return count;
  207. }
  208. public bool BagIsEvent(int eventID)
  209. {
  210. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  211. {
  212. if (eventList.eventID == eventID)
  213. {
  214. return true;
  215. }
  216. }
  217. return false;
  218. }
  219. public int GetBagEventCount(int eventID)
  220. {
  221. int count = 0;
  222. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  223. {
  224. if (eventList.eventID == eventID)
  225. {
  226. count++;
  227. }
  228. }
  229. return count;
  230. }
  231. // public bool IsRefenceEvent(int eventID)
  232. // {
  233. // EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventID);
  234. // }
  235. public bool IsEventTrigger(int eventID)
  236. {
  237. foreach (var eventList in AccountFileInfo.Instance.playerData.completeEvents)
  238. {
  239. if (eventList.eventID == eventID)
  240. {
  241. return true;
  242. }
  243. }
  244. return false;
  245. }
  246. private List<AccountFileInfo.EventList> DetectEvents(int eventCount, List<ItemInfo> useItems)
  247. {
  248. SmallPlacesConfig smallPlacesConfig =
  249. ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);
  250. PlacesConfig bigMap = ConfigComponent.Instance.Get<PlacesConfig>(smallPlacesConfig.PlacesId);
  251. DivineSenseConfig divineSenseConfig =
  252. ConfigComponent.Instance.Get<DivineSenseConfig>(AccountFileInfo.Instance.playerData.divineSenseLevel);
  253. LogTool.Log($"使用神识,神识等级:{AccountFileInfo.Instance.playerData.divineSenseLevel}");
  254. List<AccountFileInfo.EventList> eventLists = new List<AccountFileInfo.EventList>();
  255. //取消根据主线进度刷新啊支线任务
  256. //现在改成优先刷新满足条件的支线任务然后判断概率是否刷新
  257. //找出可以刷新的支线任务
  258. // if (bigMap.ZhixianActivatedPercentage != null)
  259. // {
  260. // List<EventConfig> zhiXianEvents = new List<EventConfig>();
  261. // for (var i = 0; i < bigMap.ZhixianActivatedPercentage.Length; i++)
  262. // {
  263. // if (PlayerManager.Instance.PlacesBl >= bigMap.ZhixianActivatedPercentage[i])
  264. // {
  265. // if (!BagIsEvent(bigMap.ZhixianID[i]) && !IsEventTrigger(bigMap.ZhixianID[i]) &&
  266. // CanTriggerEvent(bigMap.ZhixianID[i]))
  267. // {
  268. // zhiXianEvents.Add(ConfigComponent.Instance.Get<EventConfig>(bigMap.ZhixianID[i]));
  269. // }
  270. // }
  271. // }
  272. //
  273. // foreach (var c in zhiXianEvents)
  274. // {
  275. // AccountFileInfo.EventList eventList = AddEvent(c.ID);
  276. // if (eventList != null)
  277. // {
  278. // eventLists.Add(eventList);
  279. // eventCount--;
  280. //
  281. // if (eventCount == 0)
  282. // {
  283. // return eventLists;
  284. // }
  285. // }
  286. // }
  287. // }
  288. for (int i = 0; i < eventCount; i++)
  289. {
  290. //刷新支线任务
  291. List<EventConfig> zhiXianEvents = eventConfigs.Where(e =>
  292. e.EventTriggerType == 6 && !BagIsEvent(e.ID) && !IsEventTrigger(e.ID) &&
  293. ((e.SmallPlacesId == 0 && e.placeID == 0) ||
  294. (e.SmallPlacesId != 0 && e.SmallPlacesId == smallPlacesConfig.ID) ||
  295. (e.SmallPlacesId == 0 && e.placeID == smallPlacesConfig.PlacesId)) &&
  296. eventLists.FirstOrDefault(el => el.eventID == e.ID) == null && CanTriggerEvent(e.ID)).ToList();
  297. if (zhiXianEvents.Count > 0)
  298. {
  299. var zhixianEvnetConfig = zhiXianEvents[0];
  300. int randomValueZhiXian = Random.Range(0, 101);
  301. if (randomValueZhiXian <= zhixianEvnetConfig.RefreshProbability)
  302. {
  303. AccountFileInfo.EventList eventList = AddEvent(zhixianEvnetConfig.ID);
  304. if (eventList != null)
  305. {
  306. eventLists.Add(eventList);
  307. LogTool.Log("刷新支线任务:id:" + zhixianEvnetConfig.ID);
  308. continue;
  309. }
  310. }
  311. }
  312. int randomValue3 = Random.Range(0, 101);
  313. //先刷事件关联的事件
  314. if (randomValue3 <= PlayerManager.Instance.gameConstantConfig.RefreshRelevanceEventProbability)
  315. {
  316. bool isRefence = false;
  317. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  318. {
  319. foreach (var eventListEventLink in eventList.eventLinks)
  320. {
  321. foreach (var eventConditionData in eventListEventLink.eventConditions)
  322. {
  323. if (IsEvenkLinkComplete(eventConditionData))
  324. continue;
  325. EventConditionConfig eventConditionConfig =
  326. ConfigComponent.Instance.Get<EventConditionConfig>(eventConditionData.eventCondition);
  327. for (var i1 = 0; i1 < eventConditionConfig.RelatedEvents?.Length; i1++)
  328. {
  329. EventConfig eventConfig1 =
  330. ConfigComponent.Instance.Get<EventConfig>(eventConditionConfig.RelatedEvents[i1]);
  331. int count = 0;
  332. foreach (var list in eventLists)
  333. {
  334. if (list.eventID == eventConfig1.ID)
  335. {
  336. count++;
  337. }
  338. }
  339. if (GetBagEventCount(eventConfig1.ID) + count >= eventConfig1.RefreshCount)
  340. {
  341. continue;
  342. }
  343. int randomValue4 = Random.Range(0, 101);
  344. if (randomValue4 <= eventConfig1.RefreshProbability)
  345. {
  346. var eventList1 = AddEvent(eventConfig1.ID);
  347. if (eventList1 != null)
  348. {
  349. eventLists.Add(AddEvent(eventConfig1.ID));
  350. isRefence = true;
  351. }
  352. else
  353. {
  354. LogTool.Error("管理事件没有刷新出来 id:" + eventConfig1.ID);
  355. }
  356. break;
  357. }
  358. }
  359. }
  360. }
  361. }
  362. if (isRefence)
  363. continue;
  364. }
  365. //概率
  366. ItemInfo itemInfoType1 = null;
  367. //类型
  368. ItemInfo itemInfoType2 = null;
  369. foreach (var itemInfo in useItems)
  370. {
  371. if (itemInfo.config.associateID == 6)
  372. {
  373. itemInfoType1 = itemInfo;
  374. }
  375. else if (itemInfo.config.associateID == 7)
  376. {
  377. itemInfoType2 = itemInfo;
  378. }
  379. }
  380. float[] QualityBonusChance = divineSenseConfig.QualityBonusChance.ToArray();
  381. if (itemInfoType1 != null)
  382. {
  383. QualityBonusChance[itemInfoType1.config.associateVlaue[0] - 1] *=
  384. itemInfoType1.config.associateVlaue[1];
  385. }
  386. //先掉落出品质
  387. int quality = UtilTools.GetRandomByWeight(qualitys, QualityBonusChance);
  388. // 获取通用事件
  389. List<EventConfig> globalEvents = eventConfigs.Where(e =>
  390. e.EventTriggerType == 1 && e.EventQuality == quality &&
  391. eventLists.FirstOrDefault(el => el.eventID == e.ID) == null && CanTriggerEvent(e.ID) &&
  392. CanEventType(e.ID, itemInfoType2)).ToList();
  393. //场景特定事件
  394. List<EventConfig> candidateEvents = eventConfigs.Where(e =>
  395. e.EventQuality == quality &&
  396. eventLists.FirstOrDefault(el => el.eventID == e.ID) == null && CanTriggerEvent(e.ID) &&
  397. CanEventType(e.ID, itemInfoType2)).ToList();
  398. if (candidateEvents.Count == 0 && globalEvents.Count == 0)
  399. {
  400. continue;
  401. }
  402. int randomValue1 = Random.Range(0, 101);
  403. // 达到怪率刷新场景特定事件
  404. //不然刷新通用事件(每个地图都可以刷的)
  405. if (randomValue1 < bigMap.DivineSenseGeneralProbability && candidateEvents.Count > 0)
  406. {
  407. int randomValue2 = Random.Range(0, candidateEvents.Count);
  408. var eventList = AddEvent(candidateEvents[randomValue2].ID);
  409. if (eventList != null)
  410. {
  411. eventLists.Add(eventList);
  412. }
  413. else
  414. {
  415. LogTool.Error("场景没有刷新出来 id:" + candidateEvents[randomValue2].ID);
  416. }
  417. }
  418. else if (globalEvents.Count > 0)
  419. {
  420. List<int> quanzhong = new List<int>();
  421. for (var i1 = 0; i1 < globalEvents.Count; i1++)
  422. {
  423. quanzhong.Add(globalEvents[i1].RefreshProbability);
  424. }
  425. var eventconfig = UtilTools.GetRandomByWeight(globalEvents, quanzhong.ToArray());
  426. // int randomValue2 = Random.Range(0, globalEvents.Count);
  427. var eventList = AddEvent(eventconfig.ID);
  428. if (eventList != null)
  429. {
  430. eventLists.Add(eventList);
  431. }
  432. else
  433. {
  434. LogTool.Error("通用事件没有刷新出来 id:" + eventconfig.ID);
  435. }
  436. }
  437. }
  438. if (eventLists.Count == 0)
  439. {
  440. LogTool.Error("没有可以触发的事件");
  441. return null;
  442. }
  443. return eventLists;
  444. }
  445. //添加事件
  446. public AccountFileInfo.EventList AddEvent(int eventID)
  447. {
  448. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventID);
  449. AccountFileInfo.EventList eventList = null;
  450. if (eventConfig.ID == 0)
  451. {
  452. return null;
  453. }
  454. //主线任务只能刷一次
  455. if (eventConfig.EventTriggerType == 4 || eventConfig.EventTriggerType == 6)
  456. {
  457. AccountFileInfo.EventList e =
  458. AccountFileInfo.Instance.playerData.eventList.FirstOrDefault(e => e.eventID == eventID);
  459. if (e == null)
  460. {
  461. e = AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(e => e.eventID == eventID);
  462. if (e == null)
  463. {
  464. eventList = new AccountFileInfo.EventList();
  465. eventList.eventID = eventID;
  466. }
  467. else
  468. {
  469. return null;
  470. }
  471. eventList.guid = IdGenerater.GenerateIdInt();
  472. eventList.curStep = eventConfig.EventLinksId[0];
  473. eventList.selectEventLinkIds.Add(eventConfig.EventLinksId[0]);
  474. //记录英雄等级 神识刷出来的战斗等级不变
  475. if (PlayerManager.Instance.myHero != null)
  476. eventList.heroLevel = PlayerManager.Instance.myHero.level.Value;
  477. }
  478. }
  479. else
  480. {
  481. eventList = new AccountFileInfo.EventList();
  482. eventList.eventID = eventID;
  483. eventList.guid = IdGenerater.GenerateIdInt();
  484. eventList.curStep = eventConfig.EventLinksId[0];
  485. eventList.selectEventLinkIds.Add(eventConfig.EventLinksId[0]);
  486. //记录英雄等级 神识刷出来的战斗等级不变
  487. if (PlayerManager.Instance.myHero != null)
  488. eventList.heroLevel = PlayerManager.Instance.myHero.level.Value;
  489. }
  490. //初始化神识链条,用于监听条件是否完成
  491. if (eventList != null && eventConfig.EventType != 2)
  492. {
  493. foreach (var i in eventConfig.EventLinksId)
  494. {
  495. EventLinkConfig eventLinkConfig = ConfigComponent.Instance.Get<EventLinkConfig>(i);
  496. AccountFileInfo.EventLinkData eventLinkData = new AccountFileInfo.EventLinkData();
  497. eventLinkData.eventId = eventID;
  498. eventLinkData.eventLinkId = i;
  499. if (eventLinkConfig.ConditionId != null)
  500. {
  501. foreach (var i1 in eventLinkConfig.ConditionId)
  502. {
  503. AccountFileInfo.EventConditionData
  504. eventConditionData = new AccountFileInfo.EventConditionData();
  505. eventConditionData.eventId = eventList.eventID;
  506. eventConditionData.eventCondition = i1;
  507. eventLinkData.eventConditions.Add(eventConditionData);
  508. //初始化先检测一些条件
  509. CeekTaskComplete(eventConditionData, 1, null);
  510. CeekTaskComplete(eventConditionData, 3, null);
  511. }
  512. }
  513. eventList.eventLinks.Add(eventLinkData);
  514. }
  515. }
  516. return eventList;
  517. }
  518. /// <summary>
  519. /// 触发随机事件
  520. /// </summary>
  521. public void DetectRandomEvents()
  522. {
  523. if (isTriggerEvent)
  524. return;
  525. if (isOpenUi)
  526. return;
  527. // 获取随机事件
  528. List<EventConfig> randomEvents =
  529. eventConfigs.Where(e => e.EventTriggerType == 2 && CanTriggerEvent(e.ID)).ToList();
  530. if (randomEvents.Count == 0)
  531. {
  532. LogTool.Warning("没有可以刷新的事件");
  533. return;
  534. }
  535. int idex = Random.Range(0, randomEvents.Count);
  536. TriggerEvent(randomEvents[idex]);
  537. }
  538. /// <summary>
  539. /// 挂机事件触发
  540. /// </summary>
  541. public void TriggerEvent(EventConfig evt)
  542. {
  543. if (isTriggerEvent)
  544. return;
  545. isTriggerEvent = true;
  546. LogTool.Log($"触发事件: {evt.EventName} (ID: {evt.ID}, 品质: {evt.EventQuality})");
  547. CombatDrive.Instance.CombatController.ChangeState(CombatController.idle);
  548. AccountFileInfo.EventList eventList = AddEvent(evt.ID);
  549. CurrentEventList = eventList;
  550. DialogueManager.Instance.StartDialogue(eventList, evt.EventLinksId[0], evt.ID,
  551. () => { CompleteEvent(evt.ID); });
  552. }
  553. /// <summary>
  554. /// 其他类型事件触发
  555. /// </summary>
  556. public async CTask TriggerEvent(AccountFileInfo.EventList evt, Action oncompleteCallBack = null,
  557. Action uiOpenOverCallBack = null)
  558. {
  559. // ChancleEvent();
  560. if (isTriggerEvent)
  561. return;
  562. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(evt.eventID);
  563. SmallPlacesConfig smallPlacesConfig =
  564. ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);
  565. if (eventConfig.SmallPlacesId > 0)
  566. {
  567. if (eventConfig.SmallPlacesId != PlayerManager.Instance.CurrentsmallPlaces.id)
  568. {
  569. AccountFileInfo.SmallPlacesData lastSmallPlacesData =
  570. PlayerManager.Instance.GetSmallPlacesData(eventConfig.SmallPlacesId - 1);
  571. SmallPlacesConfig lastSmallPlacesConfig =
  572. ConfigComponent.Instance.Get<SmallPlacesConfig>(eventConfig.SmallPlacesId - 1);
  573. SmallPlacesConfig currentSmallPlacesConfig =
  574. ConfigComponent.Instance.Get<SmallPlacesConfig>(eventConfig.SmallPlacesId);
  575. if (currentSmallPlacesConfig.ID > 1 && (lastSmallPlacesData == null ||
  576. lastSmallPlacesData.completionEventCount <
  577. lastSmallPlacesConfig.CompletionEventCount))
  578. {
  579. TipMessagePanel tipMessagePanel = await TipMessagePanel.OpenTipMessagePanel(
  580. LanguageManager.Instance.Text(10379,
  581. LanguageManager.Instance.Text(lastSmallPlacesConfig.placeName),
  582. lastSmallPlacesConfig.CompletionEventCount));
  583. if (PlayerGuideManager.Instance.GuideIsCanDo(3))
  584. {
  585. PlayerGuideManager.Instance.SetGuid(3);
  586. }
  587. return;
  588. }
  589. if (lastSmallPlacesConfig.UnlockEnvetid != 0)
  590. {
  591. AccountFileInfo.EventList eventList =
  592. AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce =>
  593. ce.eventID == lastSmallPlacesConfig.UnlockEnvetid);
  594. if (eventList == null || !eventList.isCompleted)
  595. {
  596. var econfig = ConfigComponent.Instance.Get<EventConfig>(lastSmallPlacesConfig.UnlockEnvetid);
  597. TipMessagePanel.OpenTipMessagePanel(LanguageManager.Instance.Text(10380,
  598. LanguageManager.Instance.Text(lastSmallPlacesConfig.placeName),
  599. LanguageManager.Instance.Text(econfig.EventName)));
  600. return;
  601. }
  602. }
  603. SmallPlacesConfig SmallPlacesConfig =
  604. ConfigComponent.Instance.Get<SmallPlacesConfig>(eventConfig.SmallPlacesId);
  605. CTask<bool> cT = CTask<bool>.Create();
  606. PlacesInfoPanel.OpenPanel(SmallPlacesConfig.PlacesId, (b) => { cT.SetResult(b); });
  607. await cT;
  608. if (eventConfig.SmallPlacesId != PlayerManager.Instance.CurrentsmallPlaces.id)
  609. {
  610. return;
  611. }
  612. // if (!cT.Result)
  613. // {
  614. // return;
  615. // }
  616. }
  617. }
  618. else if (eventConfig.placeID > 0)
  619. {
  620. if (eventConfig.placeID != smallPlacesConfig.PlacesId)
  621. {
  622. CTask<bool> cT = CTask<bool>.Create();
  623. PlacesInfoPanel.OpenPanel(eventConfig.placeID, (b) => { cT.SetResult(b); });
  624. await cT;
  625. smallPlacesConfig =
  626. ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);
  627. if (eventConfig.placeID != smallPlacesConfig.PlacesId)
  628. {
  629. return;
  630. }
  631. }
  632. }
  633. CTask cTask = CTask.Create();
  634. this.onCompleteCallback = oncompleteCallBack;
  635. isTriggerEvent = true;
  636. LogTool.Log(
  637. $"触发事件: {LanguageManager.Instance.Text(eventConfig.EventName)} (ID: {eventConfig.ID}, 品质: {eventConfig.EventQuality})");
  638. int dialogueID = 0;
  639. if (evt.curStep == 0)
  640. {
  641. dialogueID = eventConfig.EventLinksId[0];
  642. }
  643. else
  644. {
  645. dialogueID = evt.curStep;
  646. }
  647. CurrentEventList = evt;
  648. CombatDrive.Instance.CombatController.ChangeState(CombatController.idle);
  649. await DialogueManager.Instance.StartDialogue(CurrentEventList, dialogueID, eventConfig.ID, () =>
  650. {
  651. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(CurrentEventList.eventID);
  652. if (eventConfig.EventTriggerType != 4)
  653. {
  654. CompleteEvent(CurrentEventList);
  655. }
  656. else
  657. {
  658. CurrentEventList.isCompleted1 = true;
  659. AccountFileInfo.Instance.SavePlayerData();
  660. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  661. onCompleteCallback?.Invoke();
  662. onCompleteCallback = null;
  663. EventManager.Instance.Dispatch(CustomEventType.CompleteUpdate, null);
  664. }
  665. cTask.SetResult();
  666. }, () =>
  667. {
  668. CancelEvent(CurrentEventList);
  669. cTask.SetResult();
  670. });
  671. uiOpenOverCallBack?.Invoke();
  672. DivineSenceEventPreviewPanel divineSenceEventPreviewPanel =
  673. UIManager.Instance.GetComponent<DivineSenceEventPreviewPanel>();
  674. AppBarPanel appBarPanel = UIManager.Instance.GetComponent<AppBarPanel>();
  675. // DivineSenceInfoPanel divineSenceInfoPanel = UIManager.Instance.GetComponent<DivineSenceInfoPanel>();
  676. if (divineSenceEventPreviewPanel != null && !divineSenceEventPreviewPanel.IsClose)
  677. {
  678. divineSenceEventPreviewPanel.GObjectPoolInterface.SetActive(false);
  679. }
  680. // if (appBarPanel != null && !appBarPanel.IsClose)
  681. // {
  682. // appBarPanel.GObjectPoolInterface.SetActive(false);
  683. // }
  684. // if (divineSenceInfoPanel != null)
  685. // {
  686. // divineSenceInfoPanel.GObjectPoolInterface.SetActive(false);
  687. // }
  688. await cTask;
  689. if (divineSenceEventPreviewPanel != null && !divineSenceEventPreviewPanel.IsClose)
  690. {
  691. divineSenceEventPreviewPanel.GObjectPoolInterface.SetActive(true);
  692. }
  693. if (appBarPanel != null && !appBarPanel.IsClose)
  694. {
  695. appBarPanel.GObjectPoolInterface.SetActive(true);
  696. }
  697. // if (divineSenceInfoPanel != null)
  698. // {
  699. // divineSenceInfoPanel.GObjectPoolInterface.SetActive(true);
  700. // }
  701. }
  702. //任务是否完成
  703. public bool IsEvenkLinkComplete(AccountFileInfo.EventConditionData eventCondition)
  704. {
  705. EventConditionConfig eventConditionConfig =
  706. ConfigComponent.Instance.Get<EventConditionConfig>(eventCondition.eventCondition);
  707. if (eventCondition != null)
  708. {
  709. return eventCondition.fishCount >= eventConditionConfig.finishCount;
  710. }
  711. return false;
  712. }
  713. public bool CeekEventGroupComplete(List<AccountFileInfo.EventConditionData> eventConditions)
  714. {
  715. Map<int, List<AccountFileInfo.EventConditionData>> eventConditionDataGroup =
  716. new Map<int, List<AccountFileInfo.EventConditionData>>();
  717. foreach (var eventConditionData in eventConditions)
  718. {
  719. EventConditionConfig eventConditionConfig =
  720. ConfigComponent.Instance.Get<EventConditionConfig>(eventConditionData.eventCondition);
  721. if (!eventConditionDataGroup.ContainsKey(eventConditionConfig.Operation))
  722. {
  723. eventConditionDataGroup.Add(eventConditionConfig.Operation,
  724. new List<AccountFileInfo.EventConditionData>());
  725. }
  726. eventConditionDataGroup[eventConditionConfig.Operation].Add(eventConditionData);
  727. }
  728. bool isUlock = true;
  729. //分组检测 其中一个组绑定成功就可以执行
  730. foreach (var keyValuePair in eventConditionDataGroup)
  731. {
  732. isUlock = true;
  733. foreach (var eventConditionData in keyValuePair.Value)
  734. {
  735. if (!IsEvenkLinkComplete(eventConditionData))
  736. {
  737. isUlock = false;
  738. }
  739. }
  740. if (isUlock)
  741. {
  742. return isUlock;
  743. }
  744. }
  745. return isUlock;
  746. }
  747. public void CeekEventCompletes(int type, int[] value)
  748. {
  749. foreach (var playerDataEventLinkData in AccountFileInfo.Instance.playerData.eventList)
  750. {
  751. foreach (var eventLinkData in playerDataEventLinkData.eventLinks)
  752. {
  753. foreach (var eventConditionData in eventLinkData.eventConditions)
  754. {
  755. CeekTaskComplete(eventConditionData, type, value);
  756. }
  757. }
  758. }
  759. EventManager.Instance.Dispatch(CustomEventType.RemoveEvent, null);
  760. }
  761. public void CeekTaskComplete(AccountFileInfo.EventConditionData conditionData, int type, int[] value)
  762. {
  763. EventConditionConfig eventConditionConfig =
  764. ConfigComponent.Instance.Get<EventConditionConfig>(conditionData.eventCondition);
  765. if (IsEvenkLinkComplete(conditionData))
  766. return;
  767. switch (type)
  768. {
  769. //检测背包道具
  770. case 1:
  771. if (eventConditionConfig.ConditionType == 1)
  772. {
  773. conditionData.fishCount +=
  774. (int)PlayerManager.Instance.BagController.GetItemCount(eventConditionConfig.ConditionPara[0]);
  775. if (IsEvenkLinkComplete(conditionData))
  776. {
  777. // CompleteTask(conditionData.guid);
  778. }
  779. }
  780. break;
  781. //境界检测
  782. case 3:
  783. if (eventConditionConfig.ConditionType == 3 && PlayerManager.Instance.myHero.powerUpConfig.ID >=
  784. eventConditionConfig.ConditionPara[0])
  785. {
  786. conditionData.fishCount++;
  787. if (IsEvenkLinkComplete(conditionData))
  788. {
  789. // CompleteTask(conditionData.guid);
  790. }
  791. }
  792. break;
  793. //战斗胜利
  794. case 5:
  795. if (eventConditionConfig.ConditionType == 5 && eventConditionConfig.ConditionPara[0] == value[0])
  796. {
  797. conditionData.fishCount++;
  798. if (IsEvenkLinkComplete(conditionData))
  799. {
  800. // CompleteEvent(conditionData.guid);
  801. }
  802. }
  803. break;
  804. //获得道具
  805. case 6:
  806. if (eventConditionConfig.ConditionType == 6 && eventConditionConfig.ConditionPara[0] == value[0])
  807. {
  808. conditionData.fishCount += value[1];
  809. if (IsEvenkLinkComplete(conditionData))
  810. {
  811. // CompleteEvent(conditionData.guid);
  812. }
  813. }
  814. break;
  815. //使用神识
  816. case 8:
  817. if (eventConditionConfig.ConditionType == 8)
  818. {
  819. conditionData.fishCount += value[0];
  820. if (IsEvenkLinkComplete(conditionData))
  821. {
  822. }
  823. }
  824. break;
  825. }
  826. AccountFileInfo.Instance.SavePlayerData();
  827. }
  828. private void CompleteTask(object taskID)
  829. {
  830. }
  831. //指定type事件
  832. private bool CanEventType(int eventID, ItemInfo itemInfo)
  833. {
  834. if (itemInfo == null)
  835. {
  836. return true;
  837. }
  838. var evt = eventConfigs.Find(e => e.ID == eventID);
  839. if (evt.PrizeType != null && evt.PrizeType.Contains(itemInfo.config.associateVlaue[0]))
  840. {
  841. return true;
  842. }
  843. return false;
  844. }
  845. /// <summary>
  846. /// 检查事件是否满足触发条件。
  847. /// </summary>
  848. private bool CanTriggerEvent(int eventID)
  849. {
  850. var evt = eventConfigs.Find(e => e.ID == eventID);
  851. if (evt.ID == 0)
  852. return false;
  853. if (evt.EventConditionId == null)
  854. return true;
  855. for (var i = 0; i < evt.EventConditionId.Length; i++)
  856. {
  857. switch (evt.EventConditionId[i])
  858. {
  859. //背包道具检测
  860. case 1:
  861. return PlayerManager.Instance.BagController.GetItemCount(evt.EventValue[i]) >= evt.EventCount[i];
  862. //境界判断
  863. case 3:
  864. return PlayerManager.Instance.myHero.level >= evt.EventValue[i];
  865. //概率判断
  866. case 7:
  867. int randomValue1 = Random.Range(0, 1001);
  868. return randomValue1 <= evt.EventValue[i];
  869. //完成事件判断
  870. case 10:
  871. AccountFileInfo.EventList eventList =
  872. AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce =>
  873. ce.eventID == evt.EventValue[i]);
  874. return eventList != null;
  875. }
  876. }
  877. return true;
  878. }
  879. /// <summary>
  880. /// 完成事件
  881. /// </summary>
  882. /// <param name="eventID">事件ID</param>
  883. public void CompleteEvent(int evtId)
  884. {
  885. isTriggerEvent = false;
  886. LogTool.Log($"完成挂机事件{evtId}");
  887. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(evtId);
  888. AccountFileInfo.EventList eventList = new AccountFileInfo.EventList();
  889. eventList.eventID = evtId;
  890. AccountFileInfo.Instance.playerData.completeEvents.Add(eventList);
  891. int placesId = PlayerManager.Instance.GetMaxSmallPlacesId();
  892. AccountFileInfo.SmallPlacesData smallPlacesData = PlayerManager.Instance.GetSmallPlacesData(placesId);
  893. if (smallPlacesData != null)
  894. {
  895. smallPlacesData.completionEventCount++;
  896. }
  897. SmallPlacesConfig smallPlacesConfig =
  898. ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);
  899. AccountFileInfo.PlacesData placesData = PlayerManager.Instance.GetPlacesData(smallPlacesConfig.PlacesId);
  900. if (placesData.progress < 100)
  901. placesData.progress += eventConfig.Score;
  902. AccountFileInfo.Instance.SavePlayerData();
  903. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  904. EventManager.Instance.Dispatch(CustomEventType.CompleteEvent, null);
  905. }
  906. /// <summary>
  907. /// 完成事件
  908. /// </summary>
  909. /// <param name="eventID">事件ID</param>
  910. public async void CompleteEvent(AccountFileInfo.EventList eventList, bool isTriggerEvent = false)
  911. {
  912. this.isTriggerEvent = isTriggerEvent;
  913. LogTool.Log($"完成事件{eventList.eventID}");
  914. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  915. AccountFileInfo.EventList ceventList =
  916. AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce => ce.eventID == eventList.eventID);
  917. int placesId = PlayerManager.Instance.GetMaxSmallPlacesId();
  918. AccountFileInfo.SmallPlacesData smallPlacesData = PlayerManager.Instance.GetSmallPlacesData(placesId);
  919. if (smallPlacesData != null)
  920. {
  921. smallPlacesData.completionEventCount++;
  922. }
  923. if (ceventList == null)
  924. {
  925. PlacesConfig[] placesConfigs = ConfigComponent.Instance.GetAll<PlacesConfig>();
  926. int pId = 0;
  927. for (var i = 0; i < placesConfigs.Length; i++)
  928. {
  929. if (placesConfigs[i].MainTaskID == null || placesConfigs[i].ZhixianID == null)
  930. continue;
  931. if (placesConfigs[i].MainTaskID.Contains(eventConfig.ID) ||
  932. placesConfigs[i].ZhixianID.Contains(eventConfig.ID))
  933. {
  934. pId = placesConfigs[i].ID;
  935. break;
  936. }
  937. }
  938. if (pId == 0)
  939. {
  940. SmallPlacesConfig smallPlacesConfig =
  941. ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);
  942. AccountFileInfo.PlacesData
  943. placesData = PlayerManager.Instance.GetPlacesData(smallPlacesConfig.PlacesId);
  944. placesData.progress += eventConfig.Score;
  945. }
  946. else
  947. {
  948. PlayerManager.Instance.GetPlacesData(pId).progress += eventConfig.Score;
  949. }
  950. }
  951. List<ItemInfo> itemInfos = new List<ItemInfo>();
  952. if (eventConfig.PrizeIDs != null)
  953. {
  954. for (var i = 0; i < eventConfig.PrizeIDs.Length; i++)
  955. {
  956. DropConfig dropConfig = ConfigComponent.Instance.Get<DropConfig>(eventConfig.PrizeIDs[i]);
  957. if (dropConfig.dropType == 3)
  958. {
  959. if (eventConfig.PrizeNums[i] < 0)
  960. {
  961. List<ItemInfo> items =
  962. DropManager.Instance.Drop(dropConfig.dropGroupID[0], eventConfig.PrizeNums[i]);
  963. if (items != null)
  964. itemInfos.AddRange(items);
  965. }
  966. else
  967. {
  968. ItemInfo itemInfo = new ItemInfo(dropConfig.dropGroupID[0], eventConfig.PrizeNums[i]);
  969. itemInfos.Add(itemInfo);
  970. }
  971. }
  972. else
  973. {
  974. List<ItemInfo> items = DropManager.Instance.DropItem(eventConfig.PrizeIDs[i]);
  975. if (items != null)
  976. itemInfos.AddRange(items);
  977. }
  978. // itemInfos.Add(new ItemInfo(eventConfig.PrizeIDs[i], eventConfig.PrizeNums[i]));
  979. }
  980. }
  981. foreach (var eventListItemInfo in eventList.itemInfos)
  982. {
  983. itemInfos.Add(new ItemInfo(eventListItemInfo));
  984. }
  985. PlayerManager.Instance.BagController.AddItem(itemInfos);
  986. if (eventConfig.EventTriggerType == 4)
  987. {
  988. eventList.isCompleted = true;
  989. AccountFileInfo.Instance.playerData.completeEvents.Add(eventList);
  990. AccountFileInfo.Instance.playerData.eventList.Remove(eventList);
  991. TaskInfoPanel taskInfoPanel = await TaskInfoPanel.OpenPanel(eventList, 2);
  992. await taskInfoPanel.UIClosed();
  993. }
  994. else
  995. {
  996. //先不移除 下次探索神识移除
  997. eventList.isCompleted = true;
  998. }
  999. if (itemInfos != null && itemInfos.Count > 0)
  1000. {
  1001. RewardsPanel rewardsPanel = await RewardsPanel.OpenPanel(itemInfos);
  1002. await rewardsPanel.UIClosed();
  1003. }
  1004. if (AccountFileInfo.Instance.playerData.CurrentZuiZhongEventListId == eventList.guid)
  1005. {
  1006. AccountFileInfo.Instance.playerData.CurrentZuiZhongEventListId = 0;
  1007. UpdateZuizhongEventData();
  1008. }
  1009. AccountFileInfo.Instance.SavePlayerData();
  1010. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  1011. EventManager.Instance.Dispatch(CustomEventType.CompleteEvent, null);
  1012. EventManager.Instance.Dispatch(CustomEventType.CompleteUpdate, null);
  1013. onCompleteCallback?.Invoke();
  1014. onCompleteCallback = null;
  1015. }
  1016. /// <summary>
  1017. /// 完成事件
  1018. /// </summary>
  1019. /// <param name="eventID">事件ID</param>
  1020. public void CompleteEvent(AccountFileInfo.EventLinkData eventLinkData)
  1021. {
  1022. }
  1023. /// <summary>
  1024. /// 取消事件
  1025. /// </summary>
  1026. /// <param name="eventID">事件ID</param>
  1027. public void CancelEvent(AccountFileInfo.EventList eventList)
  1028. {
  1029. LogTool.Log($"取消事件{eventList.eventID}");
  1030. isTriggerEvent = false;
  1031. EventManager.Instance.Dispatch(CustomEventType.CompleteUpdate, null);
  1032. // EventManager.Instance.Dispatch(CustomEventType.CompleteEvent, null);
  1033. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  1034. onCompleteCallback?.Invoke();
  1035. onCompleteCallback = null;
  1036. if (PlayerGuideManager.Instance.GuideIsCanDo(2))
  1037. {
  1038. PlayerGuideManager.Instance.SetGuid(2);
  1039. }
  1040. }
  1041. public void RemoveEvent(AccountFileInfo.EventList eventList)
  1042. {
  1043. AccountFileInfo.Instance.playerData.eventList.Remove(eventList);
  1044. AccountFileInfo.Instance.SavePlayerData();
  1045. EventManager.Instance.Dispatch(CustomEventType.RemoveEvent, null);
  1046. }
  1047. /// <summary>
  1048. /// 获得主线事件
  1049. /// </summary>
  1050. /// <returns></returns>
  1051. public AccountFileInfo.EventList GetMainEventDta()
  1052. {
  1053. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  1054. {
  1055. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  1056. if (eventConfig.EventTriggerType == 4)
  1057. {
  1058. return eventList;
  1059. }
  1060. }
  1061. return null;
  1062. }
  1063. public void CancelEvent()
  1064. {
  1065. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  1066. DialogueManager.Instance.ChancleEvent();
  1067. CurrentEventList = null;
  1068. isTriggerEvent = false;
  1069. }
  1070. }