HeroInfo.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using Common.Utility.CombatEvent;
  4. using Core.Utility;
  5. using Excel2Json;
  6. using Fort23.Core;
  7. using Fort23.UTool;
  8. using GameLogic.Combat.CombatTool;
  9. using Utility;
  10. namespace GameLogic.Hero
  11. {
  12. public class DaoLVBiData
  13. {
  14. public int id;
  15. public float value;
  16. }
  17. public class HeroInfo : CombatHeroInfo
  18. {
  19. public AccountFileInfo.HeroData heroData;
  20. private string _iconZhiYe;
  21. private Map<HeroAttributeType, float> attributeBlValue = new Map<HeroAttributeType, float>();
  22. public Map<int, float> daolvBlMap = new Map<int, float>();
  23. public List<DaoLVBiData> daolvBl = new List<DaoLVBiData>();
  24. // public List<int> ImmortalBond = new List<int>();
  25. private Map<HeroAttributeType, float> attributeValue = new Map<HeroAttributeType, float>();
  26. public HeroInfo()
  27. {
  28. }
  29. public HeroInfo CopyHero()
  30. {
  31. AccountFileInfo.HeroData heroDataCopy = new AccountFileInfo.HeroData();
  32. heroDataCopy.heroModelId = heroData.heroModelId;
  33. heroDataCopy.heroPowerId = heroData.heroPowerId;
  34. heroDataCopy.exp = heroData.exp;
  35. heroDataCopy.upTime = heroData.upTime;
  36. heroDataCopy.isCombat = heroData.isCombat;
  37. heroDataCopy.TaoismSkillId = heroData.TaoismSkillId;
  38. heroDataCopy.ImmortalBond = heroData.ImmortalBond.ToList();
  39. HeroInfo heroInfo = new HeroInfo();
  40. heroInfo.MagicWeaponID = MagicWeaponID.ToList();
  41. heroInfo.unLockSkills = unLockSkills.ToList();
  42. heroInfo.InitHero(heroData);
  43. return heroInfo;
  44. }
  45. public void InitHero(AccountFileInfo.HeroData heroData)
  46. {
  47. this.heroData = heroData;
  48. InitHero(heroData.heroModelId, heroData.heroPowerId);
  49. }
  50. public void InitHero(int modelID, int powerID)
  51. {
  52. this.modelID = modelID;
  53. SetDataConfig(modelID,
  54. powerID);
  55. ComputeHeroInfo();
  56. //CalBasicAttribute();
  57. }
  58. public HeroInfo Upgrade()
  59. {
  60. int currentMiao = (int)((TimeHelper.ClientNow() - PlayerManager.Instance.myHero.heroData.upTime) / 1000);
  61. float allexp = currentMiao * PlayerManager.Instance.myHero.powerUpConfig.AutoXiuwei;
  62. heroData.exp += allexp;
  63. heroData.exp -= powerUpConfig.levelUpExp;
  64. heroData.upTime = TimeHelper.ClientNow();
  65. heroData.isCombat = false;
  66. heroData.heroPowerId++;
  67. InitHero(heroData);
  68. PlayerManager.Instance.SaveHeroData(this);
  69. EventManager.Instance.Dispatch(CustomEventType.JingJieUpgrade, null);
  70. RedDotManager.Instance.AllRedDotUpDate();
  71. return this;
  72. }
  73. public void GetDaoLvBl()
  74. {
  75. daolvBl.Clear();
  76. foreach (var i in heroData?.ImmortalBond)
  77. {
  78. DaoyouModelConfig daoyouModelConfig = ConfigComponent.Instance.Get<DaoyouModelConfig>(i);
  79. foreach (var i1 in daoyouModelConfig.daolvSkillID)
  80. {
  81. daolvSkill daolvSkill = ConfigComponent.Instance.Get<daolvSkill>(i1);
  82. // //唯一只加一次
  83. // if (daolvSkill.type == 1)
  84. // {
  85. // if (!daolvBlMap.ContainsKey(i1))
  86. // {
  87. // daolvBlMap.Add(i1, daolvSkill.para[0]);
  88. // }
  89. // }
  90. // else
  91. // {
  92. // if (!daolvBlMap.ContainsKey(i1))
  93. // {
  94. // daolvBlMap.Add(i1, daolvSkill.para[0]);
  95. // }
  96. // else
  97. // {
  98. // daolvBlMap[i1] += daolvSkill.para[0];
  99. // }
  100. // }
  101. DaoLVBiData daoLvBiData;
  102. if (daolvSkill.type == 1)
  103. {
  104. daoLvBiData = daolvBl.FirstOrDefault(d => d.id == i1);
  105. if (daoLvBiData != null)
  106. {
  107. daoLvBiData = new DaoLVBiData();
  108. daoLvBiData.id = i1;
  109. daoLvBiData.value = daolvSkill.para[0];
  110. daolvBl.Add(daoLvBiData);
  111. }
  112. }
  113. else
  114. {
  115. daoLvBiData = new DaoLVBiData();
  116. daoLvBiData.id = i1;
  117. daoLvBiData.value = daolvSkill.para[0];
  118. daolvBl.Add(daoLvBiData);
  119. // if (!daolvBlMap.ContainsKey(i1))
  120. // {
  121. // daolvBlMap.Add(i1, daolvSkill.para[0]);
  122. // }
  123. // else
  124. // {
  125. // daolvBlMap[i1] += daolvSkill.para[0];
  126. // }
  127. }
  128. }
  129. }
  130. }
  131. public void ComputeHeroInfo()
  132. {
  133. attributeValue.Clear();
  134. attributeBlValue.Clear();
  135. Metal = 100;
  136. Wood = 100;
  137. Water = 100;
  138. Fire = 100;
  139. Earth = 100;
  140. CalAttribute();
  141. GetDaoLvBl();
  142. if (!PlayerManager.Instance.isTest)
  143. {
  144. List<FaBaoInfo> myAllFaBao = PlayerManager.Instance.FaBaoControl.myAllFaBao;
  145. foreach (var faBaoInfo in myAllFaBao)
  146. {
  147. if (faBaoInfo.SkillConfig.addPropertyType != null)
  148. {
  149. for (int i = 0; i < faBaoInfo.SkillConfig.addPropertyType.Length; i++)
  150. {
  151. int shuxingID = faBaoInfo.SkillConfig.addPropertyType[i];
  152. float shuxingValue = faBaoInfo.SkillConfig.addPropertyValue[i];
  153. ComputeHeroAttributeType(shuxingID, shuxingValue);
  154. }
  155. }
  156. }
  157. ///功法加被动属性
  158. List<SkillInfo> allSkill = PlayerManager.Instance.GongFaControl.allSkill;
  159. for (int j = 0; j < allSkill.Count; j++)
  160. {
  161. SkillInfo skillInfo = allSkill[j];
  162. if (skillInfo.skillConfig.addPropertyType != null)
  163. {
  164. for (int i = 0; i < skillInfo.skillConfig.addPropertyType.Length; i++)
  165. {
  166. int shuxingID = skillInfo.skillConfig.addPropertyType[i];
  167. float shuxingValue = skillInfo.skillConfig.addPropertyValue[i];
  168. ComputeHeroAttributeType(shuxingID, shuxingValue);
  169. }
  170. }
  171. }
  172. foreach (var VARIABLE in attributeBlValue)
  173. {
  174. ComputeHeroAttributeType((int)VARIABLE.Key, VARIABLE.Value);
  175. }
  176. }
  177. //道侣带来的属性加成
  178. foreach (var keyValuePair in daolvBlMap)
  179. {
  180. daolvSkill daolvSkill = ConfigComponent.Instance.Get<daolvSkill>(keyValuePair.Key);
  181. ComputeHeroAttributeType(daolvSkill.AttrID, keyValuePair.Value);
  182. }
  183. //心境带来的加成
  184. AddSentimentData();
  185. if (CombatController.currActiveCombat != null && CombatController.currActiveCombat.playerHeroEntity != null)
  186. {
  187. CombatController.currActiveCombat.playerHeroEntity.CurrCombatHeroInfo = this.Copy();
  188. CombatController.currActiveCombat.playerHeroEntity.MaxCombatHeroInfo = this.Copy();
  189. }
  190. AddAttributeValue();
  191. }
  192. private void AddSentimentData()
  193. {
  194. SentimentEffectConfig[] allSentimentEffectConfigs =
  195. ConfigComponent.Instance.GetAll<SentimentEffectConfig>();
  196. List<AccountFileInfo.SentimentData> SentimentDatas = AccountFileInfo.Instance.playerData.SentimentDatas;
  197. for (int i = 0; i < SentimentDatas.Count; i++)
  198. {
  199. AccountFileInfo.SentimentData sentimentData = SentimentDatas[i];
  200. for (int j = 0; j < sentimentData.sentimentProperties.Count; j++)
  201. {
  202. AddSentimentProperty(sentimentData.sentimentProperties[i], allSentimentEffectConfigs);
  203. }
  204. }
  205. }
  206. private void AddSentimentProperty(AccountFileInfo.SentimentProperty sentimentProperty,
  207. SentimentEffectConfig[] allSentimentEffectConfigs)
  208. {
  209. SentimentEffectConfig currSentimentEffectConfig = default;
  210. for (int i = 0; i < allSentimentEffectConfigs.Length; i++)
  211. {
  212. SentimentEffectConfig sentimentEffectConfig = allSentimentEffectConfigs[i];
  213. if (sentimentEffectConfig.groupId == sentimentProperty.groupId &&
  214. sentimentEffectConfig.level == sentimentProperty.level)
  215. {
  216. currSentimentEffectConfig = sentimentEffectConfig;
  217. }
  218. }
  219. switch (currSentimentEffectConfig.effectType)
  220. {
  221. case 1:
  222. attack += (EncryptionLong)(attack.Value * currSentimentEffectConfig.effectVale[0] * 0.01f);
  223. break;
  224. case 2:
  225. gongFaStrength += currSentimentEffectConfig.effectVale[0];
  226. break;
  227. case 3:
  228. hp += (EncryptionLong)(hp.Value * currSentimentEffectConfig.effectVale[0] * 0.01f);
  229. break;
  230. case 4:
  231. defense += (EncryptionLong)(defense.Value * currSentimentEffectConfig.effectVale[0] * 0.01f);
  232. break;
  233. case 5:
  234. int type = currSentimentEffectConfig.effectVale[0];
  235. switch ((HeroAttributeType)type)
  236. {
  237. case HeroAttributeType.Gold:
  238. Metal += currSentimentEffectConfig.effectVale[1];
  239. break;
  240. case HeroAttributeType.Wood:
  241. Wood += currSentimentEffectConfig.effectVale[1];
  242. break;
  243. case HeroAttributeType.Fire:
  244. Fire += currSentimentEffectConfig.effectVale[1];
  245. break;
  246. case HeroAttributeType.Water:
  247. Water += currSentimentEffectConfig.effectVale[1];
  248. break;
  249. case HeroAttributeType.Earth:
  250. Earth += currSentimentEffectConfig.effectVale[1];
  251. break;
  252. }
  253. break;
  254. case 6:
  255. finallyHarmReduce = currSentimentEffectConfig.effectVale[0];
  256. break;
  257. case 7:
  258. abnormalHarmAdd = currSentimentEffectConfig.effectVale[0];
  259. break;
  260. case 8:
  261. Fire_Proficient = currSentimentEffectConfig.effectVale[0];
  262. break;
  263. case 9:
  264. Wood_Proficient = currSentimentEffectConfig.effectVale[0];
  265. break;
  266. case 10:
  267. Metal_Proficient = currSentimentEffectConfig.effectVale[0];
  268. break;
  269. case 11:
  270. Water_Proficient = currSentimentEffectConfig.effectVale[0];
  271. break;
  272. case 12:
  273. Earth_Proficient = currSentimentEffectConfig.effectVale[0];
  274. break;
  275. case 99:
  276. // Fire_HarmAdd= currSentimentEffectConfig.effectVale[0];
  277. break;
  278. }
  279. }
  280. private void AddAttributeValue()
  281. {
  282. for (attributeValue.Begin(); attributeValue.Next();)
  283. {
  284. HeroAttributeType heroAttributeType = attributeValue.Key;
  285. float value = attributeValue.Value;
  286. switch (heroAttributeType)
  287. {
  288. case HeroAttributeType.HP:
  289. hp.Value += (int)value;
  290. break;
  291. case HeroAttributeType.ATT:
  292. attack.Value += (int)value;
  293. break;
  294. case HeroAttributeType.DEF:
  295. defense.Value += (int)value;
  296. break;
  297. case HeroAttributeType.HP_BL:
  298. hp.Value += (long)(hp.Value * (value / 100f));
  299. break;
  300. case HeroAttributeType.ATT_BL:
  301. attack.Value += (long)(attack.Value * (value / 100f));
  302. break;
  303. case HeroAttributeType.DEF_BL:
  304. defense.Value += (long)(defense.Value * (value / 100f));
  305. break;
  306. case HeroAttributeType.ShengShi_BL:
  307. shenshi.Value += (long)(shenshi.Value * (value / 100f));
  308. break;
  309. case HeroAttributeType.Gold:
  310. Metal += value;
  311. break;
  312. case HeroAttributeType.Wood:
  313. Wood += value;
  314. break;
  315. case HeroAttributeType.Fire:
  316. Fire += value;
  317. break;
  318. case HeroAttributeType.Water:
  319. Water += value;
  320. break;
  321. case HeroAttributeType.Earth:
  322. Earth += value;
  323. break;
  324. case HeroAttributeType.Shields:
  325. Shield.Value += (int)value;
  326. break;
  327. // default:
  328. // if (attributeBlValue.TryGetValue((HeroAttributeType)shuxingID, out var value1)
  329. // )
  330. // {
  331. // attributeBlValue[(HeroAttributeType)shuxingID] = value1 + value;
  332. // }
  333. // else
  334. // {
  335. // attributeBlValue.Add((HeroAttributeType)shuxingID, value);
  336. // }
  337. //
  338. // break;
  339. }
  340. }
  341. attributeValue.Clear();
  342. }
  343. private void ComputeHeroAttributeType(int shuxingID, float value)
  344. {
  345. HeroAttributeType heroAttributeType = (HeroAttributeType)shuxingID;
  346. if (attributeValue.TryGetValue(heroAttributeType, out float oldValue))
  347. {
  348. attributeValue[heroAttributeType] = oldValue + value;
  349. }
  350. else
  351. {
  352. attributeValue.Add(heroAttributeType, value);
  353. }
  354. // attributeValue.Add((HeroAttributeType)shuxingID,);
  355. }
  356. }
  357. }