HeroInfo.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using Common.Utility.CombatEvent;
  4. using Excel2Json;
  5. using Fort23.Core;
  6. using Fort23.UTool;
  7. using GameLogic.Combat.CombatTool;
  8. using Utility;
  9. namespace GameLogic.Hero
  10. {
  11. public class HeroInfo : CombatHeroInfo
  12. {
  13. public AccountFileInfo.HeroData heroData;
  14. private string _iconZhiYe;
  15. private Map<HeroAttributeType, float> attributeBlValue = new Map<HeroAttributeType, float>();
  16. public Map<int, float> daolvBlMap = new Map<int, float>();
  17. // public List<int> ImmortalBond = new List<int>();
  18. public HeroInfo()
  19. {
  20. }
  21. public HeroInfo CopyHero()
  22. {
  23. AccountFileInfo.HeroData heroDataCopy = new AccountFileInfo.HeroData();
  24. heroDataCopy.heroModelId = heroData.heroModelId;
  25. heroDataCopy.heroPowerId = heroData.heroPowerId ;
  26. heroDataCopy.exp = heroData.exp;
  27. heroDataCopy.upTime = heroData.upTime;
  28. heroDataCopy.isCombat = heroData.isCombat;
  29. heroDataCopy.TaoismSkillId = heroData.TaoismSkillId;
  30. heroDataCopy.ImmortalBond = heroData.ImmortalBond.ToList();
  31. HeroInfo heroInfo = new HeroInfo();
  32. heroInfo.InitHero(heroData);
  33. return heroInfo;
  34. }
  35. public void InitHero(AccountFileInfo.HeroData heroData)
  36. {
  37. this.heroData = heroData;
  38. InitHero(heroData.heroModelId, heroData.heroPowerId);
  39. }
  40. public void InitHero(int modelID, int powerID)
  41. {
  42. this.modelID = modelID;
  43. SetDataConfig(modelID,
  44. powerID);
  45. ComputeHeroInfo();
  46. CalBasicAttribute();
  47. }
  48. public HeroInfo Upgrade()
  49. {
  50. int currentMiao = (int)((TimeHelper.ClientNow() - PlayerManager.Instance.myHero.heroData.upTime) / 1000);
  51. int allexp = currentMiao * PlayerManager.Instance.myHero.powerUpConfig.AutoXiuwei;
  52. heroData.exp += allexp;
  53. heroData.exp -= powerUpConfig.levelUpExp;
  54. heroData.upTime = TimeHelper.ClientNow();
  55. heroData.isCombat = false;
  56. heroData.heroPowerId++;
  57. InitHero(heroData);
  58. PlayerManager.Instance.SaveHeroData(this);
  59. EventManager.Instance.Dispatch(CustomEventType.JingJieUpgrade, null);
  60. return this;
  61. }
  62. public void GetDaoLvBl()
  63. {
  64. daolvBlMap.Clear();
  65. foreach (var i in heroData?.ImmortalBond)
  66. {
  67. DaoyouModelConfig daoyouModelConfig = ConfigComponent.Instance.Get<DaoyouModelConfig>(i);
  68. foreach (var i1 in daoyouModelConfig.daolvSkillID)
  69. {
  70. daolvSkill daolvSkill = ConfigComponent.Instance.Get<daolvSkill>(i1);
  71. //唯一只加一次
  72. if (daolvSkill.type == 1)
  73. {
  74. if (!daolvBlMap.ContainsKey(i1))
  75. {
  76. daolvBlMap.Add(i1, daolvSkill.para[0]);
  77. }
  78. }
  79. else
  80. {
  81. if (!daolvBlMap.ContainsKey(i1))
  82. {
  83. daolvBlMap.Add(i1, daolvSkill.para[0]);
  84. }
  85. else
  86. {
  87. daolvBlMap[i1] += daolvSkill.para[0];
  88. }
  89. }
  90. }
  91. }
  92. }
  93. public void ComputeHeroInfo()
  94. {
  95. attributeBlValue.Clear();
  96. CalAttribute();
  97. GetDaoLvBl();
  98. if (!PlayerManager.Instance.isTest)
  99. {
  100. List<FaBaoInfo> myAllFaBao = PlayerManager.Instance.FaBaoControl.myAllFaBao;
  101. foreach (var faBaoInfo in myAllFaBao)
  102. {
  103. if (faBaoInfo.SkillConfig.addPropertyType != null)
  104. {
  105. for (int i = 0; i < faBaoInfo.SkillConfig.addPropertyType.Length; i++)
  106. {
  107. int shuxingID = faBaoInfo.SkillConfig.addPropertyType[i];
  108. float shuxingValue = faBaoInfo.SkillConfig.addPropertyValue[i];
  109. ComputeHeroAttributeType(shuxingID, shuxingValue);
  110. }
  111. }
  112. }
  113. ///功法加被动属性
  114. List<SkillInfo> allSkill = PlayerManager.Instance.GongFaControl.allSkill;
  115. for (int j = 0; j < allSkill.Count; j++)
  116. {
  117. SkillInfo skillInfo = allSkill[j];
  118. if (skillInfo.skillConfig.addPropertyType != null)
  119. {
  120. for (int i = 0; i < skillInfo.skillConfig.addPropertyType.Length; i++)
  121. {
  122. int shuxingID = skillInfo.skillConfig.addPropertyType[i];
  123. float shuxingValue = skillInfo.skillConfig.addPropertyValue[i];
  124. ComputeHeroAttributeType(shuxingID, shuxingValue);
  125. }
  126. }
  127. }
  128. foreach (var VARIABLE in attributeBlValue)
  129. {
  130. switch (VARIABLE.Key)
  131. {
  132. case HeroAttributeType.HP_BL:
  133. hp.Value += (long)(hp.Value * (VARIABLE.Value / 100f));
  134. break;
  135. case HeroAttributeType.ATT_BL:
  136. attack.Value += (long)(attack.Value * (VARIABLE.Value / 100f));
  137. break;
  138. case HeroAttributeType.DEF_BL:
  139. defense.Value += (long)(defense.Value * (VARIABLE.Value / 100f));
  140. break;
  141. case HeroAttributeType.ShengShi_BL:
  142. shenshi.Value += (long)(shenshi.Value * (VARIABLE.Value / 100f));
  143. break;
  144. }
  145. }
  146. }
  147. //道侣带来的属性加成
  148. foreach (var keyValuePair in daolvBlMap)
  149. {
  150. daolvSkill daolvSkill = ConfigComponent.Instance.Get<daolvSkill>(keyValuePair.Key);
  151. ComputeHeroAttributeType(daolvSkill.AttrID, keyValuePair.Value);
  152. }
  153. if (CombatController.currActiveCombat != null && CombatController.currActiveCombat.playerHeroEntity != null)
  154. {
  155. CombatController.currActiveCombat.playerHeroEntity.CurrCombatHeroInfo = this.Copy();
  156. CombatController.currActiveCombat.playerHeroEntity.MaxCombatHeroInfo = this.Copy();
  157. }
  158. }
  159. private void ComputeHeroAttributeType(int shuxingID, float value)
  160. {
  161. switch ((HeroAttributeType)shuxingID)
  162. {
  163. case HeroAttributeType.HP:
  164. hp.Value += (int)value;
  165. break;
  166. case HeroAttributeType.ATT:
  167. attack.Value += (int)value;
  168. break;
  169. case HeroAttributeType.DEF:
  170. defense.Value += (int)value;
  171. break;
  172. case HeroAttributeType.Gold:
  173. Metal += value;
  174. break;
  175. case HeroAttributeType.Wood:
  176. Wood += value;
  177. break;
  178. case HeroAttributeType.Fire:
  179. Fire += value;
  180. break;
  181. case HeroAttributeType.Water:
  182. Water += value;
  183. break;
  184. case HeroAttributeType.Earth:
  185. Earth += value;
  186. break;
  187. case HeroAttributeType.Shields:
  188. Shield.Value += (int)value;
  189. break;
  190. default:
  191. if (attributeBlValue.TryGetValue((HeroAttributeType)shuxingID, out var value1)
  192. )
  193. {
  194. attributeBlValue[(HeroAttributeType)shuxingID] = value1 + value;
  195. }
  196. else
  197. {
  198. attributeBlValue.Add((HeroAttributeType)shuxingID, value);
  199. }
  200. break;
  201. }
  202. }
  203. }
  204. }