PlayerManager.cs 29 KB

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