EventSystemManager.cs 50 KB

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