EventSystemManager.cs 45 KB

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