CombatHeroInfo.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  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 EncryptionInt exp = new EncryptionInt();
  29. public HeroModelConfig modelConfig;
  30. public HeroPowerUpConfig powerUpConfig;
  31. public MonsterPowerUpConfig MonsterPowerUpConfig;
  32. /// <summary>
  33. /// 功法强度的加成 %
  34. /// </summary>
  35. public float gongFaStrength;
  36. /// <summary>
  37. /// 护盾
  38. /// </summary>
  39. public EncryptionLong Shield;
  40. /// <summary>
  41. /// 神识
  42. /// </summary>
  43. public EncryptionLong shenshi;
  44. /// <summary>
  45. /// 添加的攻击速度比例%
  46. /// </summary>
  47. public float addAttSpeed_bl;
  48. /// <summary>
  49. /// 金
  50. /// </summary>
  51. public float Metal = 100;
  52. /// <summary>
  53. /// 木
  54. /// </summary>
  55. public float Wood = 100;
  56. /// <summary>
  57. /// 水
  58. /// </summary>
  59. public float Water = 100;
  60. /// <summary>
  61. /// 火
  62. /// </summary>
  63. public float Fire = 100;
  64. /// <summary>
  65. /// 土
  66. /// </summary>
  67. public float Earth = 100;
  68. /// <summary>
  69. /// 金
  70. /// </summary>
  71. public float Metal_Injury;
  72. /// <summary>
  73. /// 木
  74. /// </summary>
  75. public float Wood_Injury;
  76. /// <summary>
  77. /// 水
  78. /// </summary>
  79. public float Water_Injury;
  80. /// <summary>
  81. /// 火
  82. /// </summary>
  83. public float Fire_Injury;
  84. /// <summary>
  85. /// 土
  86. /// </summary>
  87. public float Earth_Injury;
  88. /// <summary>
  89. /// 1=英雄 2=小怪 3=精英怪 4=boss
  90. /// </summary>
  91. public int heroType;
  92. public string modelName;
  93. public bool isMonster;
  94. public int k;
  95. // public int[] skillId;
  96. // public List<SkillConfig> skillConfigs;
  97. /// <summary>
  98. /// 所有已解锁技能的ID
  99. /// </summary>
  100. public List<SkillInfo> unLockSkills = new List<SkillInfo>();
  101. public bool isGpu;
  102. public string heroName;
  103. public List<FaBaoInfo> MagicWeaponID = new List<FaBaoInfo>();
  104. /// <summary>
  105. /// 大道修炼ID
  106. /// </summary>
  107. public int TaoismSkillId;
  108. public float GetAttSpeed
  109. {
  110. get
  111. {
  112. float speed = CombatCalculateTool.Instance.GetVlaueRatioForFloat(attSpeed.Value,
  113. addAttSpeed_bl + 100);
  114. if (speed < 0)
  115. {
  116. speed = 0;
  117. }
  118. return speed;
  119. }
  120. }
  121. public CombatHeroInfo()
  122. {
  123. }
  124. protected Map<AttributeType, float> _AttributeCacheValue = new Map<AttributeType, float>();
  125. public void AddAttributeValueToCache(AttributeType attributeType, float value)
  126. {
  127. if (_AttributeCacheValue.TryGetValue(attributeType, out float v))
  128. {
  129. value += v;
  130. }
  131. _AttributeCacheValue[attributeType] = value;
  132. }
  133. /// <summary>
  134. /// 获取五行灵根属性
  135. /// </summary>
  136. /// <param name="wuXingType"></param>
  137. /// <returns></returns>
  138. public float GetWuXingShuXing(WuXingType wuXingType)
  139. {
  140. switch (wuXingType)
  141. {
  142. case WuXingType.Gold:
  143. float Metal_v = Metal - Metal_Injury;
  144. if (Metal_v < 0)
  145. {
  146. Metal_v = 0;
  147. }
  148. return Metal_v;
  149. break;
  150. case WuXingType.Wood:
  151. float Wood_v = Wood - Wood_Injury;
  152. if (Wood_v < 0)
  153. {
  154. Wood_v = 0;
  155. }
  156. return Wood_v;
  157. break;
  158. case WuXingType.Water:
  159. float Water_v = Water - Water_Injury;
  160. if (Water_v < 0)
  161. {
  162. Water_v = 0;
  163. }
  164. return Water_v;
  165. break;
  166. case WuXingType.Fire:
  167. float Fire_v = Fire - Fire_Injury;
  168. if (Fire_v < 0)
  169. {
  170. Fire_v = 0;
  171. }
  172. return Fire_v;
  173. break;
  174. case WuXingType.Earth:
  175. float Earth_v = Earth - Earth_Injury;
  176. if (Earth_v < 0)
  177. {
  178. Earth_v = 0;
  179. }
  180. return Earth_v;
  181. break;
  182. default:
  183. return 0;
  184. }
  185. }
  186. protected void CalBasicAttribute()
  187. {
  188. _AttributeCacheValue.Clear();
  189. if (isMonster)
  190. {
  191. unLockSkills.Clear();
  192. hp = (EncryptionLong)(modelConfig.hp * MonsterPowerUpConfig.HPFactor);
  193. defense = (EncryptionLong)(modelConfig.def * MonsterPowerUpConfig.DEFFactor);
  194. attack = (EncryptionLong)(modelConfig.attack * MonsterPowerUpConfig.ATKFactor);
  195. k = MonsterPowerUpConfig.defK;
  196. if (modelConfig.skillID != null)
  197. {
  198. for (int i = 0; i < modelConfig.skillID.Length; i++)
  199. {
  200. int skillid = modelConfig.skillID[i] * 10 + MonsterPowerUpConfig.GongfaStar;
  201. SkillInfo skillInfo = new SkillInfo(skillid, MonsterPowerUpConfig.GongfaLv);
  202. unLockSkills.Add(skillInfo);
  203. }
  204. }
  205. if (modelConfig.fa_bao_id != null)
  206. {
  207. for (int i = 0; i < modelConfig.fa_bao_id.Length; i++)
  208. {
  209. int faBaoId = modelConfig.fa_bao_id[i];
  210. FaBaoInfo faBaoInfo = new FaBaoInfo(faBaoId, MonsterPowerUpConfig.FabaoLv,
  211. MonsterPowerUpConfig.FabaoStar);
  212. MagicWeaponID.Add(faBaoInfo);
  213. }
  214. }
  215. }
  216. else
  217. {
  218. hp = (EncryptionLong)(modelConfig.hp * powerUpConfig.HPFactor);
  219. defense = (EncryptionLong)(modelConfig.def * powerUpConfig.DEFFactor);
  220. attack = (EncryptionLong)(modelConfig.attack * powerUpConfig.ATKFactor);
  221. Shield = (EncryptionLong)(modelConfig.shield * powerUpConfig.HudunFactor);
  222. // shenshi = (EncryptionLong)(modelConfig.shenshi * powerUpConfig.ShenshiFactor);
  223. k = powerUpConfig.defK;
  224. }
  225. for (_AttributeCacheValue.Begin(); _AttributeCacheValue.Next();)
  226. {
  227. switch (_AttributeCacheValue.Key)
  228. {
  229. case AttributeType.Hp:
  230. hp += CombatCalculateTool.Instance.GetVlaueRatioForLong(hp.Value, _AttributeCacheValue.Value);
  231. break;
  232. case AttributeType.Att:
  233. attack += CombatCalculateTool.Instance.GetVlaueRatioForLong(attack.Value,
  234. _AttributeCacheValue.Value);
  235. break;
  236. case AttributeType.Def:
  237. defense += CombatCalculateTool.Instance.GetVlaueRatioForLong(defense.Value,
  238. _AttributeCacheValue.Value);
  239. break;
  240. }
  241. }
  242. }
  243. public SkillConfig GetGroupSkillConfig(int idGroup)
  244. {
  245. if (unLockSkills == null)
  246. {
  247. return default;
  248. }
  249. for (int i = 0; i < unLockSkills.Count; i++)
  250. {
  251. // SkillConfig skillConfig = ConfigComponent.Instance.Get<SkillConfig>(unLockSkills[i]);
  252. if (unLockSkills[i].skillConfig.IDGroup == idGroup)
  253. {
  254. return unLockSkills[i].skillConfig;
  255. }
  256. }
  257. return default;
  258. }
  259. protected void CalAttribute()
  260. {
  261. CalBasicAttribute();
  262. attSpeed = (EncryptionFloat)modelConfig.speed_atk;
  263. // skillId = modelConfig.skillID;
  264. modelName = modelConfig.model;
  265. isGpu = modelConfig.isUseGpu;
  266. heroType = modelConfig.heroType;
  267. }
  268. protected void AddSkillAttribute(SkillConfig skillConfig)
  269. {
  270. if (skillConfig.addPropertyType == null)
  271. {
  272. return;
  273. }
  274. for (int i = 0; i < skillConfig.addPropertyType.Length; i++)
  275. {
  276. int propertyType = skillConfig.addPropertyType[i];
  277. float value = skillConfig.addPropertyValue[i];
  278. switch (propertyType)
  279. {
  280. case 101:
  281. AddAttributeValueToCache(AttributeType.Hp, value);
  282. break;
  283. case 102:
  284. AddAttributeValueToCache(AttributeType.Att, value);
  285. break;
  286. case 103:
  287. AddAttributeValueToCache(AttributeType.Def, value);
  288. break;
  289. }
  290. }
  291. }
  292. protected void SetDataConfig(int modelID, int level)
  293. {
  294. modelConfig = ConfigComponent.Instance.Get<HeroModelConfig>(modelID);
  295. if (isMonster)
  296. {
  297. MonsterPowerUpConfig = ConfigComponent.Instance.Get<MonsterPowerUpConfig>(level);
  298. }
  299. else
  300. {
  301. powerUpConfig = ConfigComponent.Instance.Get<HeroPowerUpConfig>(level);
  302. }
  303. this.level = (EncryptionInt)level;
  304. heroName = LanguageManager.Instance.Text(modelConfig.name);
  305. }
  306. public void InitMonster(int modelID, int level)
  307. {
  308. isMonster = true;
  309. SetDataConfig(modelID, level);
  310. CalAttribute();
  311. }
  312. public CombatHeroInfo Copy()
  313. {
  314. CombatHeroInfo combatHeroInfo = (CombatHeroInfo)MemberwiseClone();
  315. return combatHeroInfo;
  316. }
  317. }