PlayerManager.cs 31 KB

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