PlayerManager.cs 28 KB

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