EventSystemManager.cs 50 KB

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