CombatHeroInfo.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using Core.Language;
  4. using Core.Utility;
  5. using Excel2Json;
  6. using Fort23.UTool;
  7. using GameLogic.Combat.CombatTool;
  8. using GameLogic.Hero;
  9. using UnityEngine;
  10. using UnityEngine.Serialization;
  11. using Utility;
  12. [System.Serializable]
  13. public class CombatHeroInfo
  14. {
  15. public enum AttributeType
  16. {
  17. Hp,
  18. Att,
  19. Def,
  20. }
  21. public int modelID;
  22. public EncryptionLong hp = new EncryptionLong();
  23. public EncryptionLong defense = new EncryptionLong();
  24. public EncryptionLong attack = new EncryptionLong();
  25. public EncryptionFloat attSpeed = (EncryptionFloat)2;
  26. public EncryptionInt level;
  27. public EncryptionFloat exp = new EncryptionFloat();
  28. public HeroModelConfig modelConfig;
  29. public HeroPowerUpConfig powerUpConfig;
  30. public MonsterPowerUpConfig MonsterPowerUpConfig;
  31. public HeroPromoteConfig promoteConfig;
  32. public EncryptionLong Shield;
  33. /// <summary>
  34. /// 添加的攻击速度比例%
  35. /// </summary>
  36. public float addAttSpeed_bl = (float)2;
  37. /// <summary>
  38. /// 金
  39. /// </summary>
  40. public float Metal;
  41. /// <summary>
  42. /// 木
  43. /// </summary>
  44. public float Wood;
  45. /// <summary>
  46. /// 水
  47. /// </summary>
  48. public float Water;
  49. /// <summary>
  50. /// 火
  51. /// </summary>
  52. public float Fire;
  53. /// <summary>
  54. /// 土
  55. /// </summary>
  56. public float Earth;
  57. /// <summary>
  58. /// 金
  59. /// </summary>
  60. public float Metal_Injury;
  61. /// <summary>
  62. /// 木
  63. /// </summary>
  64. public float Wood_Injury;
  65. /// <summary>
  66. /// 水
  67. /// </summary>
  68. public float Water_Injury;
  69. /// <summary>
  70. /// 火
  71. /// </summary>
  72. public float Fire_Injury;
  73. /// <summary>
  74. /// 土
  75. /// </summary>
  76. public float Earth_Injury;
  77. /// <summary>
  78. /// 1=英雄 2=小怪 3=精英怪 4=boss
  79. /// </summary>
  80. public int heroType;
  81. public string modelName;
  82. public bool isMonster;
  83. // public int[] skillId;
  84. // public List<SkillConfig> skillConfigs;
  85. /// <summary>
  86. /// 所有已解锁技能的ID
  87. /// </summary>
  88. public List<int> unLockSkills;
  89. public bool isGpu;
  90. public string heroName;
  91. public List<int> MagicWeaponID;
  92. public CombatHeroInfo()
  93. {
  94. }
  95. protected Map<AttributeType, int> _AttributeCacheValue = new Map<AttributeType, int>();
  96. public void AddAttributeValueToCache(AttributeType attributeType, int value)
  97. {
  98. if (_AttributeCacheValue.TryGetValue(attributeType, out int v))
  99. {
  100. value += v;
  101. }
  102. _AttributeCacheValue[attributeType] = value;
  103. }
  104. protected void CalBasicAttribute()
  105. {
  106. _AttributeCacheValue.Clear();
  107. if (isMonster)
  108. {
  109. hp = (EncryptionLong)(modelConfig.hp * MonsterPowerUpConfig.HPFactor);
  110. defense = (EncryptionLong)(modelConfig.def * MonsterPowerUpConfig.DEFFactor);
  111. attack = (EncryptionLong)(modelConfig.attack * MonsterPowerUpConfig.ATKFactor);
  112. }
  113. else
  114. {
  115. hp = (EncryptionLong)(modelConfig.hp * powerUpConfig.HPFactor);
  116. defense = (EncryptionLong)(modelConfig.def * powerUpConfig.DEFFactor);
  117. attack = (EncryptionLong)(modelConfig.attack * powerUpConfig.ATKFactor);
  118. //职业装备提供的属性
  119. hp += PlayerManager.Instance.eqController.zyEqAddAttributeDic[modelConfig.profession].hp;
  120. defense += PlayerManager.Instance.eqController.zyEqAddAttributeDic[modelConfig.profession].def;
  121. attack += PlayerManager.Instance.eqController.zyEqAddAttributeDic[modelConfig.profession].atk;
  122. }
  123. CalUnLockSkill();
  124. for (_AttributeCacheValue.Begin(); _AttributeCacheValue.Next();)
  125. {
  126. switch (_AttributeCacheValue.Key)
  127. {
  128. case AttributeType.Hp:
  129. hp += CombatCalculateTool.Instance.GetVlaueRatioForLong(hp.Value, _AttributeCacheValue.Value);
  130. break;
  131. case AttributeType.Att:
  132. attack += CombatCalculateTool.Instance.GetVlaueRatioForLong(attack.Value,
  133. _AttributeCacheValue.Value);
  134. break;
  135. case AttributeType.Def:
  136. defense += CombatCalculateTool.Instance.GetVlaueRatioForLong(defense.Value,
  137. _AttributeCacheValue.Value);
  138. break;
  139. }
  140. }
  141. }
  142. public SkillConfig GetGroupSkillConfig(int idGroup)
  143. {
  144. if (unLockSkills == null)
  145. {
  146. return default;
  147. }
  148. for (int i = 0; i < unLockSkills.Count; i++)
  149. {
  150. SkillConfig skillConfig = ConfigComponent.Instance.Get<SkillConfig>(unLockSkills[i]);
  151. if (skillConfig.IDGroup == idGroup)
  152. {
  153. return skillConfig;
  154. }
  155. }
  156. return default;
  157. }
  158. protected void CalAttribute()
  159. {
  160. CalBasicAttribute();
  161. attSpeed = (EncryptionFloat)modelConfig.speed_atk;
  162. // skillId = modelConfig.skillID;
  163. modelName = modelConfig.model;
  164. isGpu = modelConfig.isUseGpu;
  165. heroType = modelConfig.heroType;
  166. }
  167. /// <summary>
  168. /// 计算解锁技能
  169. /// </summary>
  170. public void CalUnLockSkill()
  171. {
  172. unLockSkills = new List<int>();
  173. }
  174. protected void AddSkillAttribute(SkillConfig skillConfig)
  175. {
  176. if (skillConfig.addPropertyType == null)
  177. {
  178. return;
  179. }
  180. for (int i = 0; i < skillConfig.addPropertyType.Length; i++)
  181. {
  182. int propertyType = skillConfig.addPropertyType[i];
  183. int value = skillConfig.addPropertyValue[i];
  184. switch (propertyType)
  185. {
  186. case 1:
  187. AddAttributeValueToCache(AttributeType.Hp, value);
  188. break;
  189. case 2:
  190. AddAttributeValueToCache(AttributeType.Att, value);
  191. break;
  192. case 3:
  193. AddAttributeValueToCache(AttributeType.Def, value);
  194. break;
  195. }
  196. }
  197. }
  198. protected void SetDataConfig(int modelID, int level, int star)
  199. {
  200. modelConfig = ConfigComponent.Instance.Get<HeroModelConfig>(modelID);
  201. if (isMonster)
  202. {
  203. MonsterPowerUpConfig = ConfigComponent.Instance.Get<MonsterPowerUpConfig>(level);
  204. }
  205. else
  206. {
  207. powerUpConfig = ConfigComponent.Instance.Get<HeroPowerUpConfig>(level);
  208. }
  209. promoteConfig = ConfigComponent.Instance.Get<HeroPromoteConfig>(star);
  210. this.level = (EncryptionInt)level;
  211. heroName = LanguageManager.Instance.Text(modelConfig.name);
  212. }
  213. public void InitMonster(int modelID, int level, int star = 1)
  214. {
  215. isMonster = true;
  216. SetDataConfig(modelID, level, star);
  217. CalAttribute();
  218. }
  219. public CombatHeroInfo Copy()
  220. {
  221. CombatHeroInfo combatHeroInfo = (CombatHeroInfo)MemberwiseClone();
  222. return combatHeroInfo;
  223. }
  224. }