PlayerManager.cs 29 KB

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