PlayerManager.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784
  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. if (!TimeHelper.IsNetworkTimeReady)
  306. {
  307. LogTool.Error($"获取网络时间失败,挂机奖励停止计算");
  308. return;
  309. }
  310. timer += Time.deltaTime;
  311. if (timer > 1)
  312. {
  313. timer = 0;
  314. if (AccountFileInfo.Instance.playerData.QiankundaiDropTimer <= gameConstantConfig.qiankundaiMaxTime)
  315. {
  316. AccountFileInfo.Instance.playerData.QiankundaiDropTimer++;
  317. QianKunDaiAward();
  318. AccountFileInfo.Instance.SavePlayerData();
  319. }
  320. }
  321. //每天刷新
  322. if (TimeHelper.ClientNow() > AccountFileInfo.Instance.playerData.nextRefence)
  323. {
  324. AccountFileInfo.Instance.playerData.nextRefence =
  325. TimeHelper.GetBaseRefreshTime(TimeHelper.ClientNow());
  326. AccountFileInfo.Instance.playerData.todayUseExpElixrPanelCount = 0;
  327. AccountFileInfo.Instance.playerData.todayDivineSensePoint = 0;
  328. foreach (var playerDataSummonData in AccountFileInfo.Instance.playerData.SummonDatas)
  329. {
  330. playerDataSummonData.onePayCount = 0;
  331. playerDataSummonData.tenPayCount = 0;
  332. playerDataSummonData.oneFreeCount = 0;
  333. playerDataSummonData.nextOneFreeTime = 0;
  334. playerDataSummonData.tenFreeCount = 0;
  335. playerDataSummonData.nextTenFreeTime = 0;
  336. }
  337. AccountFileInfo.Instance.SavePlayerData();
  338. }
  339. foreach (var keyValuePair in AccountFileInfo.Instance.playerData.daoYouGuaiJiDatas)
  340. {
  341. if (!keyValuePair.isLeave && TimeHelper.ClientNow() > keyValuePair.leaveTime)
  342. {
  343. //判断概率给奖励
  344. isUpdate = true;
  345. keyValuePair.isLeave = true;
  346. AccountFileInfo.DaoYouData daoYouData =
  347. AccountFileInfo.Instance.playerData.daoYouDatas.FirstOrDefault(d =>
  348. d.id == keyValuePair.daoyouDataID);
  349. DaoyouModelConfig daoyouModelConfig =
  350. ConfigComponent.Instance.Get<DaoyouModelConfig>(daoYouData.id);
  351. int bl = GetBl(daoYouData, daoyouModelConfig.guajiBuffID[0]);
  352. int randomValue1 = Random.Range(0, 101);
  353. LogTool.Log("道友随机怪率:" + randomValue1 + " 比例:" + bl);
  354. List<AccountFileInfo.ItemData> itemDatas = new List<AccountFileInfo.ItemData>();
  355. if (randomValue1 >= bl)
  356. {
  357. for (var i = 1; i < daoyouModelConfig.guajiBuffID.Length; i++)
  358. {
  359. int count = GetBl(daoYouData, daoyouModelConfig.guajiBuffID[i]);
  360. guajibuff guajibuff =
  361. ConfigComponent.Instance.Get<guajibuff>(daoyouModelConfig.guajiBuffID[i]);
  362. switch (guajibuff.paraValue)
  363. {
  364. case 1:
  365. itemDatas.Add(new AccountFileInfo.ItemData(1003, count));
  366. LogTool.Log("道友获得道具id:" + 1003 + " 数量:" + count);
  367. break;
  368. case 2:
  369. itemDatas.Add(new AccountFileInfo.ItemData(1001, count));
  370. LogTool.Log("道友获得道具id:" + 1001 + " 数量:" + count);
  371. break;
  372. case 3:
  373. itemDatas.Add(new AccountFileInfo.ItemData(1005, count));
  374. LogTool.Log("道友获得道具id:" + 1005 + " 数量:" + count);
  375. break;
  376. case 4:
  377. itemDatas.Add(new AccountFileInfo.ItemData(1006, count));
  378. LogTool.Log("道友获得道具id:" + 1006 + " 数量:" + count);
  379. break;
  380. }
  381. }
  382. }
  383. keyValuePair.items.AddRange(itemDatas);
  384. }
  385. }
  386. if (isUpdate)
  387. {
  388. AccountFileInfo.Instance.SavePlayerData();
  389. EventManager.Instance.Dispatch(CustomEventType.DaoYouCounUpdate, null);
  390. isUpdate = false;
  391. }
  392. }
  393. public async CTask ChangeMap(int mapId,bool isShowUI = true)
  394. {
  395. SmallPlacesConfig currentSmallPlacesConfig = ConfigComponent.Instance.Get<SmallPlacesConfig>(PlayerManager.Instance.CurrentsmallPlaces.id);
  396. SmallPlacesConfig smallPlacesConfig = ConfigComponent.Instance.Get<SmallPlacesConfig>(mapId);
  397. if (smallPlacesConfig.ID == 0)
  398. return;
  399. AccountFileInfo.SmallPlacesData lastSmallPlacesData =
  400. PlayerManager.Instance.GetSmallPlacesData(smallPlacesConfig.ID - 1);
  401. SmallPlacesConfig lastSmallPlacesConfig =
  402. ConfigComponent.Instance.Get<SmallPlacesConfig>(smallPlacesConfig.ID - 1);
  403. if (smallPlacesConfig.ID > 1 && (lastSmallPlacesData == null ||
  404. lastSmallPlacesData.completionEventCount <
  405. lastSmallPlacesConfig.CompletionEventCount))
  406. {
  407. return;
  408. }
  409. if (lastSmallPlacesConfig.UnlockEnvetid != 0)
  410. {
  411. AccountFileInfo.EventList eventList =
  412. AccountFileInfo.Instance.playerData.completeEvents.FirstOrDefault(ce =>
  413. ce.eventID == lastSmallPlacesConfig.UnlockEnvetid);
  414. if (eventList == null || !eventList.isCompleted)
  415. {
  416. return;
  417. }
  418. }
  419. UIManager.Instance.HindCurrAllShowPanel();
  420. _cTask = CTask.Create();
  421. AccountFileInfo.SmallPlacesData smallPlacesData =
  422. PlayerManager.Instance.GetSmallPlacesData(smallPlacesConfig.ID);
  423. if (smallPlacesData == null)
  424. {
  425. smallPlacesData = new AccountFileInfo.SmallPlacesData();
  426. smallPlacesData.id = smallPlacesConfig.ID;
  427. AccountFileInfo.Instance.playerData.smallPlacesDatas.Add(smallPlacesData);
  428. }
  429. AccountFileInfo.PlacesData currentPlacesData = PlayerManager.Instance.GetPlacesData(smallPlacesConfig.ID);
  430. if (currentPlacesData == null)
  431. {
  432. currentPlacesData = new AccountFileInfo.PlacesData();
  433. currentPlacesData.id = smallPlacesConfig.PlacesId;
  434. AccountFileInfo.Instance.playerData.placesDatas.Add(currentPlacesData);
  435. }
  436. PlayerManager.Instance.CurrentsmallPlaces = smallPlacesData;
  437. if (currentSmallPlacesConfig.PlacesId == smallPlacesConfig.PlacesId)
  438. {
  439. CombatController.currActiveCombat.ChangeState(CombatController.miniSceneSwitch);
  440. }
  441. else
  442. {
  443. CombatController.currActiveCombat.ChangeState(CombatController.sceneSwitch);
  444. }
  445. await _cTask;
  446. if(isShowUI)
  447. UIManager.Instance.ShowLastHindAllShowPanel();
  448. EventManager.Instance.Dispatch(CustomEventType.ChangeMap, null);
  449. }
  450. public void QianKunDaiAward()
  451. {
  452. foreach (var playerDataQiankundaiData in AccountFileInfo.Instance.playerData.QiankundaiDatas)
  453. {
  454. //重置掉落次数
  455. QiankundaiConfig qiankundaiConfig =
  456. ConfigComponent.Instance.Get<QiankundaiConfig>(playerDataQiankundaiData.id);
  457. if (qiankundaiConfig.dropType != 2 &&
  458. TimeHelper.ClientNow() >= playerDataQiankundaiData.refenceTime)
  459. {
  460. if (qiankundaiConfig.dropPara1 == 1)
  461. {
  462. playerDataQiankundaiData.refenceTime = TimeHelper.ClientNow() + 60 * 60 * 1000;
  463. }
  464. else if (qiankundaiConfig.dropPara1 == 2)
  465. {
  466. playerDataQiankundaiData.refenceTime =
  467. TimeHelper.GetBaseRefreshTime(TimeHelper.ClientNow());
  468. }
  469. else if (qiankundaiConfig.dropPara1 == 3)
  470. {
  471. }
  472. playerDataQiankundaiData.dropCount = 0;
  473. }
  474. if (myHero.powerUpConfig.ID >= qiankundaiConfig.dropLevel[0] &&
  475. myHero.powerUpConfig.ID <= qiankundaiConfig.dropLevel[1])
  476. {
  477. if (playerDataQiankundaiData.dropCount < qiankundaiConfig.dropPara2 ||
  478. qiankundaiConfig.dropPara2 == -1)
  479. {
  480. playerDataQiankundaiData.dropTime++;
  481. if (playerDataQiankundaiData.dropTime >= qiankundaiConfig.dropTypePara)
  482. {
  483. //发放奖励
  484. for (var i = 0; i < qiankundaiConfig.ChoukaID.Length; i++)
  485. {
  486. List<ItemInfo> itemInfos = DropManager.Instance.Drop(qiankundaiConfig.ChoukaID[i],
  487. qiankundaiConfig.DropCount[i]);
  488. foreach (var itemInfo in itemInfos)
  489. {
  490. AccountFileInfo.ItemData itemData =
  491. AccountFileInfo.Instance.playerData.QiankundaiItemDatas.FirstOrDefault(i =>
  492. i.itemId == itemInfo.itemID);
  493. if (itemData != null)
  494. {
  495. itemData.itemCount += itemInfo.count.Value;
  496. }
  497. else
  498. {
  499. itemData = itemInfo.ToItemData();
  500. AccountFileInfo.Instance.playerData.QiankundaiItemDatas.Add(itemData);
  501. }
  502. }
  503. }
  504. playerDataQiankundaiData.dropCount = 0;
  505. playerDataQiankundaiData.dropTime = 0;
  506. }
  507. }
  508. }
  509. // AccountFileInfo.Instance.SavePlayerData();
  510. }
  511. }
  512. public void CalculateOfflineRewards()
  513. {
  514. // return;
  515. if (AccountFileInfo.Instance.playerData.QiankundaiDropTimer <=
  516. PlayerManager.Instance.gameConstantConfig.qiankundaiMaxTime &&
  517. AccountFileInfo.Instance.playerData.ExitTime > 0)
  518. {
  519. int miao = (int)((TimeHelper.ClientNow() - AccountFileInfo.Instance.playerData.ExitTime) / 1000);
  520. miao = AccountFileInfo.Instance.playerData.QiankundaiDropTimer + miao >=
  521. PlayerManager.Instance.gameConstantConfig.qiankundaiMaxTime
  522. ? PlayerManager.Instance.gameConstantConfig.qiankundaiMaxTime - miao
  523. : miao;
  524. AccountFileInfo.Instance.playerData.QiankundaiDropTimer += miao;
  525. for (int i = 0; i < miao; i++)
  526. {
  527. QianKunDaiAward();
  528. }
  529. }
  530. AccountFileInfo.Instance.playerData.ExitTime = 0;
  531. AccountFileInfo.Instance.SavePlayerData();
  532. }
  533. public void AddTestHeroInfo(TestCombatHeroConfig.TestHeroInfoConfig testHeroInfoConfig)
  534. {
  535. isTest = true;
  536. GongFaControl.allSkill.Clear();
  537. SkillConfig[] allSkillConfig = ConfigComponent.Instance.GetAll<SkillConfig>();
  538. for (int i = 0; i < allSkillConfig.Length; i++)
  539. {
  540. SkillConfig skillConfig = allSkillConfig[i];
  541. if (skillConfig.level == testHeroInfoConfig.skillStart)
  542. {
  543. SkillInfo skillInfo = new SkillInfo(skillConfig.ID, testHeroInfoConfig.skillLevel);
  544. skillInfo.index = -1;
  545. GongFaControl.AddSkillInfo(skillInfo);
  546. }
  547. }
  548. AccountFileInfo.HeroData heroData = new AccountFileInfo.HeroData();
  549. heroData.heroModelId = testHeroInfoConfig.heroID;
  550. heroData.heroPowerId = testHeroInfoConfig.level;
  551. myHero = new HeroInfo();
  552. myHero.InitHero(heroData);
  553. if (testHeroInfoConfig.skill.Count > 0)
  554. {
  555. GongFaControl.allSkill.Clear();
  556. for (int i = 0; i < testHeroInfoConfig.skill.Count; i++)
  557. {
  558. SkillInfo skillInfo = new SkillInfo(testHeroInfoConfig.skill[i], testHeroInfoConfig.skillLevel,
  559. testHeroInfoConfig.skillStart);
  560. skillInfo.index = i;
  561. GongFaControl.AddSkillInfo(skillInfo);
  562. }
  563. }
  564. else
  565. {
  566. SkillInfo[] skillInfos = GongFaControl.allUseSkill;
  567. for (int i = 0; i < skillInfos.Length; i++)
  568. {
  569. if (skillInfos[i] != null)
  570. {
  571. SkillInfo skillInfo = new SkillInfo(skillInfos[i].skillConfig.IDGroup,
  572. testHeroInfoConfig.skillLevel,
  573. testHeroInfoConfig.skillStart);
  574. skillInfo.index = i;
  575. GongFaControl.allUseSkill[i] = skillInfo;
  576. }
  577. }
  578. }
  579. if (testHeroInfoConfig.magicWeaponId.Count > 0)
  580. {
  581. int fbLevel = ((testHeroInfoConfig.level - 1) / 10) + 1;
  582. if (fbLevel <= 0)
  583. {
  584. fbLevel = 1;
  585. }
  586. for (int i = 0; i < testHeroInfoConfig.magicWeaponId.Count; i++)
  587. {
  588. FaBaoInfo faBaoInfo = new FaBaoInfo(testHeroInfoConfig.magicWeaponId[i], fbLevel);
  589. faBaoInfo.FaBaoData.useIndex = i;
  590. FaBaoControl.FightFaBao[i] = faBaoInfo;
  591. FaBaoControl.AddFaBao(faBaoInfo);
  592. }
  593. }
  594. float[] qiangDu = new float[] { 0, 35.7f, 98f, 138.7f, 199.3f, 216f };
  595. int qiangDuLevelId = Mathf.CeilToInt(testHeroInfoConfig.level / 5f);
  596. HeroQiangDuAddConfig heroQiangDuAddConfig = ConfigComponent.Instance.Get<HeroQiangDuAddConfig>(qiangDuLevelId);
  597. int index = Mathf.RoundToInt(heroQiangDuAddConfig.qiangDuZhi) - 1;
  598. myHero.hp = (EncryptionLong)(myHero.hp.Value * (qiangDu[index] / 100f + 1));
  599. myHero.attack = (EncryptionLong)(myHero.attack.Value * (qiangDu[index] / 100f + 1));
  600. myHero.defense = (EncryptionLong)(myHero.defense.Value * (qiangDu[index] / 100f + 1));
  601. // for (int i = 0; i < 4; i++)
  602. // {
  603. // FaBaoControl.FightFaBao[i] = FaBaoControl.myAllFaBao[i];
  604. // }
  605. myHero.hp += testHeroInfoConfig.hp;
  606. myHero.attack += testHeroInfoConfig.att;
  607. myHero.defense += testHeroInfoConfig.def;
  608. myHero.Metal += testHeroInfoConfig.jing;
  609. myHero.Wood += testHeroInfoConfig.mu;
  610. myHero.Water += testHeroInfoConfig.shui;
  611. myHero.Fire += testHeroInfoConfig.huo;
  612. myHero.Earth += testHeroInfoConfig.tu;
  613. myHero.TaoismSkillId = 601011;
  614. myHero.MagicWeaponID.Clear();
  615. myHero.MagicWeaponID.AddRange(FaBaoControl.FightFaBao);
  616. // for (int i = 0; i < FaBaoControl.FightFaBao.Length; i++)
  617. // {
  618. // FaBaoInfo faBaoInfo = FaBaoControl.FightFaBao[i];
  619. // if (faBaoInfo != null)
  620. // {
  621. // foreach (var VARIABLE in faBaoInfo.attriButedIC)
  622. // {
  623. // switch (VARIABLE.Key)
  624. // {
  625. // case 1:
  626. // myHero.hp += VARIABLE.Value;
  627. // break;
  628. // case 2:
  629. // myHero.defense += VARIABLE.Value;
  630. // break;
  631. // case 3:
  632. // myHero.attack += VARIABLE.Value;
  633. // break;
  634. // }
  635. // }
  636. // }
  637. // }
  638. }
  639. /// <summary>
  640. /// 保存英雄数据
  641. /// </summary>
  642. /// <param name="heroInfo"></param>
  643. public void SaveHeroData(HeroInfo heroInfo)
  644. {
  645. AccountFileInfo.Instance.playerData.heroData = heroInfo.heroData;
  646. AccountFileInfo.Instance.SavePlayerData();
  647. }
  648. /// <summary>
  649. /// 时间(秒)转换位小时分钟秒
  650. /// </summary>
  651. /// <param name="miao"></param>
  652. /// <returns></returns>
  653. public static string TimeToHSM(long miao)
  654. {
  655. long fen = miao / 60;
  656. miao = miao % 60;
  657. long xiaoShi = fen / 60;
  658. long tian = xiaoShi / 24;
  659. xiaoShi = xiaoShi % 24;
  660. fen = fen % 60;
  661. if (tian > 0)
  662. {
  663. return $"{tian}天{xiaoShi}小時";
  664. }
  665. else
  666. {
  667. if (xiaoShi <= 0 && fen <= 59)
  668. {
  669. return $"{fen}分{miao}秒";
  670. }
  671. else
  672. {
  673. return $"{xiaoShi}小時{fen}分";
  674. }
  675. }
  676. }
  677. }