CombatHeroInfo.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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 ;
  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 float GetAttSpeed
  93. {
  94. get
  95. {
  96. return CombatCalculateTool.Instance.GetVlaueRatioForFloat(attSpeed.Value,
  97. addAttSpeed_bl + 100);
  98. }
  99. }
  100. public CombatHeroInfo()
  101. {
  102. }
  103. protected Map<AttributeType, int> _AttributeCacheValue = new Map<AttributeType, int>();
  104. public void AddAttributeValueToCache(AttributeType attributeType, int value)
  105. {
  106. if (_AttributeCacheValue.TryGetValue(attributeType, out int v))
  107. {
  108. value += v;
  109. }
  110. _AttributeCacheValue[attributeType] = value;
  111. }
  112. protected void CalBasicAttribute()
  113. {
  114. _AttributeCacheValue.Clear();
  115. if (isMonster)
  116. {
  117. hp = (EncryptionLong)(modelConfig.hp * MonsterPowerUpConfig.HPFactor);
  118. defense = (EncryptionLong)(modelConfig.def * MonsterPowerUpConfig.DEFFactor);
  119. attack = (EncryptionLong)(modelConfig.attack * MonsterPowerUpConfig.ATKFactor);
  120. }
  121. else
  122. {
  123. hp = (EncryptionLong)(modelConfig.hp * powerUpConfig.HPFactor);
  124. defense = (EncryptionLong)(modelConfig.def * powerUpConfig.DEFFactor);
  125. attack = (EncryptionLong)(modelConfig.attack * powerUpConfig.ATKFactor);
  126. //职业装备提供的属性
  127. hp += PlayerManager.Instance.eqController.zyEqAddAttributeDic[modelConfig.profession].hp;
  128. defense += PlayerManager.Instance.eqController.zyEqAddAttributeDic[modelConfig.profession].def;
  129. attack += PlayerManager.Instance.eqController.zyEqAddAttributeDic[modelConfig.profession].atk;
  130. }
  131. CalUnLockSkill();
  132. for (_AttributeCacheValue.Begin(); _AttributeCacheValue.Next();)
  133. {
  134. switch (_AttributeCacheValue.Key)
  135. {
  136. case AttributeType.Hp:
  137. hp += CombatCalculateTool.Instance.GetVlaueRatioForLong(hp.Value, _AttributeCacheValue.Value);
  138. break;
  139. case AttributeType.Att:
  140. attack += CombatCalculateTool.Instance.GetVlaueRatioForLong(attack.Value,
  141. _AttributeCacheValue.Value);
  142. break;
  143. case AttributeType.Def:
  144. defense += CombatCalculateTool.Instance.GetVlaueRatioForLong(defense.Value,
  145. _AttributeCacheValue.Value);
  146. break;
  147. }
  148. }
  149. }
  150. public SkillConfig GetGroupSkillConfig(int idGroup)
  151. {
  152. if (unLockSkills == null)
  153. {
  154. return default;
  155. }
  156. for (int i = 0; i < unLockSkills.Count; i++)
  157. {
  158. SkillConfig skillConfig = ConfigComponent.Instance.Get<SkillConfig>(unLockSkills[i]);
  159. if (skillConfig.IDGroup == idGroup)
  160. {
  161. return skillConfig;
  162. }
  163. }
  164. return default;
  165. }
  166. protected void CalAttribute()
  167. {
  168. CalBasicAttribute();
  169. attSpeed = (EncryptionFloat)modelConfig.speed_atk;
  170. // skillId = modelConfig.skillID;
  171. modelName = modelConfig.model;
  172. isGpu = modelConfig.isUseGpu;
  173. heroType = modelConfig.heroType;
  174. }
  175. /// <summary>
  176. /// 计算解锁技能
  177. /// </summary>
  178. public void CalUnLockSkill()
  179. {
  180. unLockSkills = new List<int>();
  181. }
  182. protected void AddSkillAttribute(SkillConfig skillConfig)
  183. {
  184. if (skillConfig.addPropertyType == null)
  185. {
  186. return;
  187. }
  188. for (int i = 0; i < skillConfig.addPropertyType.Length; i++)
  189. {
  190. int propertyType = skillConfig.addPropertyType[i];
  191. int value = skillConfig.addPropertyValue[i];
  192. switch (propertyType)
  193. {
  194. case 1:
  195. AddAttributeValueToCache(AttributeType.Hp, value);
  196. break;
  197. case 2:
  198. AddAttributeValueToCache(AttributeType.Att, value);
  199. break;
  200. case 3:
  201. AddAttributeValueToCache(AttributeType.Def, value);
  202. break;
  203. }
  204. }
  205. }
  206. protected void SetDataConfig(int modelID, int level, int star)
  207. {
  208. modelConfig = ConfigComponent.Instance.Get<HeroModelConfig>(modelID);
  209. if (isMonster)
  210. {
  211. MonsterPowerUpConfig = ConfigComponent.Instance.Get<MonsterPowerUpConfig>(level);
  212. }
  213. else
  214. {
  215. powerUpConfig = ConfigComponent.Instance.Get<HeroPowerUpConfig>(level);
  216. }
  217. promoteConfig = ConfigComponent.Instance.Get<HeroPromoteConfig>(star);
  218. this.level = (EncryptionInt)level;
  219. heroName = LanguageManager.Instance.Text(modelConfig.name);
  220. }
  221. public void InitMonster(int modelID, int level, int star = 1)
  222. {
  223. isMonster = true;
  224. SetDataConfig(modelID, level, star);
  225. CalAttribute();
  226. }
  227. public CombatHeroInfo Copy()
  228. {
  229. CombatHeroInfo combatHeroInfo = (CombatHeroInfo)MemberwiseClone();
  230. return combatHeroInfo;
  231. }
  232. }