EventSystemManager.cs 45 KB

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