CombatHeroInfo.cs 6.8 KB

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