PlayerManager.cs 28 KB

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