HeroInfo.cs 12 KB

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