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