PlayerManager.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  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. yindaoHeroData = new HeroInfo();
  252. yindaoHeroData.InitMonster(102, 200);
  253. yindaoHeroData.isMonster = false;
  254. // yindaoHeroData = heroInfo;
  255. yindaoHeroData.TaoismSkillId = 601011;
  256. // myHero= yindaoHeroData;
  257. BagController.Init();
  258. //初始化关卡
  259. CurrentsmallPlaces = GetSmallPlacesData(GetMaxSmallPlacesId());
  260. StaticUpdater.Instance.RemoveRenderUpdateCallBack(Update);
  261. StaticUpdater.Instance.AddRenderUpdateCallBack(Update);
  262. }
  263. private float timer;
  264. public int GetMaxSmallPlacesId()
  265. {
  266. int placesId = AccountFileInfo.Instance.playerData.smallPlacesDatas.Max(p => p.id);
  267. return placesId;
  268. }
  269. public AccountFileInfo.PlacesData GetPlacesData(int placesId)
  270. {
  271. return AccountFileInfo.Instance.playerData.placesDatas.FirstOrDefault(p => p.id == placesId);
  272. }
  273. public AccountFileInfo.SmallPlacesData GetSmallPlacesData(int smallPlacesId)
  274. {
  275. return AccountFileInfo.Instance.playerData.smallPlacesDatas.FirstOrDefault(p => p.id == smallPlacesId);
  276. }
  277. public float GetMapBl(int map)
  278. {
  279. SmallPlacesConfig smallPlacesConfig = ConfigComponent.Instance.Get<SmallPlacesConfig>(map);
  280. AccountFileInfo.PlacesData placesData = GetPlacesData(smallPlacesConfig.PlacesId);
  281. if (placesData == null)
  282. return 0;
  283. PlacesConfig placesConfig = ConfigComponent.Instance.Get<PlacesConfig>(smallPlacesConfig.PlacesId);
  284. if (placesConfig.TotalScore == 0)
  285. {
  286. return 0;
  287. }
  288. return (float)Math.Round(((float)placesData.progress / placesConfig.TotalScore) * 100, 1);
  289. // AccountFileInfo.Instance.playerData.completeEvents.Where(ce =>placesConfig.MainTaskID.Contains(ce.eventID) || placesConfig.ZhixianID.Contains(ce.eventID) || placesConfig.ZhixianID.Contains(ce.1001
  290. // ))
  291. }
  292. // List<long> removeKey = new List<long>();
  293. private bool isUpdate = false;
  294. private void Update()
  295. {
  296. timer += Time.deltaTime;
  297. if (timer > 1)
  298. {
  299. timer = 0;
  300. // PlayerManager.Instance.myHero.heroData.exp += myHero.powerUpConfig.AutoXiuwei;
  301. // AccountFileInfo.Instance.SavePlayerData();
  302. if (AccountFileInfo.Instance.playerData.QiankundaiDropTimer <= gameConstantConfig.qiankundaiMaxTime)
  303. {
  304. AccountFileInfo.Instance.playerData.QiankundaiDropTimer++;
  305. QianKunDaiAward();
  306. AccountFileInfo.Instance.SavePlayerData();
  307. }
  308. }
  309. //每天刷新
  310. if (TimeHelper.ClientNow() > AccountFileInfo.Instance.playerData.nextRefence)
  311. {
  312. AccountFileInfo.Instance.playerData.nextRefence =
  313. TimeHelper.GetBaseRefreshTime(TimeHelper.ClientNow());
  314. AccountFileInfo.Instance.playerData.todayUseExpElixrPanelCount = 0;
  315. AccountFileInfo.Instance.playerData.todayDivineSensePoint = 0;
  316. foreach (var playerDataSummonData in AccountFileInfo.Instance.playerData.SummonDatas)
  317. {
  318. playerDataSummonData.onePayCount = 0;
  319. playerDataSummonData.tenPayCount = 0;
  320. playerDataSummonData.oneFreeCount = 0;
  321. playerDataSummonData.nextOneFreeTime = 0;
  322. playerDataSummonData.tenFreeCount = 0;
  323. playerDataSummonData.nextTenFreeTime = 0;
  324. }
  325. AccountFileInfo.Instance.SavePlayerData();
  326. }
  327. foreach (var keyValuePair in AccountFileInfo.Instance.playerData.daoYouGuaiJiDatas)
  328. {
  329. if (!keyValuePair.isLeave && TimeHelper.ClientNow() > keyValuePair.leaveTime)
  330. {
  331. //判断概率给奖励
  332. isUpdate = true;
  333. keyValuePair.isLeave = true;
  334. AccountFileInfo.DaoYouData daoYouData =
  335. AccountFileInfo.Instance.playerData.daoYouDatas.FirstOrDefault(d =>
  336. d.id == keyValuePair.daoyouDataID);
  337. DaoyouModelConfig daoyouModelConfig =
  338. ConfigComponent.Instance.Get<DaoyouModelConfig>(daoYouData.id);
  339. int bl = GetBl(daoYouData, daoyouModelConfig.guajiBuffID[0]);
  340. int randomValue1 = Random.Range(0, 101);
  341. LogTool.Log("道友随机怪率:" + randomValue1 + " 比例:" + bl);
  342. List<AccountFileInfo.ItemData> itemDatas = new List<AccountFileInfo.ItemData>();
  343. if (randomValue1 >= bl)
  344. {
  345. for (var i = 1; i < daoyouModelConfig.guajiBuffID.Length; i++)
  346. {
  347. int count = GetBl(daoYouData, daoyouModelConfig.guajiBuffID[i]);
  348. guajibuff guajibuff =
  349. ConfigComponent.Instance.Get<guajibuff>(daoyouModelConfig.guajiBuffID[i]);
  350. switch (guajibuff.paraValue)
  351. {
  352. case 1:
  353. itemDatas.Add(new AccountFileInfo.ItemData(1003, count));
  354. LogTool.Log("道友获得道具id:" + 1003 + " 数量:" + count);
  355. break;
  356. case 2:
  357. itemDatas.Add(new AccountFileInfo.ItemData(1001, count));
  358. LogTool.Log("道友获得道具id:" + 1001 + " 数量:" + count);
  359. break;
  360. case 3:
  361. itemDatas.Add(new AccountFileInfo.ItemData(1005, count));
  362. LogTool.Log("道友获得道具id:" + 1005 + " 数量:" + count);
  363. break;
  364. case 4:
  365. itemDatas.Add(new AccountFileInfo.ItemData(1006, count));
  366. LogTool.Log("道友获得道具id:" + 1006 + " 数量:" + count);
  367. break;
  368. }
  369. }
  370. }
  371. keyValuePair.items.AddRange(itemDatas);
  372. }
  373. }
  374. if (isUpdate)
  375. {
  376. AccountFileInfo.Instance.SavePlayerData();
  377. EventManager.Instance.Dispatch(CustomEventType.DaoYouCounUpdate, null);
  378. isUpdate = false;
  379. }
  380. }
  381. public async void ChangeMap(int mapId)
  382. {
  383. SmallPlacesConfig smallPlacesConfig = ConfigComponent.Instance.Get<SmallPlacesConfig>(mapId);
  384. if (smallPlacesConfig.ID == 0)
  385. return;
  386. AccountFileInfo.SmallPlacesData lastSmallPlacesData =
  387. PlayerManager.Instance.GetSmallPlacesData(smallPlacesConfig.ID - 1);
  388. SmallPlacesConfig lastSmallPlacesConfig =
  389. ConfigComponent.Instance.Get<SmallPlacesConfig>(smallPlacesConfig.ID - 1);
  390. if (smallPlacesConfig.ID > 1 && (lastSmallPlacesData == null ||
  391. lastSmallPlacesData.completionEventCount <
  392. lastSmallPlacesConfig.CompletionEventCount))
  393. {
  394. return;
  395. }
  396. if (lastSmallPlacesConfig.UnlockEnvetid != 0)
  397. {
  398. AccountFileInfo.EventList eventList =
  399. AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce =>
  400. ce.eventID == lastSmallPlacesConfig.UnlockEnvetid);
  401. if (eventList == null || !eventList.isCompleted)
  402. {
  403. return;
  404. }
  405. }
  406. AccountFileInfo.SmallPlacesData smallPlacesData =
  407. PlayerManager.Instance.GetSmallPlacesData(smallPlacesConfig.ID);
  408. if (smallPlacesData == null)
  409. {
  410. smallPlacesData = new AccountFileInfo.SmallPlacesData();
  411. smallPlacesData.id = smallPlacesConfig.ID;
  412. AccountFileInfo.Instance.playerData.smallPlacesDatas.Add(smallPlacesData);
  413. }
  414. AccountFileInfo.PlacesData currentPlacesData = PlayerManager.Instance.GetPlacesData(smallPlacesConfig.ID);
  415. if (currentPlacesData == null)
  416. {
  417. currentPlacesData = new AccountFileInfo.PlacesData();
  418. currentPlacesData.id = smallPlacesConfig.PlacesId;
  419. AccountFileInfo.Instance.playerData.placesDatas.Add(currentPlacesData);
  420. }
  421. PlayerManager.Instance.CurrentsmallPlaces = smallPlacesData;
  422. EventManager.Instance.Dispatch(CustomEventType.ChangeMap, null);
  423. }
  424. public void QianKunDaiAward()
  425. {
  426. foreach (var playerDataQiankundaiData in AccountFileInfo.Instance.playerData.QiankundaiDatas)
  427. {
  428. //重置掉落次数
  429. QiankundaiConfig qiankundaiConfig =
  430. ConfigComponent.Instance.Get<QiankundaiConfig>(playerDataQiankundaiData.id);
  431. if (qiankundaiConfig.dropType != 2 &&
  432. TimeHelper.ClientNow() >= playerDataQiankundaiData.refenceTime)
  433. {
  434. if (qiankundaiConfig.dropPara1 == 1)
  435. {
  436. playerDataQiankundaiData.refenceTime = TimeHelper.ClientNow() + 60 * 60 * 1000;
  437. }
  438. else if (qiankundaiConfig.dropPara1 == 2)
  439. {
  440. playerDataQiankundaiData.refenceTime =
  441. TimeHelper.GetBaseRefreshTime(TimeHelper.ClientNow());
  442. }
  443. else if (qiankundaiConfig.dropPara1 == 3)
  444. {
  445. }
  446. playerDataQiankundaiData.dropCount = 0;
  447. }
  448. if (myHero.powerUpConfig.ID >= qiankundaiConfig.dropLevel[0] &&
  449. myHero.powerUpConfig.ID <= qiankundaiConfig.dropLevel[1])
  450. {
  451. if (playerDataQiankundaiData.dropCount < qiankundaiConfig.dropPara2 ||
  452. qiankundaiConfig.dropPara2 == -1)
  453. {
  454. playerDataQiankundaiData.dropTime++;
  455. if (playerDataQiankundaiData.dropTime >= qiankundaiConfig.dropTypePara)
  456. {
  457. //发放奖励
  458. for (var i = 0; i < qiankundaiConfig.ChoukaID.Length; i++)
  459. {
  460. List<ItemInfo> itemInfos = DropManager.Instance.Drop(qiankundaiConfig.ChoukaID[i],
  461. qiankundaiConfig.DropCount[i]);
  462. foreach (var itemInfo in itemInfos)
  463. {
  464. AccountFileInfo.ItemData itemData =
  465. AccountFileInfo.Instance.playerData.QiankundaiItemDatas.FirstOrDefault(i =>
  466. i.itemId == itemInfo.itemID);
  467. if (itemData != null)
  468. {
  469. itemData.itemCount += itemInfo.count.Value;
  470. }
  471. else
  472. {
  473. itemData = itemInfo.ToItemData();
  474. AccountFileInfo.Instance.playerData.QiankundaiItemDatas.Add(itemData);
  475. }
  476. }
  477. }
  478. playerDataQiankundaiData.dropCount = 0;
  479. playerDataQiankundaiData.dropTime = 0;
  480. }
  481. }
  482. }
  483. // AccountFileInfo.Instance.SavePlayerData();
  484. }
  485. }
  486. public void CalculateOfflineRewards()
  487. {
  488. // return;
  489. if (AccountFileInfo.Instance.playerData.QiankundaiDropTimer <=
  490. PlayerManager.Instance.gameConstantConfig.qiankundaiMaxTime &&
  491. AccountFileInfo.Instance.playerData.ExitTime > 0)
  492. {
  493. int miao = (int)((TimeHelper.ClientNow() - AccountFileInfo.Instance.playerData.ExitTime) / 1000);
  494. miao = AccountFileInfo.Instance.playerData.QiankundaiDropTimer + miao >=
  495. PlayerManager.Instance.gameConstantConfig.qiankundaiMaxTime
  496. ? PlayerManager.Instance.gameConstantConfig.qiankundaiMaxTime - miao
  497. : miao;
  498. AccountFileInfo.Instance.playerData.QiankundaiDropTimer += miao;
  499. for (int i = 0; i < miao; i++)
  500. {
  501. QianKunDaiAward();
  502. }
  503. }
  504. AccountFileInfo.Instance.playerData.ExitTime = 0;
  505. AccountFileInfo.Instance.SavePlayerData();
  506. }
  507. public void AddTestHeroInfo(TestCombatHeroConfig.TestHeroInfoConfig testHeroInfoConfig)
  508. {
  509. isTest = true;
  510. GongFaControl.allSkill.Clear();
  511. SkillConfig[] allSkillConfig = ConfigComponent.Instance.GetAll<SkillConfig>();
  512. for (int i = 0; i < allSkillConfig.Length; i++)
  513. {
  514. SkillConfig skillConfig = allSkillConfig[i];
  515. if (skillConfig.level == testHeroInfoConfig.skillStart)
  516. {
  517. SkillInfo skillInfo = new SkillInfo(skillConfig.ID, testHeroInfoConfig.skillLevel);
  518. skillInfo.index = -1;
  519. GongFaControl.AddSkillInfo(skillInfo);
  520. }
  521. }
  522. AccountFileInfo.HeroData heroData = new AccountFileInfo.HeroData();
  523. heroData.heroModelId = testHeroInfoConfig.heroID;
  524. heroData.heroPowerId = testHeroInfoConfig.level;
  525. myHero = new HeroInfo();
  526. myHero.InitHero(heroData);
  527. if (testHeroInfoConfig.skill.Count > 0)
  528. {
  529. GongFaControl.allSkill.Clear();
  530. for (int i = 0; i < testHeroInfoConfig.skill.Count; i++)
  531. {
  532. SkillInfo skillInfo = new SkillInfo(testHeroInfoConfig.skill[i], testHeroInfoConfig.skillLevel,
  533. testHeroInfoConfig.skillStart);
  534. skillInfo.index = i;
  535. GongFaControl.AddSkillInfo(skillInfo);
  536. }
  537. }
  538. else
  539. {
  540. SkillInfo[] skillInfos = GongFaControl.allUseSkill;
  541. for (int i = 0; i < skillInfos.Length; i++)
  542. {
  543. if (skillInfos[i] != null)
  544. {
  545. SkillInfo skillInfo = new SkillInfo(skillInfos[i].skillConfig.IDGroup,
  546. testHeroInfoConfig.skillLevel,
  547. testHeroInfoConfig.skillStart);
  548. skillInfo.index = i;
  549. GongFaControl.allUseSkill[i] = skillInfo;
  550. }
  551. }
  552. }
  553. if (testHeroInfoConfig.magicWeaponId.Count > 0)
  554. {
  555. int fbLevel = ((testHeroInfoConfig.level - 1) / 10) + 1;
  556. if (fbLevel <= 0)
  557. {
  558. fbLevel = 1;
  559. }
  560. for (int i = 0; i < testHeroInfoConfig.magicWeaponId.Count; i++)
  561. {
  562. FaBaoInfo faBaoInfo = new FaBaoInfo(testHeroInfoConfig.magicWeaponId[i], fbLevel);
  563. faBaoInfo.FaBaoData.useIndex = i;
  564. FaBaoControl.FightFaBao[i] = faBaoInfo;
  565. FaBaoControl.AddFaBao(faBaoInfo);
  566. }
  567. }
  568. float[] qiangDu = new float[] { 0, 35.7f, 98f, 138.7f, 199.3f, 216f };
  569. int qiangDuLevelId = Mathf.CeilToInt(testHeroInfoConfig.level / 5f);
  570. HeroQiangDuAddConfig heroQiangDuAddConfig = ConfigComponent.Instance.Get<HeroQiangDuAddConfig>(qiangDuLevelId);
  571. int index = Mathf.RoundToInt(heroQiangDuAddConfig.qiangDuZhi) - 1;
  572. myHero.hp = (EncryptionLong)(myHero.hp.Value * (qiangDu[index] / 100f + 1));
  573. myHero.attack = (EncryptionLong)(myHero.attack.Value * (qiangDu[index] / 100f + 1));
  574. myHero.defense = (EncryptionLong)(myHero.defense.Value * (qiangDu[index] / 100f + 1));
  575. // for (int i = 0; i < 4; i++)
  576. // {
  577. // FaBaoControl.FightFaBao[i] = FaBaoControl.myAllFaBao[i];
  578. // }
  579. myHero.hp += testHeroInfoConfig.hp;
  580. myHero.attack += testHeroInfoConfig.att;
  581. myHero.defense += testHeroInfoConfig.def;
  582. myHero.Metal += testHeroInfoConfig.jing;
  583. myHero.Wood += testHeroInfoConfig.mu;
  584. myHero.Water += testHeroInfoConfig.shui;
  585. myHero.Fire += testHeroInfoConfig.huo;
  586. myHero.Earth += testHeroInfoConfig.tu;
  587. myHero.TaoismSkillId = 601011;
  588. myHero.MagicWeaponID.Clear();
  589. myHero.MagicWeaponID.AddRange(FaBaoControl.FightFaBao);
  590. // for (int i = 0; i < FaBaoControl.FightFaBao.Length; i++)
  591. // {
  592. // FaBaoInfo faBaoInfo = FaBaoControl.FightFaBao[i];
  593. // if (faBaoInfo != null)
  594. // {
  595. // foreach (var VARIABLE in faBaoInfo.attriButedIC)
  596. // {
  597. // switch (VARIABLE.Key)
  598. // {
  599. // case 1:
  600. // myHero.hp += VARIABLE.Value;
  601. // break;
  602. // case 2:
  603. // myHero.defense += VARIABLE.Value;
  604. // break;
  605. // case 3:
  606. // myHero.attack += VARIABLE.Value;
  607. // break;
  608. // }
  609. // }
  610. // }
  611. // }
  612. }
  613. /// <summary>
  614. /// 保存英雄数据
  615. /// </summary>
  616. /// <param name="heroInfo"></param>
  617. public void SaveHeroData(HeroInfo heroInfo)
  618. {
  619. AccountFileInfo.Instance.playerData.heroData = heroInfo.heroData;
  620. AccountFileInfo.Instance.SavePlayerData();
  621. }
  622. /// <summary>
  623. /// 时间(秒)转换位小时分钟秒
  624. /// </summary>
  625. /// <param name="miao"></param>
  626. /// <returns></returns>
  627. public static string TimeToHSM(long miao)
  628. {
  629. long fen = miao / 60;
  630. miao = miao % 60;
  631. long xiaoShi = fen / 60;
  632. long tian = xiaoShi / 24;
  633. xiaoShi = xiaoShi % 24;
  634. fen = fen % 60;
  635. if (tian > 0)
  636. {
  637. return $"{tian}天{xiaoShi}小時";
  638. }
  639. else
  640. {
  641. if (xiaoShi <= 0 && fen <= 59)
  642. {
  643. return $"{fen}分{miao}秒";
  644. }
  645. else
  646. {
  647. return $"{xiaoShi}小時{fen}分";
  648. }
  649. }
  650. }
  651. }