HeroInfo.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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. public HeroInfo()
  26. {
  27. }
  28. public HeroInfo CopyHero()
  29. {
  30. AccountFileInfo.HeroData heroDataCopy = new AccountFileInfo.HeroData();
  31. heroDataCopy.heroModelId = heroData.heroModelId;
  32. heroDataCopy.heroPowerId = heroData.heroPowerId;
  33. heroDataCopy.exp = heroData.exp;
  34. heroDataCopy.upTime = heroData.upTime;
  35. heroDataCopy.isCombat = heroData.isCombat;
  36. heroDataCopy.TaoismSkillId = heroData.TaoismSkillId;
  37. heroDataCopy.ImmortalBond = heroData.ImmortalBond.ToList();
  38. HeroInfo heroInfo = new HeroInfo();
  39. heroInfo.MagicWeaponID = MagicWeaponID.ToList();
  40. heroInfo.unLockSkills = unLockSkills.ToList();
  41. heroInfo.InitHero(heroData);
  42. return heroInfo;
  43. }
  44. public void InitHero(AccountFileInfo.HeroData heroData)
  45. {
  46. this.heroData = heroData;
  47. InitHero(heroData.heroModelId, heroData.heroPowerId);
  48. }
  49. public void InitHero(int modelID, int powerID)
  50. {
  51. this.modelID = modelID;
  52. SetDataConfig(modelID,
  53. powerID);
  54. ComputeHeroInfo();
  55. //CalBasicAttribute();
  56. }
  57. public HeroInfo Upgrade()
  58. {
  59. int currentMiao = (int)((TimeHelper.ClientNow() - PlayerManager.Instance.myHero.heroData.upTime) / 1000);
  60. float allexp = currentMiao * PlayerManager.Instance.myHero.powerUpConfig.AutoXiuwei;
  61. heroData.exp += allexp;
  62. heroData.exp -= powerUpConfig.levelUpExp;
  63. heroData.upTime = TimeHelper.ClientNow();
  64. heroData.isCombat = false;
  65. heroData.heroPowerId++;
  66. InitHero(heroData);
  67. PlayerManager.Instance.SaveHeroData(this);
  68. EventManager.Instance.Dispatch(CustomEventType.JingJieUpgrade, null);
  69. RedDotManager.Instance.AllRedDotUpDate();
  70. return this;
  71. }
  72. public void GetDaoLvBl()
  73. {
  74. daolvBl.Clear();
  75. foreach (var i in heroData?.ImmortalBond)
  76. {
  77. DaoyouModelConfig daoyouModelConfig = ConfigComponent.Instance.Get<DaoyouModelConfig>(i);
  78. foreach (var i1 in daoyouModelConfig.daolvSkillID)
  79. {
  80. daolvSkill daolvSkill = ConfigComponent.Instance.Get<daolvSkill>(i1);
  81. //唯一只加一次
  82. if (daolvSkill.type == 1)
  83. {
  84. if (!daolvBlMap.ContainsKey(i1))
  85. {
  86. daolvBlMap.Add(i1, daolvSkill.para[0]);
  87. }
  88. }
  89. else
  90. {
  91. if (!daolvBlMap.ContainsKey(i1))
  92. {
  93. daolvBlMap.Add(i1, daolvSkill.para[0]);
  94. }
  95. else
  96. {
  97. daolvBlMap[i1] += daolvSkill.para[0];
  98. }
  99. }
  100. DaoLVBiData daoLvBiData;
  101. if (daolvSkill.type == 1)
  102. {
  103. daoLvBiData = daolvBl.FirstOrDefault(d => d.id == i1);
  104. if (daoLvBiData == null)
  105. {
  106. daoLvBiData = new DaoLVBiData();
  107. daoLvBiData.id = i1;
  108. daoLvBiData.value = daolvSkill.para[0];
  109. daolvBl.Add(daoLvBiData);
  110. }
  111. }
  112. else
  113. {
  114. daoLvBiData = daolvBl.FirstOrDefault(d => d.id == i1);
  115. if (daoLvBiData == null)
  116. {
  117. daoLvBiData = new DaoLVBiData();
  118. daoLvBiData.id = i1;
  119. daoLvBiData.value = daolvSkill.para[0];
  120. daolvBl.Add(daoLvBiData);
  121. }
  122. else
  123. {
  124. daoLvBiData.value += daolvSkill.para[0];
  125. }
  126. if (!daolvBlMap.ContainsKey(i1))
  127. {
  128. daolvBlMap.Add(i1, daolvSkill.para[0]);
  129. }
  130. else
  131. {
  132. daolvBlMap[i1] += daolvSkill.para[0];
  133. }
  134. }
  135. }
  136. }
  137. }
  138. public void ComputeHeroInfo()
  139. {
  140. attributeValue.Clear();
  141. attributeBlValue.Clear();
  142. Metal = 100;
  143. Wood = 100;
  144. Water = 100;
  145. Fire = 100;
  146. Earth = 100;
  147. CalAttribute();
  148. GetDaoLvBl();
  149. if (!PlayerManager.Instance.isTest)
  150. {
  151. List<FaBaoInfo> myAllFaBao = PlayerManager.Instance.FaBaoControl.myAllFaBao;
  152. foreach (var faBaoInfo in myAllFaBao)
  153. {
  154. if (faBaoInfo.SkillConfig.addPropertyType != null)
  155. {
  156. for (int i = 0; i < faBaoInfo.SkillConfig.addPropertyType.Length; i++)
  157. {
  158. int shuxingID = faBaoInfo.SkillConfig.addPropertyType[i];
  159. float shuxingValue = faBaoInfo.SkillConfig.addPropertyValue[i];
  160. ComputeHeroAttributeType(shuxingID, shuxingValue);
  161. }
  162. }
  163. }
  164. ///功法加被动属性
  165. List<SkillInfo> allSkill = PlayerManager.Instance.GongFaControl.allSkill;
  166. for (int j = 0; j < allSkill.Count; j++)
  167. {
  168. SkillInfo skillInfo = allSkill[j];
  169. if (skillInfo.skillConfig.addPropertyType != null)
  170. {
  171. for (int i = 0; i < skillInfo.skillConfig.addPropertyType.Length; i++)
  172. {
  173. int shuxingID = skillInfo.skillConfig.addPropertyType[i];
  174. float shuxingValue = skillInfo.skillConfig.addPropertyValue[i];
  175. ComputeHeroAttributeType(shuxingID, shuxingValue);
  176. }
  177. }
  178. }
  179. foreach (var VARIABLE in attributeBlValue)
  180. {
  181. ComputeHeroAttributeType((int)VARIABLE.Key, VARIABLE.Value);
  182. }
  183. }
  184. //道侣带来的属性加成
  185. foreach (var keyValuePair in daolvBlMap)
  186. {
  187. daolvSkill daolvSkill = ConfigComponent.Instance.Get<daolvSkill>(keyValuePair.Key);
  188. ComputeHeroAttributeType(daolvSkill.AttrID, keyValuePair.Value);
  189. }
  190. //心境带来的加成
  191. AddSentimentData();
  192. if (CombatController.currActiveCombat != null && CombatController.currActiveCombat.playerHeroEntity != null)
  193. {
  194. CombatController.currActiveCombat.playerHeroEntity.CurrCombatHeroInfo = this.Copy();
  195. CombatController.currActiveCombat.playerHeroEntity.MaxCombatHeroInfo = this.Copy();
  196. }
  197. AddAttributeValue();
  198. }
  199. private void AddSentimentData()
  200. {
  201. SentimentEffectConfig[] allSentimentEffectConfigs =
  202. ConfigComponent.Instance.GetAll<SentimentEffectConfig>();
  203. List<AccountFileInfo.SentimentData> SentimentDatas = AccountFileInfo.Instance.playerData.SentimentDatas;
  204. for (int i = 0; i < SentimentDatas.Count; i++)
  205. {
  206. AccountFileInfo.SentimentData sentimentData = SentimentDatas[i];
  207. for (int j = 0; j < sentimentData.sentimentProperties.Count; j++)
  208. {
  209. AddSentimentProperty(sentimentData.sentimentProperties[i], allSentimentEffectConfigs);
  210. }
  211. }
  212. }
  213. private void AddSentimentProperty(AccountFileInfo.SentimentProperty sentimentProperty,
  214. SentimentEffectConfig[] allSentimentEffectConfigs)
  215. {
  216. SentimentEffectConfig currSentimentEffectConfig = default;
  217. for (int i = 0; i < allSentimentEffectConfigs.Length; i++)
  218. {
  219. SentimentEffectConfig sentimentEffectConfig = allSentimentEffectConfigs[i];
  220. if (sentimentEffectConfig.groupId == sentimentProperty.groupId &&
  221. sentimentEffectConfig.level == sentimentProperty.level)
  222. {
  223. currSentimentEffectConfig = sentimentEffectConfig;
  224. }
  225. }
  226. switch (currSentimentEffectConfig.effectType)
  227. {
  228. case 1:
  229. ComputeHeroAttributeType((int)HeroAttributeType.ATT_BL, currSentimentEffectConfig.effectVale[0]);
  230. // attack += (EncryptionLong)(attack.Value * currSentimentEffectConfig.effectVale[0] * 0.01f);
  231. break;
  232. case 2:
  233. gongFaStrength += currSentimentEffectConfig.effectVale[0];
  234. break;
  235. case 3:
  236. ComputeHeroAttributeType((int)HeroAttributeType.HP_BL, currSentimentEffectConfig.effectVale[0]);
  237. // hp += (EncryptionLong)(hp.Value * currSentimentEffectConfig.effectVale[0] * 0.01f);
  238. break;
  239. case 4:
  240. ComputeHeroAttributeType((int)HeroAttributeType.DEF_BL, currSentimentEffectConfig.effectVale[0]);
  241. // defense += (EncryptionLong)(defense.Value * currSentimentEffectConfig.effectVale[0] * 0.01f);
  242. break;
  243. case 5:
  244. int type = currSentimentEffectConfig.effectVale[0];
  245. switch ((HeroAttributeType)type)
  246. {
  247. case HeroAttributeType.Gold:
  248. Metal += currSentimentEffectConfig.effectVale[1];
  249. break;
  250. case HeroAttributeType.Wood:
  251. Wood += currSentimentEffectConfig.effectVale[1];
  252. break;
  253. case HeroAttributeType.Fire:
  254. Fire += currSentimentEffectConfig.effectVale[1];
  255. break;
  256. case HeroAttributeType.Water:
  257. Water += currSentimentEffectConfig.effectVale[1];
  258. break;
  259. case HeroAttributeType.Earth:
  260. Earth += currSentimentEffectConfig.effectVale[1];
  261. break;
  262. }
  263. break;
  264. case 6:
  265. finallyHarmReduce = currSentimentEffectConfig.effectVale[0];
  266. break;
  267. case 7:
  268. abnormalHarmAdd = currSentimentEffectConfig.effectVale[0];
  269. break;
  270. case 8:
  271. Fire_Proficient = currSentimentEffectConfig.effectVale[0];
  272. break;
  273. case 9:
  274. Wood_Proficient = currSentimentEffectConfig.effectVale[0];
  275. break;
  276. case 10:
  277. Metal_Proficient = currSentimentEffectConfig.effectVale[0];
  278. break;
  279. case 11:
  280. Water_Proficient = currSentimentEffectConfig.effectVale[0];
  281. break;
  282. case 12:
  283. Earth_Proficient = currSentimentEffectConfig.effectVale[0];
  284. break;
  285. case 99:
  286. // Fire_HarmAdd= currSentimentEffectConfig.effectVale[0];
  287. break;
  288. }
  289. }
  290. }
  291. }