EventSystemManager.cs 47 KB

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