CombatHeroInfo.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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 GameLogic.Player;
  10. using UnityEngine;
  11. using UnityEngine.Serialization;
  12. using Utility;
  13. [System.Serializable]
  14. public class CombatHeroInfo
  15. {
  16. public enum AttributeType
  17. {
  18. Hp,
  19. Att,
  20. Def,
  21. }
  22. public int modelID;
  23. public EncryptionLong hp = new EncryptionLong();
  24. public EncryptionLong defense = new EncryptionLong();
  25. public EncryptionLong attack = new EncryptionLong();
  26. public EncryptionFloat attSpeed = (EncryptionFloat)2;
  27. public EncryptionInt level;
  28. public EncryptionFloat exp = new EncryptionFloat();
  29. public HeroModelConfig modelConfig;
  30. public HeroPowerUpConfig powerUpConfig;
  31. public MonsterPowerUpConfig MonsterPowerUpConfig;
  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=100;
  48. /// <summary>
  49. /// 木
  50. /// </summary>
  51. public float Wood = 100;
  52. /// <summary>
  53. /// 水
  54. /// </summary>
  55. public float Water = 100;
  56. /// <summary>
  57. /// 火
  58. /// </summary>
  59. public float Fire = 100;
  60. /// <summary>
  61. /// 土
  62. /// </summary>
  63. public float Earth = 100;
  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 k;
  91. // public int[] skillId;
  92. // public List<SkillConfig> skillConfigs;
  93. /// <summary>
  94. /// 所有已解锁技能的ID
  95. /// </summary>
  96. public List<SkillInfo> unLockSkills = new List<SkillInfo>();
  97. public bool isGpu;
  98. public string heroName;
  99. public List<FaBaoInfo> MagicWeaponID = new List<FaBaoInfo>();
  100. /// <summary>
  101. /// 大道修炼ID
  102. /// </summary>
  103. public int TaoismSkillId;
  104. public float GetAttSpeed
  105. {
  106. get
  107. {
  108. float speed = CombatCalculateTool.Instance.GetVlaueRatioForFloat(attSpeed.Value,
  109. addAttSpeed_bl + 100);
  110. if (speed < 0)
  111. {
  112. speed = 0;
  113. }
  114. return speed;
  115. }
  116. }
  117. public CombatHeroInfo()
  118. {
  119. }
  120. protected Map<AttributeType, int> _AttributeCacheValue = new Map<AttributeType, int>();
  121. public void AddAttributeValueToCache(AttributeType attributeType, int value)
  122. {
  123. if (_AttributeCacheValue.TryGetValue(attributeType, out int v))
  124. {
  125. value += v;
  126. }
  127. _AttributeCacheValue[attributeType] = value;
  128. }
  129. /// <summary>
  130. /// 获取五行灵根属性
  131. /// </summary>
  132. /// <param name="wuXingType"></param>
  133. /// <returns></returns>
  134. public float GetWuXingShuXing(WuXingType wuXingType)
  135. {
  136. switch (wuXingType)
  137. {
  138. case WuXingType.Gold:
  139. return Metal;
  140. break;
  141. case WuXingType.Wood:
  142. return Wood;
  143. break;
  144. case WuXingType.Water:
  145. return Water;
  146. break;
  147. case WuXingType.Fire:
  148. return Fire;
  149. break;
  150. case WuXingType.Earth:
  151. return Earth;
  152. break;
  153. default:
  154. return 0;
  155. }
  156. }
  157. protected void CalBasicAttribute()
  158. {
  159. _AttributeCacheValue.Clear();
  160. if (isMonster)
  161. {
  162. hp = (EncryptionLong)(modelConfig.hp * MonsterPowerUpConfig.HPFactor);
  163. defense = (EncryptionLong)(modelConfig.def * MonsterPowerUpConfig.DEFFactor);
  164. attack = (EncryptionLong)(modelConfig.attack * MonsterPowerUpConfig.ATKFactor);
  165. }
  166. else
  167. {
  168. hp = (EncryptionLong)(modelConfig.hp * powerUpConfig.HPFactor);
  169. defense = (EncryptionLong)(modelConfig.def * powerUpConfig.DEFFactor);
  170. attack = (EncryptionLong)(modelConfig.attack * powerUpConfig.ATKFactor);
  171. Shield = (EncryptionLong)(modelConfig.shield * powerUpConfig.HudunFactor);
  172. shenshi = (EncryptionLong)(modelConfig.shenshi * powerUpConfig.ShenshiFactor);
  173. k = powerUpConfig.defK;
  174. }
  175. for (_AttributeCacheValue.Begin(); _AttributeCacheValue.Next();)
  176. {
  177. switch (_AttributeCacheValue.Key)
  178. {
  179. case AttributeType.Hp:
  180. hp += CombatCalculateTool.Instance.GetVlaueRatioForLong(hp.Value, _AttributeCacheValue.Value);
  181. break;
  182. case AttributeType.Att:
  183. attack += CombatCalculateTool.Instance.GetVlaueRatioForLong(attack.Value,
  184. _AttributeCacheValue.Value);
  185. break;
  186. case AttributeType.Def:
  187. defense += CombatCalculateTool.Instance.GetVlaueRatioForLong(defense.Value,
  188. _AttributeCacheValue.Value);
  189. break;
  190. }
  191. }
  192. }
  193. public SkillConfig GetGroupSkillConfig(int idGroup)
  194. {
  195. if (unLockSkills == null)
  196. {
  197. return default;
  198. }
  199. for (int i = 0; i < unLockSkills.Count; i++)
  200. {
  201. // SkillConfig skillConfig = ConfigComponent.Instance.Get<SkillConfig>(unLockSkills[i]);
  202. if (unLockSkills[i].skillConfig.IDGroup == idGroup)
  203. {
  204. return unLockSkills[i].skillConfig;
  205. }
  206. }
  207. return default;
  208. }
  209. protected void CalAttribute()
  210. {
  211. CalBasicAttribute();
  212. attSpeed = (EncryptionFloat)modelConfig.speed_atk;
  213. // skillId = modelConfig.skillID;
  214. modelName = modelConfig.model;
  215. isGpu = modelConfig.isUseGpu;
  216. heroType = modelConfig.heroType;
  217. }
  218. protected void AddSkillAttribute(SkillConfig skillConfig)
  219. {
  220. if (skillConfig.addPropertyType == null)
  221. {
  222. return;
  223. }
  224. for (int i = 0; i < skillConfig.addPropertyType.Length; i++)
  225. {
  226. int propertyType = skillConfig.addPropertyType[i];
  227. int value = skillConfig.addPropertyValue[i];
  228. switch (propertyType)
  229. {
  230. case 1:
  231. AddAttributeValueToCache(AttributeType.Hp, value);
  232. break;
  233. case 2:
  234. AddAttributeValueToCache(AttributeType.Att, value);
  235. break;
  236. case 3:
  237. AddAttributeValueToCache(AttributeType.Def, value);
  238. break;
  239. }
  240. }
  241. }
  242. protected void SetDataConfig(int modelID, int level)
  243. {
  244. modelConfig = ConfigComponent.Instance.Get<HeroModelConfig>(modelID);
  245. if (isMonster)
  246. {
  247. MonsterPowerUpConfig = ConfigComponent.Instance.Get<MonsterPowerUpConfig>(level);
  248. }
  249. else
  250. {
  251. powerUpConfig = ConfigComponent.Instance.Get<HeroPowerUpConfig>(level);
  252. }
  253. this.level = (EncryptionInt)level;
  254. heroName = LanguageManager.Instance.Text(modelConfig.name);
  255. }
  256. public void InitMonster(int modelID, int level)
  257. {
  258. isMonster = true;
  259. SetDataConfig(modelID, level);
  260. CalAttribute();
  261. }
  262. public CombatHeroInfo Copy()
  263. {
  264. CombatHeroInfo combatHeroInfo = (CombatHeroInfo)MemberwiseClone();
  265. return combatHeroInfo;
  266. }
  267. }