EventSystemManager.cs 50 KB

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