HeroInfo.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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. ULockManager.Instance.RefreshULock();
  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 = daolvBl.FirstOrDefault(d => d.id == i1);
  116. if (daoLvBiData == null)
  117. {
  118. daoLvBiData = new DaoLVBiData();
  119. daoLvBiData.id = i1;
  120. daoLvBiData.value = daolvSkill.para[0];
  121. daolvBl.Add(daoLvBiData);
  122. }
  123. else
  124. {
  125. daoLvBiData.value += daolvSkill.para[0];
  126. }
  127. if (!daolvBlMap.ContainsKey(i1))
  128. {
  129. daolvBlMap.Add(i1, daolvSkill.para[0]);
  130. }
  131. else
  132. {
  133. daolvBlMap[i1] += daolvSkill.para[0];
  134. }
  135. }
  136. }
  137. }
  138. }
  139. public void ComputeHeroInfo()
  140. {
  141. attributeValue.Clear();
  142. attributeBlValue.Clear();
  143. Metal = 100;
  144. Wood = 100;
  145. Water = 100;
  146. Fire = 100;
  147. Earth = 100;
  148. CalAttribute();
  149. GetDaoLvBl();
  150. if (!PlayerManager.Instance.isTest)
  151. {
  152. List<FaBaoInfo> myAllFaBao = PlayerManager.Instance.FaBaoControl.myAllFaBao;
  153. foreach (var faBaoInfo in myAllFaBao)
  154. {
  155. if (faBaoInfo.SkillConfig.addPropertyType != null)
  156. {
  157. for (int i = 0; i < faBaoInfo.SkillConfig.addPropertyType.Length; i++)
  158. {
  159. int shuxingID = faBaoInfo.SkillConfig.addPropertyType[i];
  160. float shuxingValue = faBaoInfo.SkillConfig.addPropertyValue[i];
  161. ComputeHeroAttributeType(shuxingID, shuxingValue);
  162. }
  163. }
  164. }
  165. ///功法加被动属性
  166. List<SkillInfo> allSkill = PlayerManager.Instance.GongFaControl.allSkill;
  167. for (int j = 0; j < allSkill.Count; j++)
  168. {
  169. SkillInfo skillInfo = allSkill[j];
  170. if (skillInfo.skillConfig.addPropertyType != null)
  171. {
  172. for (int i = 0; i < skillInfo.skillConfig.addPropertyType.Length; i++)
  173. {
  174. int shuxingID = skillInfo.skillConfig.addPropertyType[i];
  175. float shuxingValue = skillInfo.skillConfig.addPropertyValue[i];
  176. ComputeHeroAttributeType(shuxingID, shuxingValue);
  177. }
  178. }
  179. }
  180. foreach (var VARIABLE in attributeBlValue)
  181. {
  182. ComputeHeroAttributeType((int)VARIABLE.Key, VARIABLE.Value);
  183. }
  184. }
  185. //道侣带来的属性加成
  186. foreach (var keyValuePair in daolvBlMap)
  187. {
  188. daolvSkill daolvSkill = ConfigComponent.Instance.Get<daolvSkill>(keyValuePair.Key);
  189. ComputeHeroAttributeType(daolvSkill.AttrID, keyValuePair.Value);
  190. }
  191. //心境带来的加成
  192. AddSentimentData();
  193. if (CombatController.currActiveCombat != null && CombatController.currActiveCombat.playerHeroEntity != null)
  194. {
  195. CombatController.currActiveCombat.playerHeroEntity.CurrCombatHeroInfo = this.Copy();
  196. CombatController.currActiveCombat.playerHeroEntity.MaxCombatHeroInfo = this.Copy();
  197. }
  198. AddAttributeValue();
  199. }
  200. private void AddSentimentData()
  201. {
  202. SentimentEffectConfig[] allSentimentEffectConfigs =
  203. ConfigComponent.Instance.GetAll<SentimentEffectConfig>();
  204. List<AccountFileInfo.SentimentData> SentimentDatas = AccountFileInfo.Instance.playerData.SentimentDatas;
  205. for (int i = 0; i < SentimentDatas.Count; i++)
  206. {
  207. AccountFileInfo.SentimentData sentimentData = SentimentDatas[i];
  208. for (int j = 0; j < sentimentData.sentimentProperties.Count; j++)
  209. {
  210. AddSentimentProperty(sentimentData.sentimentProperties[i], allSentimentEffectConfigs);
  211. }
  212. }
  213. }
  214. private void AddSentimentProperty(AccountFileInfo.SentimentProperty sentimentProperty,
  215. SentimentEffectConfig[] allSentimentEffectConfigs)
  216. {
  217. SentimentEffectConfig currSentimentEffectConfig = default;
  218. for (int i = 0; i < allSentimentEffectConfigs.Length; i++)
  219. {
  220. SentimentEffectConfig sentimentEffectConfig = allSentimentEffectConfigs[i];
  221. if (sentimentEffectConfig.groupId == sentimentProperty.groupId &&
  222. sentimentEffectConfig.level == sentimentProperty.level)
  223. {
  224. currSentimentEffectConfig = sentimentEffectConfig;
  225. }
  226. }
  227. switch (currSentimentEffectConfig.effectType)
  228. {
  229. case 1:
  230. ComputeHeroAttributeType((int)HeroAttributeType.ATT_BL, currSentimentEffectConfig.effectVale[0]);
  231. // attack += (EncryptionLong)(attack.Value * currSentimentEffectConfig.effectVale[0] * 0.01f);
  232. break;
  233. case 2:
  234. gongFaStrength += currSentimentEffectConfig.effectVale[0];
  235. break;
  236. case 3:
  237. ComputeHeroAttributeType((int)HeroAttributeType.HP_BL, currSentimentEffectConfig.effectVale[0]);
  238. // hp += (EncryptionLong)(hp.Value * currSentimentEffectConfig.effectVale[0] * 0.01f);
  239. break;
  240. case 4:
  241. ComputeHeroAttributeType((int)HeroAttributeType.DEF_BL, currSentimentEffectConfig.effectVale[0]);
  242. // defense += (EncryptionLong)(defense.Value * currSentimentEffectConfig.effectVale[0] * 0.01f);
  243. break;
  244. case 5:
  245. int type = currSentimentEffectConfig.effectVale[0];
  246. switch ((HeroAttributeType)type)
  247. {
  248. case HeroAttributeType.Gold:
  249. Metal += currSentimentEffectConfig.effectVale[1];
  250. break;
  251. case HeroAttributeType.Wood:
  252. Wood += currSentimentEffectConfig.effectVale[1];
  253. break;
  254. case HeroAttributeType.Fire:
  255. Fire += currSentimentEffectConfig.effectVale[1];
  256. break;
  257. case HeroAttributeType.Water:
  258. Water += currSentimentEffectConfig.effectVale[1];
  259. break;
  260. case HeroAttributeType.Earth:
  261. Earth += currSentimentEffectConfig.effectVale[1];
  262. break;
  263. }
  264. break;
  265. case 6:
  266. finallyHarmReduce = currSentimentEffectConfig.effectVale[0];
  267. break;
  268. case 7:
  269. abnormalHarmAdd = currSentimentEffectConfig.effectVale[0];
  270. break;
  271. case 8:
  272. Fire_Proficient = currSentimentEffectConfig.effectVale[0];
  273. break;
  274. case 9:
  275. Wood_Proficient = currSentimentEffectConfig.effectVale[0];
  276. break;
  277. case 10:
  278. Metal_Proficient = currSentimentEffectConfig.effectVale[0];
  279. break;
  280. case 11:
  281. Water_Proficient = currSentimentEffectConfig.effectVale[0];
  282. break;
  283. case 12:
  284. Earth_Proficient = currSentimentEffectConfig.effectVale[0];
  285. break;
  286. case 99:
  287. // Fire_HarmAdd= currSentimentEffectConfig.effectVale[0];
  288. break;
  289. }
  290. }
  291. }
  292. }