EventSystemManager.cs 48 KB

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