PlayerManager.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  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 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. CombatController.currActiveCombat.ChangeState(CombatController.sceneSwitch);
  434. await _cTask;
  435. UIManager.Instance.ShowLastHindAllShowPanel();
  436. EventManager.Instance.Dispatch(CustomEventType.ChangeMap, null);
  437. }
  438. public void QianKunDaiAward()
  439. {
  440. foreach (var playerDataQiankundaiData in AccountFileInfo.Instance.playerData.QiankundaiDatas)
  441. {
  442. //重置掉落次数
  443. QiankundaiConfig qiankundaiConfig =
  444. ConfigComponent.Instance.Get<QiankundaiConfig>(playerDataQiankundaiData.id);
  445. if (qiankundaiConfig.dropType != 2 &&
  446. TimeHelper.ClientNow() >= playerDataQiankundaiData.refenceTime)
  447. {
  448. if (qiankundaiConfig.dropPara1 == 1)
  449. {
  450. playerDataQiankundaiData.refenceTime = TimeHelper.ClientNow() + 60 * 60 * 1000;
  451. }
  452. else if (qiankundaiConfig.dropPara1 == 2)
  453. {
  454. playerDataQiankundaiData.refenceTime =
  455. TimeHelper.GetBaseRefreshTime(TimeHelper.ClientNow());
  456. }
  457. else if (qiankundaiConfig.dropPara1 == 3)
  458. {
  459. }
  460. playerDataQiankundaiData.dropCount = 0;
  461. }
  462. if (myHero.powerUpConfig.ID >= qiankundaiConfig.dropLevel[0] &&
  463. myHero.powerUpConfig.ID <= qiankundaiConfig.dropLevel[1])
  464. {
  465. if (playerDataQiankundaiData.dropCount < qiankundaiConfig.dropPara2 ||
  466. qiankundaiConfig.dropPara2 == -1)
  467. {
  468. playerDataQiankundaiData.dropTime++;
  469. if (playerDataQiankundaiData.dropTime >= qiankundaiConfig.dropTypePara)
  470. {
  471. //发放奖励
  472. for (var i = 0; i < qiankundaiConfig.ChoukaID.Length; i++)
  473. {
  474. List<ItemInfo> itemInfos = DropManager.Instance.Drop(qiankundaiConfig.ChoukaID[i],
  475. qiankundaiConfig.DropCount[i]);
  476. foreach (var itemInfo in itemInfos)
  477. {
  478. AccountFileInfo.ItemData itemData =
  479. AccountFileInfo.Instance.playerData.QiankundaiItemDatas.FirstOrDefault(i =>
  480. i.itemId == itemInfo.itemID);
  481. if (itemData != null)
  482. {
  483. itemData.itemCount += itemInfo.count.Value;
  484. }
  485. else
  486. {
  487. itemData = itemInfo.ToItemData();
  488. AccountFileInfo.Instance.playerData.QiankundaiItemDatas.Add(itemData);
  489. }
  490. }
  491. }
  492. playerDataQiankundaiData.dropCount = 0;
  493. playerDataQiankundaiData.dropTime = 0;
  494. }
  495. }
  496. }
  497. // AccountFileInfo.Instance.SavePlayerData();
  498. }
  499. }
  500. public void CalculateOfflineRewards()
  501. {
  502. // return;
  503. if (AccountFileInfo.Instance.playerData.QiankundaiDropTimer <=
  504. PlayerManager.Instance.gameConstantConfig.qiankundaiMaxTime &&
  505. AccountFileInfo.Instance.playerData.ExitTime > 0)
  506. {
  507. int miao = (int)((TimeHelper.ClientNow() - AccountFileInfo.Instance.playerData.ExitTime) / 1000);
  508. miao = AccountFileInfo.Instance.playerData.QiankundaiDropTimer + miao >=
  509. PlayerManager.Instance.gameConstantConfig.qiankundaiMaxTime
  510. ? PlayerManager.Instance.gameConstantConfig.qiankundaiMaxTime - miao
  511. : miao;
  512. AccountFileInfo.Instance.playerData.QiankundaiDropTimer += miao;
  513. for (int i = 0; i < miao; i++)
  514. {
  515. QianKunDaiAward();
  516. }
  517. }
  518. AccountFileInfo.Instance.playerData.ExitTime = 0;
  519. AccountFileInfo.Instance.SavePlayerData();
  520. }
  521. public void AddTestHeroInfo(TestCombatHeroConfig.TestHeroInfoConfig testHeroInfoConfig)
  522. {
  523. isTest = true;
  524. GongFaControl.allSkill.Clear();
  525. SkillConfig[] allSkillConfig = ConfigComponent.Instance.GetAll<SkillConfig>();
  526. for (int i = 0; i < allSkillConfig.Length; i++)
  527. {
  528. SkillConfig skillConfig = allSkillConfig[i];
  529. if (skillConfig.level == testHeroInfoConfig.skillStart)
  530. {
  531. SkillInfo skillInfo = new SkillInfo(skillConfig.ID, testHeroInfoConfig.skillLevel);
  532. skillInfo.index = -1;
  533. GongFaControl.AddSkillInfo(skillInfo);
  534. }
  535. }
  536. AccountFileInfo.HeroData heroData = new AccountFileInfo.HeroData();
  537. heroData.heroModelId = testHeroInfoConfig.heroID;
  538. heroData.heroPowerId = testHeroInfoConfig.level;
  539. myHero = new HeroInfo();
  540. myHero.InitHero(heroData);
  541. if (testHeroInfoConfig.skill.Count > 0)
  542. {
  543. GongFaControl.allSkill.Clear();
  544. for (int i = 0; i < testHeroInfoConfig.skill.Count; i++)
  545. {
  546. SkillInfo skillInfo = new SkillInfo(testHeroInfoConfig.skill[i], testHeroInfoConfig.skillLevel,
  547. testHeroInfoConfig.skillStart);
  548. skillInfo.index = i;
  549. GongFaControl.AddSkillInfo(skillInfo);
  550. }
  551. }
  552. else
  553. {
  554. SkillInfo[] skillInfos = GongFaControl.allUseSkill;
  555. for (int i = 0; i < skillInfos.Length; i++)
  556. {
  557. if (skillInfos[i] != null)
  558. {
  559. SkillInfo skillInfo = new SkillInfo(skillInfos[i].skillConfig.IDGroup,
  560. testHeroInfoConfig.skillLevel,
  561. testHeroInfoConfig.skillStart);
  562. skillInfo.index = i;
  563. GongFaControl.allUseSkill[i] = skillInfo;
  564. }
  565. }
  566. }
  567. if (testHeroInfoConfig.magicWeaponId.Count > 0)
  568. {
  569. int fbLevel = ((testHeroInfoConfig.level - 1) / 10) + 1;
  570. if (fbLevel <= 0)
  571. {
  572. fbLevel = 1;
  573. }
  574. for (int i = 0; i < testHeroInfoConfig.magicWeaponId.Count; i++)
  575. {
  576. FaBaoInfo faBaoInfo = new FaBaoInfo(testHeroInfoConfig.magicWeaponId[i], fbLevel);
  577. faBaoInfo.FaBaoData.useIndex = i;
  578. FaBaoControl.FightFaBao[i] = faBaoInfo;
  579. FaBaoControl.AddFaBao(faBaoInfo);
  580. }
  581. }
  582. float[] qiangDu = new float[] { 0, 35.7f, 98f, 138.7f, 199.3f, 216f };
  583. int qiangDuLevelId = Mathf.CeilToInt(testHeroInfoConfig.level / 5f);
  584. HeroQiangDuAddConfig heroQiangDuAddConfig = ConfigComponent.Instance.Get<HeroQiangDuAddConfig>(qiangDuLevelId);
  585. int index = Mathf.RoundToInt(heroQiangDuAddConfig.qiangDuZhi) - 1;
  586. myHero.hp = (EncryptionLong)(myHero.hp.Value * (qiangDu[index] / 100f + 1));
  587. myHero.attack = (EncryptionLong)(myHero.attack.Value * (qiangDu[index] / 100f + 1));
  588. myHero.defense = (EncryptionLong)(myHero.defense.Value * (qiangDu[index] / 100f + 1));
  589. // for (int i = 0; i < 4; i++)
  590. // {
  591. // FaBaoControl.FightFaBao[i] = FaBaoControl.myAllFaBao[i];
  592. // }
  593. myHero.hp += testHeroInfoConfig.hp;
  594. myHero.attack += testHeroInfoConfig.att;
  595. myHero.defense += testHeroInfoConfig.def;
  596. myHero.Metal += testHeroInfoConfig.jing;
  597. myHero.Wood += testHeroInfoConfig.mu;
  598. myHero.Water += testHeroInfoConfig.shui;
  599. myHero.Fire += testHeroInfoConfig.huo;
  600. myHero.Earth += testHeroInfoConfig.tu;
  601. myHero.TaoismSkillId = 601011;
  602. myHero.MagicWeaponID.Clear();
  603. myHero.MagicWeaponID.AddRange(FaBaoControl.FightFaBao);
  604. // for (int i = 0; i < FaBaoControl.FightFaBao.Length; i++)
  605. // {
  606. // FaBaoInfo faBaoInfo = FaBaoControl.FightFaBao[i];
  607. // if (faBaoInfo != null)
  608. // {
  609. // foreach (var VARIABLE in faBaoInfo.attriButedIC)
  610. // {
  611. // switch (VARIABLE.Key)
  612. // {
  613. // case 1:
  614. // myHero.hp += VARIABLE.Value;
  615. // break;
  616. // case 2:
  617. // myHero.defense += VARIABLE.Value;
  618. // break;
  619. // case 3:
  620. // myHero.attack += VARIABLE.Value;
  621. // break;
  622. // }
  623. // }
  624. // }
  625. // }
  626. }
  627. /// <summary>
  628. /// 保存英雄数据
  629. /// </summary>
  630. /// <param name="heroInfo"></param>
  631. public void SaveHeroData(HeroInfo heroInfo)
  632. {
  633. AccountFileInfo.Instance.playerData.heroData = heroInfo.heroData;
  634. AccountFileInfo.Instance.SavePlayerData();
  635. }
  636. /// <summary>
  637. /// 时间(秒)转换位小时分钟秒
  638. /// </summary>
  639. /// <param name="miao"></param>
  640. /// <returns></returns>
  641. public static string TimeToHSM(long miao)
  642. {
  643. long fen = miao / 60;
  644. miao = miao % 60;
  645. long xiaoShi = fen / 60;
  646. long tian = xiaoShi / 24;
  647. xiaoShi = xiaoShi % 24;
  648. fen = fen % 60;
  649. if (tian > 0)
  650. {
  651. return $"{tian}天{xiaoShi}小時";
  652. }
  653. else
  654. {
  655. if (xiaoShi <= 0 && fen <= 59)
  656. {
  657. return $"{fen}分{miao}秒";
  658. }
  659. else
  660. {
  661. return $"{xiaoShi}小時{fen}分";
  662. }
  663. }
  664. }
  665. }