PlayerManager.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Core.Language;
  5. using Core.Utility;
  6. using Excel2Json;
  7. using Fort23.Core;
  8. using Fort23.Mono;
  9. using Fort23.UTool;
  10. using GameLogic.Bag;
  11. using GameLogic.CombatScenesTool;
  12. using GameLogic.Hero;
  13. using GameLogic.Player;
  14. using Mono.Player;
  15. using UnityEngine;
  16. using Utility;
  17. using Random = UnityEngine.Random;
  18. public class PlayerManager : Singleton<PlayerManager>
  19. {
  20. public GameConstantConfig gameConstantConfig;
  21. public GongFaControl GongFaControl;
  22. public FaBaoControl FaBaoControl;
  23. public BagController BagController;
  24. public PlayerGuideDataComponent PlayerGuideDataComponent = new PlayerGuideDataComponent();
  25. public SummonManager SummonManager = new SummonManager();
  26. // public Map<long, List<AccountFileInfo.DaoYouGuaiJiData>> GuaijiDaoYou = new Map<long, List<AccountFileInfo.DaoYouGuaiJiData>>();
  27. public bool isTest;
  28. /// <summary>
  29. /// 玩家角色属性
  30. /// </summary>
  31. public HeroInfo myHero;
  32. public HeroInfo yindaoHeroData;
  33. private string playerName;
  34. public string PlayerName
  35. {
  36. get { return LanguageManager.Instance.Text(myHero.modelConfig.name); }
  37. set { playerName = value; }
  38. }
  39. public long serverTime => TimeHelper.ServerNow();
  40. private AccountFileInfo.SmallPlacesData currentPlaces;
  41. public AccountFileInfo.SmallPlacesData CurrentsmallPlaces
  42. {
  43. get { return currentPlaces; }
  44. set { currentPlaces = value; }
  45. }
  46. public float PlacesBl => GetMapBl(CurrentsmallPlaces.id);
  47. private TimerEntity _timerEntity;
  48. public bool isLogin;
  49. /// <summary>
  50. /// 当前引导id
  51. /// </summary>
  52. public int curGuideGroupId;
  53. public void Init()
  54. {
  55. AccountFileInfo.Instance.LoadPlayerData();
  56. SetConfigs();
  57. InitGameData();
  58. // int m = Random.Range(0, 4 * 60 * 1000);
  59. RandownDaoYou(gameConstantConfig.Daoyoushowuptime + 1000);
  60. QiankundaiConfig[] qiankundaiConfigs = ConfigComponent.Instance.GetAll<QiankundaiConfig>();
  61. foreach (var qiankundaiConfig in qiankundaiConfigs)
  62. {
  63. if (qiankundaiConfig.dropType == 1)
  64. {
  65. AccountFileInfo.QiankundaiData qiankundaiData =
  66. AccountFileInfo.Instance.playerData.QiankundaiDatas.FirstOrDefault(q =>
  67. q.id == qiankundaiConfig.ID);
  68. if (qiankundaiData == null)
  69. {
  70. qiankundaiData = new AccountFileInfo.QiankundaiData();
  71. qiankundaiData.id = qiankundaiConfig.ID;
  72. if (qiankundaiConfig.dropPara1 == 1)
  73. {
  74. qiankundaiData.refenceTime = TimeHelper.ClientNow() + 60 * 60 * 1000;
  75. }
  76. else if (qiankundaiConfig.dropPara1 == 2)
  77. {
  78. qiankundaiData.refenceTime = TimeHelper.GetBaseRefreshTime(TimeHelper.ClientNow());
  79. }
  80. else if (qiankundaiConfig.dropPara1 == 3)
  81. {
  82. }
  83. AccountFileInfo.Instance.playerData.QiankundaiDatas.Add(qiankundaiData);
  84. }
  85. }
  86. }
  87. CalculateOfflineRewards();
  88. AccountFileInfo.Instance.SavePlayerData();
  89. SummonManager.CustomInit();
  90. isLogin = true;
  91. }
  92. /// <summary>
  93. /// 获得固定时间乾坤袋表
  94. /// </summary>
  95. /// <returns></returns>
  96. public List<QiankundaiConfig> GetFixedTimeQiankundaiConfigs()
  97. {
  98. List<QiankundaiConfig> configs = new List<QiankundaiConfig>();
  99. QiankundaiConfig[] qiankundaiConfigs = ConfigComponent.Instance.GetAll<QiankundaiConfig>();
  100. foreach (var qiankundaiConfig in qiankundaiConfigs)
  101. {
  102. if (qiankundaiConfig.dropType == 2)
  103. {
  104. if (myHero.powerUpConfig.ID >= qiankundaiConfig.dropLevel[0] &&
  105. myHero.powerUpConfig.ID <= qiankundaiConfig.dropLevel[1])
  106. {
  107. configs.Add(qiankundaiConfig);
  108. }
  109. }
  110. }
  111. return configs;
  112. }
  113. //添加心境
  114. public void AddSentimentData(int id)
  115. {
  116. AccountFileInfo.SentimentData sentimentData =
  117. AccountFileInfo.Instance.playerData.SentimentDatas.FirstOrDefault(sd => sd.id == id);
  118. if (sentimentData != null)
  119. {
  120. LogTool.Error("已经用心境 id:" + id);
  121. return;
  122. }
  123. SentimentConfig sentimentConfig = ConfigComponent.Instance.Get<SentimentConfig>(id);
  124. sentimentData = new AccountFileInfo.SentimentData();
  125. sentimentData.id = id;
  126. sentimentData.mainSentiment = new AccountFileInfo.SentimentProperty();
  127. sentimentData.mainSentiment.groupId = sentimentConfig.mainSentimentEffect;
  128. foreach (var i in sentimentConfig.sentimentEffect)
  129. {
  130. AccountFileInfo.SentimentProperty sentimentProperty = new AccountFileInfo.SentimentProperty();
  131. sentimentProperty.groupId = i;
  132. sentimentData.sentimentProperties.Add(sentimentProperty);
  133. }
  134. AccountFileInfo.Instance.playerData.SentimentDatas.Add(sentimentData);
  135. AccountFileInfo.Instance.SavePlayerData();
  136. }
  137. List<AccountFileInfo.DaoYouData> removerDaoYou = new List<AccountFileInfo.DaoYouData>();
  138. public void RandownDaoYou(int m)
  139. {
  140. _timerEntity?.Dispose();
  141. _timerEntity = null;
  142. _timerEntity = TimerComponent.Instance.AddTimer(m, () =>
  143. {
  144. List<AccountFileInfo.DaoYouData> daoYouDatas = AccountFileInfo.Instance.playerData.daoYouDatas.ToList();
  145. foreach (var daoYouData in daoYouDatas)
  146. {
  147. if (daoYouData.favorabilityLv <= 1)
  148. {
  149. removerDaoYou.Add(daoYouData);
  150. continue;
  151. }
  152. foreach (var keyValuePair in AccountFileInfo.Instance.playerData.daoYouGuaiJiDatas)
  153. {
  154. if (daoYouData.id == keyValuePair.daoyouDataID)
  155. {
  156. removerDaoYou.Add(daoYouData);
  157. break;
  158. }
  159. }
  160. }
  161. foreach (var daoYouData in removerDaoYou)
  162. {
  163. daoYouDatas.Remove(daoYouData);
  164. }
  165. removerDaoYou.Clear();
  166. int count = Random.Range(0, daoYouDatas.Count + 1);
  167. List<AccountFileInfo.DaoYouGuaiJiData> daoyou = new List<AccountFileInfo.DaoYouGuaiJiData>();
  168. for (int i = 0; i < count; i++)
  169. {
  170. int index = Random.Range(0, daoYouDatas.Count);
  171. AccountFileInfo.DaoYouGuaiJiData daoYouGuaiJiData = new AccountFileInfo.DaoYouGuaiJiData();
  172. int time = Random.Range(gameConstantConfig.DaoyouguajiDuration[0],
  173. gameConstantConfig.DaoyouguajiDuration[1]) * 1000;
  174. daoYouGuaiJiData.leaveTime = TimeHelper.ClientNow() + time;
  175. daoYouGuaiJiData.guajiTime = time;
  176. daoYouGuaiJiData.daoyouDataID = daoYouDatas[index].id;
  177. daoyou.Add(daoYouGuaiJiData);
  178. daoYouDatas.RemoveAt(index);
  179. _timerEntity?.Dispose();
  180. _timerEntity = null;
  181. }
  182. if (daoyou.Count > 0)
  183. {
  184. AccountFileInfo.Instance.playerData.daoYouGuaiJiDatas.AddRange(daoyou);
  185. EventManager.Instance.Dispatch(CustomEventType.DaoYouCounUpdate, null);
  186. }
  187. RandownDaoYou(gameConstantConfig.Daoyoushowuptime * 1000);
  188. });
  189. }
  190. public int GetDaoYouLevel(AccountFileInfo.DaoYouData daoYouData)
  191. {
  192. DaoyouModelConfig daoyouModelConfig = ConfigComponent.Instance.Get<DaoyouModelConfig>(daoYouData.id);
  193. int level = (int)(myHero.level.Value * daoyouModelConfig.growupRate * 0.01f);
  194. if (level < 1) level = 1;
  195. return level;
  196. }
  197. public int GetBl(AccountFileInfo.DaoYouData daoYouData, int guajibuffId)
  198. {
  199. DaoyouLevelupConfig daoyouLevelupConfig =
  200. ConfigComponent.Instance.Get<DaoyouLevelupConfig>(daoYouData.favorabilityLv);
  201. int level = GetDaoYouLevel(daoYouData);
  202. DaoyouguajiResourcLevel daoyouguajiResourcLevel = ConfigComponent.Instance.Get<DaoyouguajiResourcLevel>(level);
  203. guajibuff guajibuff = ConfigComponent.Instance.Get<guajibuff>(guajibuffId);
  204. int levelBl = 0;
  205. int bl = 0;
  206. switch (guajibuff.paraValue)
  207. {
  208. case 1:
  209. levelBl = daoyouguajiResourcLevel.para1;
  210. bl = (int)(guajibuff.GivingRate * levelBl * daoyouLevelupConfig.guajiGrowup * 0.01f * 0.01f);
  211. return bl;
  212. break;
  213. case 2:
  214. levelBl = daoyouguajiResourcLevel.para2;
  215. bl = (int)(guajibuff.GivingRate * levelBl * daoyouLevelupConfig.guajiGrowup * 0.01f * 0.01f);
  216. return bl;
  217. break;
  218. case 3:
  219. levelBl = daoyouguajiResourcLevel.para3;
  220. bl = (int)(guajibuff.GivingRate * levelBl * daoyouLevelupConfig.guajiGrowup * 0.01f * 0.01f);
  221. return bl;
  222. break;
  223. case 4:
  224. levelBl = daoyouguajiResourcLevel.para4;
  225. bl = (int)(guajibuff.GivingRate * levelBl * daoyouLevelupConfig.guajiGrowup * 0.01f * 0.01f);
  226. return bl;
  227. break;
  228. case 5:
  229. levelBl = daoyouguajiResourcLevel.para5;
  230. bl = (int)(guajibuff.GivingRate * levelBl * daoyouLevelupConfig.guajiGrowup * 0.01f * 0.001f);
  231. return bl;
  232. break;
  233. default:
  234. return 0;
  235. }
  236. }
  237. private void SetConfigs()
  238. {
  239. gameConstantConfig = ConfigComponent.Instance.Get<GameConstantConfig>(1);
  240. }
  241. private void InitGameData()
  242. {
  243. GongFaControl = new GongFaControl();
  244. FaBaoControl = new FaBaoControl();
  245. BagController = new BagController();
  246. HeroInfo heroInfo = new HeroInfo();
  247. AccountFileInfo.Instance.playerData.heroData.TaoismSkillId = 601011;
  248. heroInfo.InitHero(AccountFileInfo.Instance.playerData.heroData);
  249. myHero = heroInfo;
  250. myHero.TaoismSkillId = 601011;
  251. HeroInfo yindaoHeroData = new HeroInfo();
  252. yindaoHeroData.InitHero(AccountFileInfo.Instance.playerData.yindaoHeroData);
  253. yindaoHeroData = heroInfo;
  254. yindaoHeroData.TaoismSkillId = 601011;
  255. BagController.Init();
  256. //初始化关卡
  257. CurrentsmallPlaces = GetSmallPlacesData(GetMaxSmallPlacesId());
  258. StaticUpdater.Instance.RemoveRenderUpdateCallBack(Update);
  259. StaticUpdater.Instance.AddRenderUpdateCallBack(Update);
  260. }
  261. private float timer;
  262. public int GetMaxSmallPlacesId()
  263. {
  264. int placesId = AccountFileInfo.Instance.playerData.smallPlacesDatas.Max(p => p.id);
  265. return placesId;
  266. }
  267. public AccountFileInfo.PlacesData GetPlacesData(int placesId)
  268. {
  269. return AccountFileInfo.Instance.playerData.placesDatas.FirstOrDefault(p => p.id == placesId);
  270. }
  271. public AccountFileInfo.SmallPlacesData GetSmallPlacesData(int smallPlacesId)
  272. {
  273. return AccountFileInfo.Instance.playerData.smallPlacesDatas.FirstOrDefault(p => p.id == smallPlacesId);
  274. }
  275. public float GetMapBl(int map)
  276. {
  277. SmallPlacesConfig smallPlacesConfig = ConfigComponent.Instance.Get<SmallPlacesConfig>(map);
  278. AccountFileInfo.PlacesData placesData = GetPlacesData(smallPlacesConfig.PlacesId);
  279. if (placesData == null)
  280. return 0;
  281. PlacesConfig placesConfig = ConfigComponent.Instance.Get<PlacesConfig>(smallPlacesConfig.PlacesId);
  282. if (placesConfig.TotalScore == 0)
  283. {
  284. return 0;
  285. }
  286. return (float)Math.Round(((float)placesData.progress / placesConfig.TotalScore) * 100, 1);
  287. // AccountFileInfo.Instance.playerData.completeEvents.Where(ce =>placesConfig.MainTaskID.Contains(ce.eventID) || placesConfig.ZhixianID.Contains(ce.eventID) || placesConfig.ZhixianID.Contains(ce.1001
  288. // ))
  289. }
  290. // List<long> removeKey = new List<long>();
  291. private bool isUpdate = false;
  292. private void Update()
  293. {
  294. timer += Time.deltaTime;
  295. if (timer > 1)
  296. {
  297. timer = 0;
  298. // PlayerManager.Instance.myHero.heroData.exp += myHero.powerUpConfig.AutoXiuwei;
  299. // AccountFileInfo.Instance.SavePlayerData();
  300. if (AccountFileInfo.Instance.playerData.QiankundaiDropTimer <= gameConstantConfig.qiankundaiMaxTime)
  301. {
  302. AccountFileInfo.Instance.playerData.QiankundaiDropTimer++;
  303. QianKunDaiAward();
  304. AccountFileInfo.Instance.SavePlayerData();
  305. }
  306. }
  307. //每天刷新
  308. if (TimeHelper.ClientNow() > AccountFileInfo.Instance.playerData.nextRefence)
  309. {
  310. AccountFileInfo.Instance.playerData.nextRefence =
  311. TimeHelper.GetBaseRefreshTime(TimeHelper.ClientNow());
  312. AccountFileInfo.Instance.playerData.todayUseExpElixrPanelCount = 0;
  313. AccountFileInfo.Instance.playerData.todayDivineSensePoint = 0;
  314. foreach (var playerDataSummonData in AccountFileInfo.Instance.playerData.SummonDatas)
  315. {
  316. playerDataSummonData.onePayCount = 0;
  317. playerDataSummonData.tenPayCount = 0;
  318. playerDataSummonData.oneFreeCount = 0;
  319. playerDataSummonData.nextOneFreeTime = 0;
  320. playerDataSummonData.tenFreeCount = 0;
  321. playerDataSummonData.nextTenFreeTime = 0;
  322. }
  323. AccountFileInfo.Instance.SavePlayerData();
  324. }
  325. foreach (var keyValuePair in AccountFileInfo.Instance.playerData.daoYouGuaiJiDatas)
  326. {
  327. if (!keyValuePair.isLeave && TimeHelper.ClientNow() > keyValuePair.leaveTime)
  328. {
  329. //判断概率给奖励
  330. isUpdate = true;
  331. keyValuePair.isLeave = true;
  332. AccountFileInfo.DaoYouData daoYouData = AccountFileInfo.Instance.playerData.daoYouDatas.FirstOrDefault(d => d.id == keyValuePair.daoyouDataID);
  333. DaoyouModelConfig daoyouModelConfig =
  334. ConfigComponent.Instance.Get<DaoyouModelConfig>(daoYouData.id);
  335. int bl = GetBl(daoYouData, daoyouModelConfig.guajiBuffID[0]);
  336. int randomValue1 = Random.Range(0, 101);
  337. LogTool.Log("道友随机怪率:" + randomValue1 + " 比例:" + bl);
  338. List<AccountFileInfo.ItemData> itemDatas = new List<AccountFileInfo.ItemData>();
  339. if (randomValue1 >= bl)
  340. {
  341. for (var i = 1; i < daoyouModelConfig.guajiBuffID.Length; i++)
  342. {
  343. int count = GetBl(daoYouData, daoyouModelConfig.guajiBuffID[i]);
  344. guajibuff guajibuff =
  345. ConfigComponent.Instance.Get<guajibuff>(daoyouModelConfig.guajiBuffID[i]);
  346. switch (guajibuff.paraValue)
  347. {
  348. case 1:
  349. itemDatas.Add(new AccountFileInfo.ItemData(1003, count));
  350. LogTool.Log("道友获得道具id:" + 1003 + " 数量:" + count);
  351. break;
  352. case 2:
  353. itemDatas.Add(new AccountFileInfo.ItemData(1001, count));
  354. LogTool.Log("道友获得道具id:" + 1001 + " 数量:" + count);
  355. break;
  356. case 3:
  357. itemDatas.Add(new AccountFileInfo.ItemData(1005, count));
  358. LogTool.Log("道友获得道具id:" + 1005 + " 数量:" + count);
  359. break;
  360. case 4:
  361. itemDatas.Add(new AccountFileInfo.ItemData(1006, count));
  362. LogTool.Log("道友获得道具id:" + 1006 + " 数量:" + count);
  363. break;
  364. }
  365. }
  366. }
  367. keyValuePair.items.AddRange(itemDatas);
  368. }
  369. }
  370. if (isUpdate)
  371. {
  372. AccountFileInfo.Instance.SavePlayerData();
  373. EventManager.Instance.Dispatch(CustomEventType.DaoYouCounUpdate, null);
  374. isUpdate = false;
  375. }
  376. }
  377. public async void ChangeMap(int mapId)
  378. {
  379. SmallPlacesConfig smallPlacesConfig = ConfigComponent.Instance.Get<SmallPlacesConfig>(mapId);
  380. if (smallPlacesConfig.ID == 0)
  381. return;
  382. AccountFileInfo.SmallPlacesData lastSmallPlacesData = PlayerManager.Instance.GetSmallPlacesData(smallPlacesConfig.ID - 1);
  383. SmallPlacesConfig lastSmallPlacesConfig = ConfigComponent.Instance.Get<SmallPlacesConfig>(smallPlacesConfig.ID - 1);
  384. if (smallPlacesConfig.ID > 1 && (lastSmallPlacesData == null || lastSmallPlacesData.completionEventCount < lastSmallPlacesConfig.CompletionEventCount))
  385. {
  386. return;
  387. }
  388. if (lastSmallPlacesConfig.UnlockEnvetid != 0)
  389. {
  390. AccountFileInfo.EventList eventList = AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce => ce.eventID == lastSmallPlacesConfig.UnlockEnvetid);
  391. if (eventList == null || !eventList.isCompleted)
  392. {
  393. return;
  394. }
  395. }
  396. AccountFileInfo.SmallPlacesData smallPlacesData = PlayerManager.Instance.GetSmallPlacesData(smallPlacesConfig.ID);
  397. if (smallPlacesData == null)
  398. {
  399. smallPlacesData = new AccountFileInfo.SmallPlacesData();
  400. smallPlacesData.id = smallPlacesConfig.ID;
  401. AccountFileInfo.Instance.playerData.smallPlacesDatas.Add(smallPlacesData);
  402. }
  403. AccountFileInfo.PlacesData currentPlacesData = PlayerManager.Instance.GetPlacesData(smallPlacesConfig.ID);
  404. if (currentPlacesData == null)
  405. {
  406. currentPlacesData = new AccountFileInfo.PlacesData();
  407. currentPlacesData.id = smallPlacesConfig.PlacesId;
  408. AccountFileInfo.Instance.playerData.placesDatas.Add(currentPlacesData);
  409. }
  410. PlayerManager.Instance.CurrentsmallPlaces = smallPlacesData;
  411. EventManager.Instance.Dispatch(CustomEventType.ChangeMap, null);
  412. }
  413. public void QianKunDaiAward()
  414. {
  415. foreach (var playerDataQiankundaiData in AccountFileInfo.Instance.playerData.QiankundaiDatas)
  416. {
  417. //重置掉落次数
  418. QiankundaiConfig qiankundaiConfig =
  419. ConfigComponent.Instance.Get<QiankundaiConfig>(playerDataQiankundaiData.id);
  420. if (qiankundaiConfig.dropType != 2 &&
  421. TimeHelper.ClientNow() >= playerDataQiankundaiData.refenceTime)
  422. {
  423. if (qiankundaiConfig.dropPara1 == 1)
  424. {
  425. playerDataQiankundaiData.refenceTime = TimeHelper.ClientNow() + 60 * 60 * 1000;
  426. }
  427. else if (qiankundaiConfig.dropPara1 == 2)
  428. {
  429. playerDataQiankundaiData.refenceTime =
  430. TimeHelper.GetBaseRefreshTime(TimeHelper.ClientNow());
  431. }
  432. else if (qiankundaiConfig.dropPara1 == 3)
  433. {
  434. }
  435. playerDataQiankundaiData.dropCount = 0;
  436. }
  437. if (myHero.powerUpConfig.ID >= qiankundaiConfig.dropLevel[0] &&
  438. myHero.powerUpConfig.ID <= qiankundaiConfig.dropLevel[1])
  439. {
  440. if (playerDataQiankundaiData.dropCount < qiankundaiConfig.dropPara2 ||
  441. qiankundaiConfig.dropPara2 == -1)
  442. {
  443. playerDataQiankundaiData.dropTime++;
  444. if (playerDataQiankundaiData.dropTime >= qiankundaiConfig.dropTypePara)
  445. {
  446. //发放奖励
  447. for (var i = 0; i < qiankundaiConfig.ChoukaID.Length; i++)
  448. {
  449. List<ItemInfo> itemInfos = DropManager.Instance.Drop(qiankundaiConfig.ChoukaID[i],
  450. qiankundaiConfig.DropCount[i]);
  451. foreach (var itemInfo in itemInfos)
  452. {
  453. AccountFileInfo.ItemData itemData =
  454. AccountFileInfo.Instance.playerData.QiankundaiItemDatas.FirstOrDefault(i =>
  455. i.itemId == itemInfo.itemID);
  456. if (itemData != null)
  457. {
  458. itemData.itemCount += itemInfo.count.Value;
  459. }
  460. else
  461. {
  462. itemData = itemInfo.ToItemData();
  463. AccountFileInfo.Instance.playerData.QiankundaiItemDatas.Add(itemData);
  464. }
  465. }
  466. }
  467. playerDataQiankundaiData.dropCount = 0;
  468. playerDataQiankundaiData.dropTime = 0;
  469. }
  470. }
  471. }
  472. // AccountFileInfo.Instance.SavePlayerData();
  473. }
  474. }
  475. public void CalculateOfflineRewards()
  476. {
  477. // return;
  478. if (AccountFileInfo.Instance.playerData.QiankundaiDropTimer <= PlayerManager.Instance.gameConstantConfig.qiankundaiMaxTime && AccountFileInfo.Instance.playerData.ExitTime > 0)
  479. {
  480. int miao = (int)((TimeHelper.ClientNow() - AccountFileInfo.Instance.playerData.ExitTime) / 1000);
  481. miao = AccountFileInfo.Instance.playerData.QiankundaiDropTimer + miao >= PlayerManager.Instance.gameConstantConfig.qiankundaiMaxTime ? PlayerManager.Instance.gameConstantConfig.qiankundaiMaxTime - miao : miao;
  482. AccountFileInfo.Instance.playerData.QiankundaiDropTimer += miao;
  483. for (int i = 0; i < miao; i++)
  484. {
  485. QianKunDaiAward();
  486. }
  487. }
  488. AccountFileInfo.Instance.playerData.ExitTime = 0;
  489. AccountFileInfo.Instance.SavePlayerData();
  490. }
  491. public void AddTestHeroInfo(TestCombatHeroConfig.TestHeroInfoConfig testHeroInfoConfig)
  492. {
  493. isTest = true;
  494. GongFaControl.allSkill.Clear();
  495. SkillConfig[] allSkillConfig = ConfigComponent.Instance.GetAll<SkillConfig>();
  496. for (int i = 0; i < allSkillConfig.Length; i++)
  497. {
  498. SkillConfig skillConfig = allSkillConfig[i];
  499. if (skillConfig.level == testHeroInfoConfig.skillStart)
  500. {
  501. SkillInfo skillInfo = new SkillInfo(skillConfig.ID, testHeroInfoConfig.skillLevel);
  502. skillInfo.index = -1;
  503. GongFaControl.AddSkillInfo(skillInfo);
  504. }
  505. }
  506. AccountFileInfo.HeroData heroData = new AccountFileInfo.HeroData();
  507. heroData.heroModelId = testHeroInfoConfig.heroID;
  508. heroData.heroPowerId = testHeroInfoConfig.level;
  509. myHero = new HeroInfo();
  510. myHero.InitHero(heroData);
  511. if (testHeroInfoConfig.skill.Count > 0)
  512. {
  513. GongFaControl.allSkill.Clear();
  514. for (int i = 0; i < testHeroInfoConfig.skill.Count; i++)
  515. {
  516. SkillInfo skillInfo = new SkillInfo(testHeroInfoConfig.skill[i], testHeroInfoConfig.skillLevel,
  517. testHeroInfoConfig.skillStart);
  518. skillInfo.index = i;
  519. GongFaControl.AddSkillInfo(skillInfo);
  520. }
  521. }
  522. else
  523. {
  524. SkillInfo[] skillInfos = GongFaControl.allUseSkill;
  525. for (int i = 0; i < skillInfos.Length; i++)
  526. {
  527. if (skillInfos[i] != null)
  528. {
  529. SkillInfo skillInfo = new SkillInfo(skillInfos[i].skillConfig.IDGroup,
  530. testHeroInfoConfig.skillLevel,
  531. testHeroInfoConfig.skillStart);
  532. skillInfo.index = i;
  533. GongFaControl.allUseSkill[i] = skillInfo;
  534. }
  535. }
  536. }
  537. if (testHeroInfoConfig.magicWeaponId.Count > 0)
  538. {
  539. int fbLevel = ((testHeroInfoConfig.level - 1) / 10) + 1;
  540. if (fbLevel <= 0)
  541. {
  542. fbLevel = 1;
  543. }
  544. for (int i = 0; i < testHeroInfoConfig.magicWeaponId.Count; i++)
  545. {
  546. FaBaoInfo faBaoInfo = new FaBaoInfo(testHeroInfoConfig.magicWeaponId[i], fbLevel);
  547. faBaoInfo.FaBaoData.useIndex = i;
  548. FaBaoControl.FightFaBao[i] = faBaoInfo;
  549. FaBaoControl.AddFaBao(faBaoInfo);
  550. }
  551. }
  552. float[] qiangDu = new float[] { 0, 35.7f, 98f, 138.7f, 199.3f, 216f };
  553. int qiangDuLevelId = Mathf.CeilToInt(testHeroInfoConfig.level / 5f);
  554. HeroQiangDuAddConfig heroQiangDuAddConfig = ConfigComponent.Instance.Get<HeroQiangDuAddConfig>(qiangDuLevelId);
  555. int index = Mathf.RoundToInt(heroQiangDuAddConfig.qiangDuZhi) - 1;
  556. myHero.hp = (EncryptionLong)(myHero.hp.Value * (qiangDu[index] / 100f + 1));
  557. myHero.attack = (EncryptionLong)(myHero.attack.Value * (qiangDu[index] / 100f + 1));
  558. myHero.defense = (EncryptionLong)(myHero.defense.Value * (qiangDu[index] / 100f + 1));
  559. // for (int i = 0; i < 4; i++)
  560. // {
  561. // FaBaoControl.FightFaBao[i] = FaBaoControl.myAllFaBao[i];
  562. // }
  563. myHero.hp += testHeroInfoConfig.hp;
  564. myHero.attack += testHeroInfoConfig.att;
  565. myHero.defense += testHeroInfoConfig.def;
  566. myHero.Metal += testHeroInfoConfig.jing;
  567. myHero.Wood += testHeroInfoConfig.mu;
  568. myHero.Water += testHeroInfoConfig.shui;
  569. myHero.Fire += testHeroInfoConfig.huo;
  570. myHero.Earth += testHeroInfoConfig.tu;
  571. myHero.TaoismSkillId = 601011;
  572. myHero.MagicWeaponID.Clear();
  573. myHero.MagicWeaponID.AddRange(FaBaoControl.FightFaBao);
  574. // for (int i = 0; i < FaBaoControl.FightFaBao.Length; i++)
  575. // {
  576. // FaBaoInfo faBaoInfo = FaBaoControl.FightFaBao[i];
  577. // if (faBaoInfo != null)
  578. // {
  579. // foreach (var VARIABLE in faBaoInfo.attriButedIC)
  580. // {
  581. // switch (VARIABLE.Key)
  582. // {
  583. // case 1:
  584. // myHero.hp += VARIABLE.Value;
  585. // break;
  586. // case 2:
  587. // myHero.defense += VARIABLE.Value;
  588. // break;
  589. // case 3:
  590. // myHero.attack += VARIABLE.Value;
  591. // break;
  592. // }
  593. // }
  594. // }
  595. // }
  596. }
  597. /// <summary>
  598. /// 保存英雄数据
  599. /// </summary>
  600. /// <param name="heroInfo"></param>
  601. public void SaveHeroData(HeroInfo heroInfo)
  602. {
  603. AccountFileInfo.Instance.playerData.heroData = heroInfo.heroData;
  604. AccountFileInfo.Instance.SavePlayerData();
  605. }
  606. /// <summary>
  607. /// 时间(秒)转换位小时分钟秒
  608. /// </summary>
  609. /// <param name="miao"></param>
  610. /// <returns></returns>
  611. public static string TimeToHSM(long miao)
  612. {
  613. long fen = miao / 60;
  614. miao = miao % 60;
  615. long xiaoShi = fen / 60;
  616. long tian = xiaoShi / 24;
  617. xiaoShi = xiaoShi % 24;
  618. fen = fen % 60;
  619. if (tian > 0)
  620. {
  621. return $"{tian}天{xiaoShi}小時";
  622. }
  623. else
  624. {
  625. if (xiaoShi <= 0 && fen <= 59)
  626. {
  627. return $"{fen}分{miao}秒";
  628. }
  629. else
  630. {
  631. return $"{xiaoShi}小時{fen}分";
  632. }
  633. }
  634. }
  635. }