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.MagicWeaponID = MagicWeaponID.ToList();
  33. heroInfo.unLockSkills = unLockSkills.ToList();
  34. heroInfo.InitHero(heroData);
  35. return heroInfo;
  36. }
  37. public void InitHero(AccountFileInfo.HeroData heroData)
  38. {
  39. this.heroData = heroData;
  40. InitHero(heroData.heroModelId, heroData.heroPowerId);
  41. }
  42. public void InitHero(int modelID, int powerID)
  43. {
  44. this.modelID = modelID;
  45. SetDataConfig(modelID,
  46. powerID);
  47. ComputeHeroInfo();
  48. //CalBasicAttribute();
  49. }
  50. public HeroInfo Upgrade()
  51. {
  52. int currentMiao = (int)((TimeHelper.ClientNow() - PlayerManager.Instance.myHero.heroData.upTime) / 1000);
  53. int allexp = currentMiao * PlayerManager.Instance.myHero.powerUpConfig.AutoXiuwei;
  54. heroData.exp += allexp;
  55. heroData.exp -= powerUpConfig.levelUpExp;
  56. heroData.upTime = TimeHelper.ClientNow();
  57. heroData.isCombat = false;
  58. heroData.heroPowerId++;
  59. InitHero(heroData);
  60. PlayerManager.Instance.SaveHeroData(this);
  61. EventManager.Instance.Dispatch(CustomEventType.JingJieUpgrade, null);
  62. return this;
  63. }
  64. public void GetDaoLvBl()
  65. {
  66. daolvBlMap.Clear();
  67. foreach (var i in heroData?.ImmortalBond)
  68. {
  69. DaoyouModelConfig daoyouModelConfig = ConfigComponent.Instance.Get<DaoyouModelConfig>(i);
  70. foreach (var i1 in daoyouModelConfig.daolvSkillID)
  71. {
  72. daolvSkill daolvSkill = ConfigComponent.Instance.Get<daolvSkill>(i1);
  73. //唯一只加一次
  74. if (daolvSkill.type == 1)
  75. {
  76. if (!daolvBlMap.ContainsKey(i1))
  77. {
  78. daolvBlMap.Add(i1, daolvSkill.para[0]);
  79. }
  80. }
  81. else
  82. {
  83. if (!daolvBlMap.ContainsKey(i1))
  84. {
  85. daolvBlMap.Add(i1, daolvSkill.para[0]);
  86. }
  87. else
  88. {
  89. daolvBlMap[i1] += daolvSkill.para[0];
  90. }
  91. }
  92. }
  93. }
  94. }
  95. public void ComputeHeroInfo()
  96. {
  97. attributeBlValue.Clear();
  98. CalAttribute();
  99. GetDaoLvBl();
  100. if (!PlayerManager.Instance.isTest)
  101. {
  102. List<FaBaoInfo> myAllFaBao = PlayerManager.Instance.FaBaoControl.myAllFaBao;
  103. foreach (var faBaoInfo in myAllFaBao)
  104. {
  105. if (faBaoInfo.SkillConfig.addPropertyType != null)
  106. {
  107. for (int i = 0; i < faBaoInfo.SkillConfig.addPropertyType.Length; i++)
  108. {
  109. int shuxingID = faBaoInfo.SkillConfig.addPropertyType[i];
  110. float shuxingValue = faBaoInfo.SkillConfig.addPropertyValue[i];
  111. ComputeHeroAttributeType(shuxingID, shuxingValue);
  112. }
  113. }
  114. }
  115. ///功法加被动属性
  116. List<SkillInfo> allSkill = PlayerManager.Instance.GongFaControl.allSkill;
  117. for (int j = 0; j < allSkill.Count; j++)
  118. {
  119. SkillInfo skillInfo = allSkill[j];
  120. if (skillInfo.skillConfig.addPropertyType != null)
  121. {
  122. for (int i = 0; i < skillInfo.skillConfig.addPropertyType.Length; i++)
  123. {
  124. int shuxingID = skillInfo.skillConfig.addPropertyType[i];
  125. float shuxingValue = skillInfo.skillConfig.addPropertyValue[i];
  126. ComputeHeroAttributeType(shuxingID, shuxingValue);
  127. }
  128. }
  129. }
  130. foreach (var VARIABLE in attributeBlValue)
  131. {
  132. ComputeHeroAttributeType((int)VARIABLE.Key, VARIABLE.Value);
  133. }
  134. }
  135. //道侣带来的属性加成
  136. foreach (var keyValuePair in daolvBlMap)
  137. {
  138. daolvSkill daolvSkill = ConfigComponent.Instance.Get<daolvSkill>(keyValuePair.Key);
  139. ComputeHeroAttributeType(daolvSkill.AttrID, keyValuePair.Value);
  140. }
  141. if (CombatController.currActiveCombat != null && CombatController.currActiveCombat.playerHeroEntity != null)
  142. {
  143. CombatController.currActiveCombat.playerHeroEntity.CurrCombatHeroInfo = this.Copy();
  144. CombatController.currActiveCombat.playerHeroEntity.MaxCombatHeroInfo = this.Copy();
  145. }
  146. }
  147. private void ComputeHeroAttributeType(int shuxingID, float value)
  148. {
  149. switch ((HeroAttributeType)shuxingID)
  150. {
  151. case HeroAttributeType.HP:
  152. hp.Value += (int)value;
  153. break;
  154. case HeroAttributeType.ATT:
  155. attack.Value += (int)value;
  156. break;
  157. case HeroAttributeType.DEF:
  158. defense.Value += (int)value;
  159. break;
  160. case HeroAttributeType.HP_BL:
  161. hp.Value += (long)(hp.Value * (value / 100f));
  162. break;
  163. case HeroAttributeType.ATT_BL:
  164. attack.Value += (long)(attack.Value * (value / 100f));
  165. break;
  166. case HeroAttributeType.DEF_BL:
  167. defense.Value += (long)(defense.Value * (value / 100f));
  168. break;
  169. case HeroAttributeType.ShengShi_BL:
  170. shenshi.Value += (long)(shenshi.Value * (value / 100f));
  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. }