EventSystemManager.cs 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409
  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. //一开始就把道具掉落出来 ui上要显示
  505. if (eventConfig.PrizeIDs != null)
  506. {
  507. for (var i = 0; i < eventConfig.PrizeIDs.Length; i++)
  508. {
  509. List<ItemInfo> itemInfoss = DropManager.Instance.Drop(eventConfig.PrizeIDs[i],
  510. eventConfig.PrizeNums[i]);
  511. foreach (var itemInfo in itemInfoss)
  512. {
  513. eventList.itemInfos.Add(itemInfo.ToItemData());
  514. }
  515. // DropConfig dropConfig = ConfigComponent.Instance.Get<DropConfig>(eventConfig.PrizeIDs[i]);
  516. // if (dropConfig.dropType == 3)
  517. // {
  518. //
  519. //
  520. //
  521. // ItemConfig itemConfig = ConfigComponent.Instance.Get<ItemConfig>(dropConfig.dropGroupID[0]);
  522. // if (itemConfig.associateID == 14)
  523. // {
  524. // List<ItemInfo> itemInfoss = DropManager.Instance.Drop(eventConfig.PrizeIDs[i],
  525. // eventConfig.PrizeNums[i]);
  526. // foreach (var itemInfo in itemInfoss)
  527. // {
  528. // eventList.itemInfos.Add(itemInfo.ToItemData());
  529. // }
  530. // }
  531. //
  532. // else
  533. // {
  534. // ItemInfo itemInfo = new ItemInfo(dropConfig.dropGroupID[0], eventConfig.PrizeNums[i]);
  535. // eventList.itemInfos.Add(itemInfo.ToItemData());
  536. // }
  537. // }
  538. // else
  539. // {
  540. // List<ItemInfo> items =
  541. // DropManager.Instance.Drop(eventConfig.PrizeIDs[i], eventConfig.PrizeNums[i]);
  542. // foreach (var itemInfo in items)
  543. // {
  544. // eventList.itemInfos.Add(itemInfo.ToItemData());
  545. // }
  546. // }
  547. }
  548. }
  549. foreach (var i in eventConfig.EventLinksId)
  550. {
  551. EventLinkConfig eventLinkConfig = ConfigComponent.Instance.Get<EventLinkConfig>(i);
  552. AccountFileInfo.EventLinkData eventLinkData = new AccountFileInfo.EventLinkData();
  553. eventLinkData.eventId = eventID;
  554. eventLinkData.eventLinkId = i;
  555. if (eventLinkConfig.ConditionId != null)
  556. {
  557. foreach (var i1 in eventLinkConfig.ConditionId)
  558. {
  559. AccountFileInfo.EventConditionData
  560. eventConditionData = new AccountFileInfo.EventConditionData();
  561. eventConditionData.eventId = eventList.eventID;
  562. eventConditionData.eventCondition = i1;
  563. eventLinkData.eventConditions.Add(eventConditionData);
  564. //初始化先检测一些条件
  565. CeekTaskComplete(eventConditionData, 1, null);
  566. CeekTaskComplete(eventConditionData, 3, null);
  567. }
  568. }
  569. eventList.eventLinks.Add(eventLinkData);
  570. }
  571. }
  572. return eventList;
  573. }
  574. /// <summary>
  575. /// 触发随机事件
  576. /// </summary>
  577. public void DetectRandomEvents()
  578. {
  579. if (isTriggerEvent)
  580. return;
  581. if (isOpenUi)
  582. return;
  583. // 获取随机事件
  584. List<EventConfig> randomEvents =
  585. eventConfigs.Where(e => e.EventTriggerType == 2 && CanTriggerEvent(e.ID)).ToList();
  586. if (randomEvents.Count == 0)
  587. {
  588. LogTool.Warning("没有可以刷新的事件");
  589. return;
  590. }
  591. int idex = Random.Range(0, randomEvents.Count);
  592. TriggerEvent(randomEvents[idex]);
  593. }
  594. /// <summary>
  595. /// 挂机事件触发
  596. /// </summary>
  597. public void TriggerEvent(EventConfig evt)
  598. {
  599. if (isTriggerEvent)
  600. return;
  601. isTriggerEvent = true;
  602. LogTool.Log($"触发事件: {evt.EventName} (ID: {evt.ID}, 品质: {evt.EventQuality})");
  603. CombatDrive.Instance.CombatController.ChangeState(CombatController.idle);
  604. AccountFileInfo.EventList eventList = AddEvent(evt.ID);
  605. CurrentEventList = eventList;
  606. DialogueManager.Instance.StartDialogue(eventList, evt.EventLinksId[0], evt.ID,
  607. () => { CompleteEvent(evt.ID); });
  608. }
  609. /// <summary>
  610. /// 其他类型事件触发
  611. /// </summary>
  612. public async CTask TriggerEvent(AccountFileInfo.EventList evt, Action oncompleteCallBack = null,
  613. Action uiOpenOverCallBack = null)
  614. {
  615. // ChancleEvent();
  616. if (isTriggerEvent)
  617. return;
  618. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(evt.eventID);
  619. SmallPlacesConfig smallPlacesConfig =
  620. ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);
  621. if (eventConfig.SmallPlacesId > 0)
  622. {
  623. if (eventConfig.SmallPlacesId != PlayerManager.Instance.CurrentsmallPlaces.id)
  624. {
  625. AccountFileInfo.SmallPlacesData lastSmallPlacesData =
  626. PlayerManager.Instance.GetSmallPlacesData(eventConfig.SmallPlacesId - 1);
  627. SmallPlacesConfig lastSmallPlacesConfig =
  628. ConfigComponent.Instance.Get<SmallPlacesConfig>(eventConfig.SmallPlacesId - 1);
  629. SmallPlacesConfig currentSmallPlacesConfig =
  630. ConfigComponent.Instance.Get<SmallPlacesConfig>(eventConfig.SmallPlacesId);
  631. if (currentSmallPlacesConfig.ID > 1 && (lastSmallPlacesData == null ||
  632. lastSmallPlacesData.completionEventCount <
  633. lastSmallPlacesConfig.CompletionEventCount))
  634. {
  635. TipMessagePanel tipMessagePanel = await TipMessagePanel.OpenTipMessagePanel(
  636. LanguageManager.Instance.Text(10379,
  637. lastSmallPlacesConfig.CompletionEventCount - lastSmallPlacesData?.completionEventCount));
  638. if (eventConfig.ID == 10002 && PlayerGuideManager.Instance.GuideIsCanDo(3))
  639. {
  640. PlayerGuideManager.Instance.SetGuid(3);
  641. }
  642. AudioManager.Instance.PlayAudio("ui_chaozuoshibai.wav");
  643. return;
  644. }
  645. if (lastSmallPlacesConfig.UnlockEnvetid != 0)
  646. {
  647. AccountFileInfo.EventList eventList =
  648. AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce =>
  649. ce.eventID == lastSmallPlacesConfig.UnlockEnvetid);
  650. if (eventList == null || !eventList.isCompleted)
  651. {
  652. var econfig = ConfigComponent.Instance.Get<EventConfig>(lastSmallPlacesConfig.UnlockEnvetid);
  653. TipMessagePanel.OpenTipMessagePanel(LanguageManager.Instance.Text(10380,
  654. LanguageManager.Instance.Text(lastSmallPlacesConfig.placeName),
  655. LanguageManager.Instance.Text(econfig.EventName)));
  656. AudioManager.Instance.PlayAudio("ui_chaozuoshibai.wav");
  657. return;
  658. }
  659. }
  660. SmallPlacesConfig SmallPlacesConfig =
  661. ConfigComponent.Instance.Get<SmallPlacesConfig>(eventConfig.SmallPlacesId);
  662. CTask<bool> cT = CTask<bool>.Create();
  663. PlacesInfoPanel.OpenPanel(SmallPlacesConfig.PlacesId, (b) => { cT.SetResult(b); },
  664. eventConfig.SmallPlacesId);
  665. await cT;
  666. if (eventConfig.SmallPlacesId != PlayerManager.Instance.CurrentsmallPlaces.id)
  667. {
  668. return;
  669. }
  670. // if (!cT.Result)
  671. // {
  672. // return;
  673. // }
  674. }
  675. }
  676. else if (eventConfig.placeID > 0)
  677. {
  678. if (eventConfig.placeID != smallPlacesConfig.PlacesId)
  679. {
  680. CTask<bool> cT = CTask<bool>.Create();
  681. PlacesInfoPanel.OpenPanel(eventConfig.placeID, (b) => { cT.SetResult(b); });
  682. await cT;
  683. smallPlacesConfig =
  684. ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);
  685. if (eventConfig.placeID != smallPlacesConfig.PlacesId)
  686. {
  687. return;
  688. }
  689. }
  690. }
  691. CTask cTask = CTask.Create();
  692. this.onCompleteCallback = oncompleteCallBack;
  693. isTriggerEvent = true;
  694. LogTool.Log(
  695. $"触发事件: {LanguageManager.Instance.Text(eventConfig.EventName)} (ID: {eventConfig.ID}, 品质: {eventConfig.EventQuality})");
  696. int dialogueID = 0;
  697. if (evt.curStep == 0)
  698. {
  699. dialogueID = eventConfig.EventLinksId[0];
  700. }
  701. else
  702. {
  703. dialogueID = evt.curStep;
  704. }
  705. CurrentEventList = evt;
  706. CombatDrive.Instance.CombatController.ChangeState(CombatController.idle);
  707. await DialogueManager.Instance.StartDialogue(CurrentEventList, dialogueID, eventConfig.ID, async () =>
  708. {
  709. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(CurrentEventList.eventID);
  710. if (eventConfig.EventTriggerType != 4)
  711. {
  712. CompleteEvent(CurrentEventList);
  713. }
  714. else
  715. {
  716. CurrentEventList.isCompleted1 = true;
  717. AccountFileInfo.Instance.SavePlayerData();
  718. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  719. onCompleteCallback?.Invoke();
  720. onCompleteCallback = null;
  721. if (eventConfig.ID != 10001)
  722. {
  723. await UIManager.Instance.HideUIUIPanel<DivineSenceEventPreviewPanel>();
  724. UIManager.Instance.HideUIUIPanel<DivineSenceInfoPanel>();
  725. }
  726. EventManager.Instance.Dispatch(CustomEventType.CompleteUpdate, null);
  727. }
  728. cTask.SetResult();
  729. }, () =>
  730. {
  731. CancelEvent(CurrentEventList);
  732. cTask.SetResult();
  733. });
  734. uiOpenOverCallBack?.Invoke();
  735. DivineSenceEventPreviewPanel divineSenceEventPreviewPanel =
  736. UIManager.Instance.GetComponent<DivineSenceEventPreviewPanel>();
  737. AppBarPanel appBarPanel = UIManager.Instance.GetComponent<AppBarPanel>();
  738. // DivineSenceInfoPanel divineSenceInfoPanel = UIManager.Instance.GetComponent<DivineSenceInfoPanel>();
  739. if (divineSenceEventPreviewPanel != null && !divineSenceEventPreviewPanel.IsClose)
  740. {
  741. divineSenceEventPreviewPanel.GObjectPoolInterface.SetActive(false);
  742. }
  743. // if (appBarPanel != null && !appBarPanel.IsClose)
  744. // {
  745. // appBarPanel.GObjectPoolInterface.SetActive(false);
  746. // }
  747. // if (divineSenceInfoPanel != null)
  748. // {
  749. // divineSenceInfoPanel.GObjectPoolInterface.SetActive(false);
  750. // }
  751. await cTask;
  752. if (divineSenceEventPreviewPanel != null && !divineSenceEventPreviewPanel.IsClose)
  753. {
  754. divineSenceEventPreviewPanel.GObjectPoolInterface.SetActive(true);
  755. }
  756. if (appBarPanel != null && !appBarPanel.IsClose)
  757. {
  758. appBarPanel.GObjectPoolInterface.SetActive(true);
  759. }
  760. // if (divineSenceInfoPanel != null)
  761. // {
  762. // divineSenceInfoPanel.GObjectPoolInterface.SetActive(true);
  763. // }
  764. }
  765. //任务是否完成
  766. public bool IsEvenkLinkComplete(AccountFileInfo.EventConditionData eventCondition)
  767. {
  768. EventConditionConfig eventConditionConfig =
  769. ConfigComponent.Instance.Get<EventConditionConfig>(eventCondition.eventCondition);
  770. if (eventCondition != null)
  771. {
  772. return eventCondition.fishCount >= eventConditionConfig.finishCount;
  773. }
  774. return false;
  775. }
  776. public bool IsCeekEventGroupComplete(List<AccountFileInfo.EventConditionData> eventConditions)
  777. {
  778. Map<int, List<AccountFileInfo.EventConditionData>> eventConditionDataGroup =
  779. new Map<int, List<AccountFileInfo.EventConditionData>>();
  780. foreach (var eventConditionData in eventConditions)
  781. {
  782. EventConditionConfig eventConditionConfig =
  783. ConfigComponent.Instance.Get<EventConditionConfig>(eventConditionData.eventCondition);
  784. if (!eventConditionDataGroup.ContainsKey(eventConditionConfig.Operation))
  785. {
  786. eventConditionDataGroup.Add(eventConditionConfig.Operation,
  787. new List<AccountFileInfo.EventConditionData>());
  788. }
  789. eventConditionDataGroup[eventConditionConfig.Operation].Add(eventConditionData);
  790. }
  791. bool isUlock = true;
  792. //分组检测 其中一个组绑定成功就可以执行
  793. foreach (var keyValuePair in eventConditionDataGroup)
  794. {
  795. isUlock = true;
  796. foreach (var eventConditionData in keyValuePair.Value)
  797. {
  798. if (!IsEvenkLinkComplete(eventConditionData))
  799. {
  800. isUlock = false;
  801. }
  802. }
  803. if (isUlock)
  804. {
  805. return isUlock;
  806. }
  807. }
  808. return isUlock;
  809. }
  810. public void CeekEventCompletes(int type, int[] value)
  811. {
  812. foreach (var playerDataEventLinkData in AccountFileInfo.Instance.playerData.eventList)
  813. {
  814. foreach (var eventLinkData in playerDataEventLinkData.eventLinks)
  815. {
  816. foreach (var eventConditionData in eventLinkData.eventConditions)
  817. {
  818. CeekTaskComplete(eventConditionData, type, value);
  819. }
  820. }
  821. // if (playerDataEventLinkData.eventID == 10001 && playerDataEventLinkData.curStep == 1000104 &&
  822. // IsCeekEventGroupComplete(playerDataEventLinkData.eventLinks[3].eventConditions))
  823. // {
  824. // isTriggerEvent = false;
  825. // TriggerEvent(playerDataEventLinkData);
  826. // }
  827. }
  828. EventManager.Instance.Dispatch(CustomEventType.RemoveEvent, null);
  829. }
  830. public void CeekTaskComplete(AccountFileInfo.EventConditionData conditionData, int type, int[] value)
  831. {
  832. EventConditionConfig eventConditionConfig =
  833. ConfigComponent.Instance.Get<EventConditionConfig>(conditionData.eventCondition);
  834. if (IsEvenkLinkComplete(conditionData) && eventConditionConfig.ConditionType != 1)
  835. return;
  836. switch (type)
  837. {
  838. //检测背包道具
  839. case 1:
  840. if (eventConditionConfig.ConditionType == 1)
  841. {
  842. conditionData.fishCount =
  843. (int)PlayerManager.Instance.BagController.GetItemCount(eventConditionConfig.ConditionPara[0]);
  844. if (IsEvenkLinkComplete(conditionData))
  845. {
  846. // CompleteTask(conditionData.guid);
  847. }
  848. }
  849. break;
  850. //境界检测
  851. case 3:
  852. if (eventConditionConfig.ConditionType == 3 && PlayerManager.Instance.myHero.powerUpConfig.ID >=
  853. eventConditionConfig.ConditionPara[0])
  854. {
  855. conditionData.fishCount++;
  856. if (IsEvenkLinkComplete(conditionData))
  857. {
  858. // CompleteTask(conditionData.guid);
  859. }
  860. }
  861. break;
  862. //战斗胜利
  863. case 5:
  864. if (eventConditionConfig.ConditionType == 5 && eventConditionConfig.ConditionPara[0] == value[0])
  865. {
  866. conditionData.fishCount++;
  867. if (IsEvenkLinkComplete(conditionData))
  868. {
  869. // CompleteEvent(conditionData.guid);
  870. }
  871. }
  872. break;
  873. //获得道具
  874. case 6:
  875. if (eventConditionConfig.ConditionType == 6 && eventConditionConfig.ConditionPara[0] == value[0])
  876. {
  877. conditionData.fishCount += value[1];
  878. if (IsEvenkLinkComplete(conditionData))
  879. {
  880. // CompleteEvent(conditionData.guid);
  881. }
  882. }
  883. break;
  884. //使用神识
  885. case 8:
  886. if (eventConditionConfig.ConditionType == 8)
  887. {
  888. conditionData.fishCount += value[0];
  889. if (IsEvenkLinkComplete(conditionData))
  890. {
  891. }
  892. }
  893. break;
  894. //完成某个事件
  895. case 10:
  896. if (eventConditionConfig.ConditionType == 10 &&
  897. EventSystemManager.Instance.IsEventCompleted(eventConditionConfig.ConditionPara[0]))
  898. {
  899. conditionData.fishCount++;
  900. if (IsEvenkLinkComplete(conditionData))
  901. {
  902. }
  903. }
  904. break;
  905. }
  906. AccountFileInfo.Instance.SavePlayerData();
  907. }
  908. private void CompleteTask(object taskID)
  909. {
  910. }
  911. //指定type事件
  912. private bool CanEventType(int eventID, ItemInfo itemInfo)
  913. {
  914. if (itemInfo == null)
  915. {
  916. return true;
  917. }
  918. var evt = eventConfigs.Find(e => e.ID == eventID);
  919. if (evt.PrizeType != null && evt.PrizeType.Contains(itemInfo.config.associateVlaue[0]))
  920. {
  921. return true;
  922. }
  923. return false;
  924. }
  925. /// <summary>
  926. /// 检查事件是否满足触发条件。
  927. /// </summary>
  928. private bool CanTriggerEvent(int eventID)
  929. {
  930. var evt = eventConfigs.Find(e => e.ID == eventID);
  931. if (evt.ID == 0)
  932. return false;
  933. if (evt.EventConditionId == null)
  934. return true;
  935. bool isCan = true;
  936. for (var i = 0; i < evt.EventConditionId.Length; i++)
  937. {
  938. switch (evt.EventConditionId[i])
  939. {
  940. //背包道具检测
  941. case 1:
  942. if (evt.EventCount == null)
  943. {
  944. return false;
  945. }
  946. if (PlayerManager.Instance.BagController.GetItemCount(evt.EventValue[i]) >= evt.EventCount[i])
  947. {
  948. isCan = false;
  949. return false;
  950. }
  951. break;
  952. //境界判断
  953. case 3:
  954. if (evt.EventValue == null)
  955. {
  956. return false;
  957. }
  958. if (PlayerManager.Instance.myHero.level < evt.EventValue[i])
  959. {
  960. isCan = false;
  961. return false;
  962. }
  963. break;
  964. //概率判断
  965. case 7:
  966. if (evt.EventValue == null)
  967. {
  968. return false;
  969. }
  970. int randomValue1 = Random.Range(0, 1001);
  971. if (randomValue1 > evt.EventValue[i])
  972. {
  973. isCan = false;
  974. return false;
  975. }
  976. break;
  977. //完成事件判断
  978. case 10:
  979. if (evt.EventValue == null)
  980. {
  981. return false;
  982. }
  983. AccountFileInfo.EventList eventList =
  984. AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce =>
  985. ce.eventID == evt.EventValue[i]);
  986. if (eventList == null)
  987. {
  988. isCan = false;
  989. return false;
  990. }
  991. break;
  992. }
  993. }
  994. return isCan;
  995. }
  996. /// <summary>
  997. /// 完成事件
  998. /// </summary>
  999. /// <param name="eventID">事件ID</param>
  1000. public void CompleteEvent(int evtId)
  1001. {
  1002. isTriggerEvent = false;
  1003. LogTool.Log($"完成挂机事件{evtId}");
  1004. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(evtId);
  1005. AccountFileInfo.EventList eventList = new AccountFileInfo.EventList();
  1006. eventList.eventID = evtId;
  1007. AccountFileInfo.Instance.playerData.completeEvents.Add(eventList);
  1008. int placesId = PlayerManager.Instance.GetMaxSmallPlacesId();
  1009. AccountFileInfo.SmallPlacesData smallPlacesData = PlayerManager.Instance.GetSmallPlacesData(placesId);
  1010. if (smallPlacesData != null)
  1011. {
  1012. smallPlacesData.completionEventCount++;
  1013. }
  1014. SmallPlacesConfig smallPlacesConfig =
  1015. ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);
  1016. AccountFileInfo.PlacesData placesData = PlayerManager.Instance.GetPlacesData(smallPlacesConfig.PlacesId);
  1017. if (placesData.progress < 100)
  1018. placesData.progress += eventConfig.Score;
  1019. AccountFileInfo.Instance.SavePlayerData();
  1020. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  1021. EventManager.Instance.Dispatch(CustomEventType.CompleteEvent, null);
  1022. }
  1023. /// <summary>
  1024. /// 完成事件
  1025. /// </summary>
  1026. /// <param name="eventID">事件ID</param>
  1027. public async void CompleteEvent(AccountFileInfo.EventList eventList, bool isTriggerEvent = false)
  1028. {
  1029. this.isTriggerEvent = isTriggerEvent;
  1030. LogTool.Log($"完成事件{eventList.eventID}");
  1031. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  1032. AccountFileInfo.EventList ceventList =
  1033. AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce => ce.eventID == eventList.eventID);
  1034. int placesId = PlayerManager.Instance.GetMaxSmallPlacesId();
  1035. AccountFileInfo.SmallPlacesData smallPlacesData = PlayerManager.Instance.GetSmallPlacesData(placesId);
  1036. if (smallPlacesData != null)
  1037. {
  1038. smallPlacesData.completionEventCount++;
  1039. }
  1040. if (ceventList == null)
  1041. {
  1042. PlacesConfig[] placesConfigs = ConfigComponent.Instance.GetAll<PlacesConfig>();
  1043. int pId = 0;
  1044. for (var i = 0; i < placesConfigs.Length; i++)
  1045. {
  1046. if (placesConfigs[i].MainTaskID == null || placesConfigs[i].ZhixianID == null)
  1047. continue;
  1048. if (placesConfigs[i].MainTaskID.Contains(eventConfig.ID) ||
  1049. placesConfigs[i].ZhixianID.Contains(eventConfig.ID))
  1050. {
  1051. pId = placesConfigs[i].ID;
  1052. break;
  1053. }
  1054. }
  1055. if (pId == 0)
  1056. {
  1057. SmallPlacesConfig smallPlacesConfig =
  1058. ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);
  1059. AccountFileInfo.PlacesData
  1060. placesData = PlayerManager.Instance.GetPlacesData(smallPlacesConfig.PlacesId);
  1061. placesData.progress += eventConfig.Score;
  1062. }
  1063. else
  1064. {
  1065. PlayerManager.Instance.GetPlacesData(pId).progress += eventConfig.Score;
  1066. }
  1067. }
  1068. List<ItemInfo> itemInfos = new List<ItemInfo>();
  1069. foreach (var eventListItemInfo in eventList.itemInfos)
  1070. {
  1071. itemInfos.Add(new ItemInfo(eventListItemInfo));
  1072. }
  1073. PlayerManager.Instance.BagController.AddItem(itemInfos);
  1074. if (eventConfig.EventTriggerType == 4)
  1075. {
  1076. eventList.isCompleted = true;
  1077. AccountFileInfo.Instance.playerData.completeEvents.Add(eventList);
  1078. AccountFileInfo.Instance.playerData.eventList.Remove(eventList);
  1079. TaskInfoPanel taskInfoPanel = await TaskInfoPanel.OpenPanel(eventList, 2);
  1080. await taskInfoPanel.UIClosed();
  1081. }
  1082. else
  1083. {
  1084. //先不移除 下次探索神识移除
  1085. eventList.isCompleted = true;
  1086. }
  1087. CeekEventCompletes(10, null);
  1088. if (itemInfos != null && itemInfos.Count > 0)
  1089. {
  1090. RewardsPanel rewardsPanel = await RewardsPanel.OpenPanel(itemInfos);
  1091. await rewardsPanel.UIClosed();
  1092. }
  1093. if (eventConfig.EventTriggerType == 4)
  1094. {
  1095. await UIManager.Instance.HideUIUIPanel<DivineSenceEventPreviewPanel>();
  1096. UIManager.Instance.HideUIUIPanel<DivineSenceInfoPanel>();
  1097. }
  1098. if (AccountFileInfo.Instance.playerData.CurrentZuiZhongEventListId == eventList.guid)
  1099. {
  1100. AccountFileInfo.Instance.playerData.CurrentZuiZhongEventListId = 0;
  1101. UpdateZuizhongEventData();
  1102. }
  1103. AccountFileInfo.Instance.SavePlayerData();
  1104. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  1105. EventManager.Instance.Dispatch(CustomEventType.CompleteEvent, null);
  1106. EventManager.Instance.Dispatch(CustomEventType.CompleteUpdate, null);
  1107. onCompleteCallback?.Invoke();
  1108. onCompleteCallback = null;
  1109. }
  1110. /// <summary>
  1111. /// 完成事件
  1112. /// </summary>
  1113. /// <param name="eventID">事件ID</param>
  1114. public void CompleteEvent(AccountFileInfo.EventLinkData eventLinkData)
  1115. {
  1116. }
  1117. /// <summary>
  1118. /// 取消事件
  1119. /// </summary>
  1120. /// <param name="eventID">事件ID</param>
  1121. public async void CancelEvent(AccountFileInfo.EventList eventList)
  1122. {
  1123. LogTool.Log($"取消事件{eventList.eventID}");
  1124. isTriggerEvent = false;
  1125. EventManager.Instance.Dispatch(CustomEventType.CompleteUpdate, null);
  1126. // EventManager.Instance.Dispatch(CustomEventType.CompleteEvent, null);
  1127. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  1128. onCompleteCallback?.Invoke();
  1129. onCompleteCallback = null;
  1130. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  1131. if (eventConfig.EventTriggerType == 4)
  1132. {
  1133. await UIManager.Instance.HideUIUIPanel<DivineSenceEventPreviewPanel>();
  1134. await UIManager.Instance.HideUIUIPanel<DivineSenceInfoPanel>();
  1135. }
  1136. if (eventConfig.ID == 10001 && PlayerGuideManager.Instance.GuideIsCanDo(2))
  1137. {
  1138. PlayerGuideManager.Instance.SetGuid(2);
  1139. }
  1140. }
  1141. public void RemoveEvent(AccountFileInfo.EventList eventList)
  1142. {
  1143. AccountFileInfo.Instance.playerData.eventList.Remove(eventList);
  1144. AccountFileInfo.Instance.SavePlayerData();
  1145. EventManager.Instance.Dispatch(CustomEventType.RemoveEvent, null);
  1146. }
  1147. /// <summary>
  1148. /// 获得主线事件
  1149. /// </summary>
  1150. /// <returns></returns>
  1151. public AccountFileInfo.EventList GetMainEventDta()
  1152. {
  1153. foreach (var eventList in AccountFileInfo.Instance.playerData.eventList)
  1154. {
  1155. EventConfig eventConfig = ConfigComponent.Instance.Get<EventConfig>(eventList.eventID);
  1156. if (eventConfig.EventTriggerType == 4)
  1157. {
  1158. return eventList;
  1159. }
  1160. }
  1161. return null;
  1162. }
  1163. public void CancelEvent()
  1164. {
  1165. CombatDrive.Instance.CombatController.ChangeState(CombatController.update);
  1166. DialogueManager.Instance.ChancleEvent();
  1167. CurrentEventList = null;
  1168. isTriggerEvent = false;
  1169. }
  1170. }