CombatHeroInfo.cs 7.2 KB

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