EventSystemManager.cs 49 KB

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