PlayerManager.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782
  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,bool isShowUI = true)
  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. if(isShowUI)
  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. }