HeroInfo.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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. attributeBlValue.Clear();
  133. Metal = 100;
  134. Wood = 100;
  135. Water = 100;
  136. Fire = 100;
  137. Earth = 100;
  138. CalAttribute();
  139. GetDaoLvBl();
  140. if (!PlayerManager.Instance.isTest)
  141. {
  142. List<FaBaoInfo> myAllFaBao = PlayerManager.Instance.FaBaoControl.myAllFaBao;
  143. foreach (var faBaoInfo in myAllFaBao)
  144. {
  145. if (faBaoInfo.SkillConfig.addPropertyType != null)
  146. {
  147. for (int i = 0; i < faBaoInfo.SkillConfig.addPropertyType.Length; i++)
  148. {
  149. int shuxingID = faBaoInfo.SkillConfig.addPropertyType[i];
  150. float shuxingValue = faBaoInfo.SkillConfig.addPropertyValue[i];
  151. ComputeHeroAttributeType(shuxingID, shuxingValue);
  152. }
  153. }
  154. }
  155. ///功法加被动属性
  156. List<SkillInfo> allSkill = PlayerManager.Instance.GongFaControl.allSkill;
  157. for (int j = 0; j < allSkill.Count; j++)
  158. {
  159. SkillInfo skillInfo = allSkill[j];
  160. if (skillInfo.skillConfig.addPropertyType != null)
  161. {
  162. for (int i = 0; i < skillInfo.skillConfig.addPropertyType.Length; i++)
  163. {
  164. int shuxingID = skillInfo.skillConfig.addPropertyType[i];
  165. float shuxingValue = skillInfo.skillConfig.addPropertyValue[i];
  166. ComputeHeroAttributeType(shuxingID, shuxingValue);
  167. }
  168. }
  169. }
  170. foreach (var VARIABLE in attributeBlValue)
  171. {
  172. ComputeHeroAttributeType((int)VARIABLE.Key, VARIABLE.Value);
  173. }
  174. }
  175. //道侣带来的属性加成
  176. foreach (var keyValuePair in daolvBlMap)
  177. {
  178. daolvSkill daolvSkill = ConfigComponent.Instance.Get<daolvSkill>(keyValuePair.Key);
  179. ComputeHeroAttributeType(daolvSkill.AttrID, keyValuePair.Value);
  180. }
  181. //心境带来的加成
  182. AddSentimentData();
  183. if (CombatController.currActiveCombat != null && CombatController.currActiveCombat.playerHeroEntity != null)
  184. {
  185. CombatController.currActiveCombat.playerHeroEntity.CurrCombatHeroInfo = this.Copy();
  186. CombatController.currActiveCombat.playerHeroEntity.MaxCombatHeroInfo = this.Copy();
  187. }
  188. }
  189. private void AddSentimentData()
  190. {
  191. SentimentEffectConfig[] allSentimentEffectConfigs = ConfigComponent.Instance.GetAll<SentimentEffectConfig>();
  192. List<AccountFileInfo.SentimentData> SentimentDatas = AccountFileInfo.Instance.playerData.SentimentDatas;
  193. for (int i = 0; i < SentimentDatas.Count; i++)
  194. {
  195. AccountFileInfo.SentimentData sentimentData= SentimentDatas[i];
  196. for (int j = 0; j < sentimentData.sentimentProperties.Count; j++)
  197. {
  198. AddSentimentProperty( sentimentData.sentimentProperties[i],allSentimentEffectConfigs);
  199. }
  200. }
  201. }
  202. private void AddSentimentProperty(AccountFileInfo.SentimentProperty sentimentProperty,SentimentEffectConfig[] allSentimentEffectConfigs)
  203. {
  204. SentimentEffectConfig currSentimentEffectConfig = default;
  205. for (int i = 0; i < allSentimentEffectConfigs.Length; i++)
  206. {
  207. SentimentEffectConfig sentimentEffectConfig= allSentimentEffectConfigs[i];
  208. if(sentimentEffectConfig.groupId==sentimentProperty.groupId&& sentimentEffectConfig.level==sentimentProperty.level)
  209. {
  210. currSentimentEffectConfig= sentimentEffectConfig;
  211. }
  212. }
  213. switch (currSentimentEffectConfig.effectType)
  214. {
  215. case 1:
  216. attack += (EncryptionLong)(attack.Value * currSentimentEffectConfig.effectVale[0] * 0.01f);
  217. break;
  218. case 2:
  219. gongFaStrength += currSentimentEffectConfig.effectVale[0];
  220. break;
  221. case 3:
  222. hp += (EncryptionLong)(hp.Value * currSentimentEffectConfig.effectVale[0] * 0.01f);
  223. break;
  224. case 4:
  225. defense += (EncryptionLong)(defense.Value * currSentimentEffectConfig.effectVale[0] * 0.01f);
  226. break;
  227. case 5:
  228. int type = currSentimentEffectConfig.effectVale[0];
  229. switch ((HeroAttributeType)type)
  230. {
  231. case HeroAttributeType.Gold:
  232. Metal += currSentimentEffectConfig.effectVale[1];
  233. break;
  234. case HeroAttributeType.Wood:
  235. Wood += currSentimentEffectConfig.effectVale[1];
  236. break;
  237. case HeroAttributeType.Fire:
  238. Fire += currSentimentEffectConfig.effectVale[1];
  239. break;
  240. case HeroAttributeType.Water:
  241. Water += currSentimentEffectConfig.effectVale[1];
  242. break;
  243. case HeroAttributeType.Earth:
  244. Earth += currSentimentEffectConfig.effectVale[1];
  245. break;
  246. }
  247. break;
  248. case 6:
  249. finallyHarmReduce= currSentimentEffectConfig.effectVale[0];
  250. break;
  251. case 7:
  252. abnormalHarmAdd= currSentimentEffectConfig.effectVale[0];
  253. break;
  254. case 8:
  255. Fire_Proficient= currSentimentEffectConfig.effectVale[0];
  256. break;
  257. case 9:
  258. Wood_Proficient= currSentimentEffectConfig.effectVale[0];
  259. break;
  260. case 10:
  261. Metal_Proficient= currSentimentEffectConfig.effectVale[0];
  262. break;
  263. case 11:
  264. Water_Proficient= currSentimentEffectConfig.effectVale[0];
  265. break;
  266. case 12:
  267. Earth_Proficient= currSentimentEffectConfig.effectVale[0];
  268. break;
  269. case 99:
  270. // Fire_HarmAdd= currSentimentEffectConfig.effectVale[0];
  271. break;
  272. }
  273. }
  274. private void ComputeHeroAttributeType(int shuxingID, float value)
  275. {
  276. switch ((HeroAttributeType)shuxingID)
  277. {
  278. case HeroAttributeType.HP:
  279. hp.Value += (int)value;
  280. break;
  281. case HeroAttributeType.ATT:
  282. attack.Value += (int)value;
  283. break;
  284. case HeroAttributeType.DEF:
  285. defense.Value += (int)value;
  286. break;
  287. case HeroAttributeType.HP_BL:
  288. hp.Value += (long)(hp.Value * (value / 100f));
  289. break;
  290. case HeroAttributeType.ATT_BL:
  291. attack.Value += (long)(attack.Value * (value / 100f));
  292. break;
  293. case HeroAttributeType.DEF_BL:
  294. defense.Value += (long)(defense.Value * (value / 100f));
  295. break;
  296. case HeroAttributeType.ShengShi_BL:
  297. shenshi.Value += (long)(shenshi.Value * (value / 100f));
  298. break;
  299. case HeroAttributeType.Gold:
  300. Metal += value;
  301. break;
  302. case HeroAttributeType.Wood:
  303. Wood += value;
  304. break;
  305. case HeroAttributeType.Fire:
  306. Fire += value;
  307. break;
  308. case HeroAttributeType.Water:
  309. Water += value;
  310. break;
  311. case HeroAttributeType.Earth:
  312. Earth += value;
  313. break;
  314. case HeroAttributeType.Shields:
  315. Shield.Value += (int)value;
  316. break;
  317. default:
  318. if (attributeBlValue.TryGetValue((HeroAttributeType)shuxingID, out var value1)
  319. )
  320. {
  321. attributeBlValue[(HeroAttributeType)shuxingID] = value1 + value;
  322. }
  323. else
  324. {
  325. attributeBlValue.Add((HeroAttributeType)shuxingID, value);
  326. }
  327. break;
  328. }
  329. }
  330. }
  331. }