CombatHeroInfo.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  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 long
  27. public EncryptionFloat attSpeed
  28. {
  29. get { return _attSpeed; }
  30. }
  31. public EncryptionInt level;
  32. public EncryptionInt exp = new EncryptionInt();
  33. public HeroModelConfig modelConfig;
  34. public HeroPowerUpConfig powerUpConfig;
  35. public MonsterPowerUpConfig MonsterPowerUpConfig;
  36. public EncryptionFloat _attSpeed;
  37. /// <summary>
  38. /// 功法强度的加成 %
  39. /// </summary>
  40. public float gongFaStrength;
  41. /// <summary>
  42. /// 护盾
  43. /// </summary>
  44. public EncryptionLong Shield;
  45. /// <summary>
  46. /// 神识
  47. /// </summary>
  48. public EncryptionLong shenshi;
  49. /// <summary>
  50. /// 添加的攻击速度比例%
  51. /// </summary>
  52. public float addAttSpeed_bl;
  53. /// <summary>
  54. /// 金
  55. /// </summary>
  56. public float Metal = 100;
  57. /// <summary>
  58. /// 木
  59. /// </summary>
  60. public float Wood = 100;
  61. /// <summary>
  62. /// 水
  63. /// </summary>
  64. public float Water = 100;
  65. /// <summary>
  66. /// 火
  67. /// </summary>
  68. public float Fire = 100;
  69. /// <summary>
  70. /// 土
  71. /// </summary>
  72. public float Earth = 100;
  73. /// <summary>
  74. /// 金
  75. /// </summary>
  76. public float Metal_Injury;
  77. /// <summary>
  78. /// 木
  79. /// </summary>
  80. public float Wood_Injury;
  81. /// <summary>
  82. /// 水
  83. /// </summary>
  84. public float Water_Injury;
  85. /// <summary>
  86. /// 火
  87. /// </summary>
  88. public float Fire_Injury;
  89. /// <summary>
  90. /// 土
  91. /// </summary>
  92. public float Earth_Injury;
  93. /// <summary>
  94. /// 火精通
  95. /// </summary>
  96. public float Fire_Proficient;
  97. /// <summary>
  98. /// 土精通
  99. /// </summary>
  100. public float Earth_Proficient;
  101. /// <summary>
  102. /// 水精通
  103. /// </summary>
  104. public float Water_Proficient;
  105. /// <summary>
  106. /// 毒精通
  107. /// </summary>
  108. public float Wood_Proficient;
  109. /// <summary>
  110. /// 流行精通
  111. /// </summary>
  112. public float Metal_Proficient;
  113. /// <summary>
  114. /// 异常伤害增加
  115. /// </summary>
  116. public float abnormalHarmAdd;
  117. /// <summary>
  118. /// 金伤害增加
  119. /// </summary>
  120. public float Metal_HarmAdd;
  121. /// <summary>
  122. /// 火伤害增加
  123. /// </summary>
  124. public float Fire_HarmAdd;
  125. /// <summary>
  126. /// 土伤害增加
  127. /// </summary>
  128. public float Earth_HarmAdd;
  129. /// <summary>
  130. /// 水伤害增加
  131. /// </summary>
  132. public float Water_HarmAdd;
  133. /// <summary>
  134. /// 木伤害增加
  135. /// </summary>
  136. public float Wood_HarmAdd;
  137. /// <summary>
  138. /// 最后伤害减少
  139. /// </summary>
  140. public float finallyHarmReduce;
  141. /// <summary>
  142. /// 最终伤害增加 buff伤害除外
  143. /// </summary>
  144. public float finallyHarmAdd;
  145. /// <summary>
  146. /// 1=英雄 2=小怪 3=精英怪 4=boss
  147. /// </summary>
  148. public int heroType;
  149. public string modelName;
  150. public bool isMonster;
  151. public int k;
  152. // public int[] skillId;
  153. // public List<SkillConfig> skillConfigs;
  154. /// <summary>
  155. /// 所有已解锁技能的ID
  156. /// </summary>
  157. public List<SkillInfo> unLockSkills = new List<SkillInfo>();
  158. public bool isGpu;
  159. public string heroName;
  160. public List<FaBaoInfo> MagicWeaponID = new List<FaBaoInfo>();
  161. /// <summary>
  162. /// 大道修炼ID
  163. /// </summary>
  164. public int TaoismSkillId;
  165. public float GetAttSpeed
  166. {
  167. get
  168. {
  169. float speed = CombatCalculateTool.Instance.GetVlaueRatioForFloat(attSpeed.Value,
  170. addAttSpeed_bl + 100);
  171. if (speed < 0)
  172. {
  173. speed = 0.01f;
  174. }
  175. return speed;
  176. }
  177. }
  178. public float GetAnimationSpeed
  179. {
  180. get { return GetAttSpeed / _attSpeed.Value; }
  181. }
  182. public CombatHeroInfo()
  183. {
  184. }
  185. protected Map<AttributeType, float> _AttributeCacheValue = new Map<AttributeType, float>();
  186. /// <summary>
  187. /// 获取五行灵根属性
  188. /// </summary>
  189. /// <param name="wuXingType"></param>
  190. /// <returns></returns>
  191. public float GetWuXingShuXing(WuXingType wuXingType)
  192. {
  193. switch (wuXingType)
  194. {
  195. case WuXingType.Gold:
  196. float Metal_v = Metal - Metal_Injury;
  197. if (Metal_v < 0)
  198. {
  199. Metal_v = 0;
  200. }
  201. return Metal_v;
  202. break;
  203. case WuXingType.Wood:
  204. float Wood_v = Wood - Wood_Injury;
  205. if (Wood_v < 0)
  206. {
  207. Wood_v = 0;
  208. }
  209. return Wood_v;
  210. break;
  211. case WuXingType.Water:
  212. float Water_v = Water - Water_Injury;
  213. if (Water_v < 0)
  214. {
  215. Water_v = 0;
  216. }
  217. return Water_v;
  218. break;
  219. case WuXingType.Fire:
  220. float Fire_v = Fire - Fire_Injury;
  221. if (Fire_v < 0)
  222. {
  223. Fire_v = 0;
  224. }
  225. return Fire_v;
  226. break;
  227. case WuXingType.Earth:
  228. float Earth_v = Earth - Earth_Injury;
  229. if (Earth_v < 0)
  230. {
  231. Earth_v = 0;
  232. }
  233. return Earth_v;
  234. break;
  235. default:
  236. return 0;
  237. }
  238. }
  239. protected void CalBasicAttribute()
  240. {
  241. _AttributeCacheValue.Clear();
  242. modelID = modelConfig.ID;
  243. if (isMonster)
  244. {
  245. unLockSkills.Clear();
  246. hp = (EncryptionLong)(modelConfig.hp * MonsterPowerUpConfig.HPFactor);
  247. defense = (EncryptionLong)(modelConfig.def * MonsterPowerUpConfig.DEFFactor);
  248. attack = (EncryptionLong)(modelConfig.attack * MonsterPowerUpConfig.ATKFactor);
  249. k = MonsterPowerUpConfig.defK;
  250. Metal = modelConfig.Linggen[0] * MonsterPowerUpConfig.LinggenUp / 100;
  251. Water = modelConfig.Linggen[1] * MonsterPowerUpConfig.LinggenUp / 100;
  252. Wood = modelConfig.Linggen[2] * MonsterPowerUpConfig.LinggenUp / 100;
  253. Fire = modelConfig.Linggen[3] * MonsterPowerUpConfig.LinggenUp / 100;
  254. Earth = modelConfig.Linggen[4] * MonsterPowerUpConfig.LinggenUp / 100;
  255. Shield = (EncryptionLong)(modelConfig.shield * MonsterPowerUpConfig.HudunFactor);
  256. SetSkillAttSpeed(modelConfig.speed_atk);
  257. if (modelConfig.skillID != null)
  258. {
  259. for (int i = 0; i < modelConfig.skillID.Length; i++)
  260. {
  261. int id = modelConfig.skillID[i];
  262. if (id <= 0)
  263. {
  264. continue;
  265. }
  266. int startLevel = modelConfig.skillActiveLv[i];
  267. if (startLevel > 0 && level < startLevel)
  268. {
  269. continue;
  270. }
  271. SkillInfo skillInfo =
  272. new SkillInfo(id, MonsterPowerUpConfig.GongfaLv, MonsterPowerUpConfig.GongfaStar);
  273. skillInfo.index = i;
  274. unLockSkills.Add(skillInfo);
  275. }
  276. }
  277. if (modelConfig.fa_bao_id != null)
  278. {
  279. for (int i = 0; i < modelConfig.fa_bao_id.Length; i++)
  280. {
  281. int faBaoId = modelConfig.fa_bao_id[i];
  282. int startLevel = modelConfig.fabaoActiveLv[i];
  283. if (startLevel > 0 && level < startLevel)
  284. {
  285. continue;
  286. }
  287. if (faBaoId > 0)
  288. {
  289. FaBaoInfo faBaoInfo = new FaBaoInfo(faBaoId, MonsterPowerUpConfig.FabaoLv,
  290. MonsterPowerUpConfig.FabaoStar);
  291. MagicWeaponID.Add(faBaoInfo);
  292. }
  293. }
  294. }
  295. }
  296. else
  297. {
  298. hp = (EncryptionLong)(modelConfig.hp * powerUpConfig.HPFactor);
  299. defense = (EncryptionLong)(modelConfig.def * powerUpConfig.DEFFactor);
  300. attack = (EncryptionLong)(modelConfig.attack * powerUpConfig.ATKFactor);
  301. Shield = (EncryptionLong)(modelConfig.shield * powerUpConfig.HudunFactor);
  302. // shenshi = (EncryptionLong)(modelConfig.shenshi * powerUpConfig.ShenshiFactor);
  303. k = powerUpConfig.defK;
  304. }
  305. for (_AttributeCacheValue.Begin(); _AttributeCacheValue.Next();)
  306. {
  307. switch (_AttributeCacheValue.Key)
  308. {
  309. case AttributeType.Hp:
  310. hp += CombatCalculateTool.Instance.GetVlaueRatioForLong(hp.Value, _AttributeCacheValue.Value);
  311. break;
  312. case AttributeType.Att:
  313. attack += CombatCalculateTool.Instance.GetVlaueRatioForLong(attack.Value,
  314. _AttributeCacheValue.Value);
  315. break;
  316. case AttributeType.Def:
  317. defense += CombatCalculateTool.Instance.GetVlaueRatioForLong(defense.Value,
  318. _AttributeCacheValue.Value);
  319. break;
  320. }
  321. }
  322. if (!isMonster)
  323. {
  324. for (int i = 0; i < MagicWeaponID.Count; i++)
  325. {
  326. FaBaoInfo faBaoInfo = MagicWeaponID[i];
  327. foreach (var VARIABLE in faBaoInfo.attriButedIC)
  328. {
  329. switch (VARIABLE.Key)
  330. {
  331. case 1:
  332. hp += VARIABLE.Value;
  333. break;
  334. case 2:
  335. defense += VARIABLE.Value;
  336. break;
  337. case 3:
  338. attack += VARIABLE.Value;
  339. break;
  340. }
  341. }
  342. }
  343. }
  344. }
  345. public SkillConfig GetGroupSkillConfig(int idGroup)
  346. {
  347. if (unLockSkills == null)
  348. {
  349. return default;
  350. }
  351. for (int i = 0; i < unLockSkills.Count; i++)
  352. {
  353. // SkillConfig skillConfig = ConfigComponent.Instance.Get<SkillConfig>(unLockSkills[i]);
  354. if (unLockSkills[i].skillConfig.IDGroup == idGroup)
  355. {
  356. return unLockSkills[i].skillConfig;
  357. }
  358. }
  359. return default;
  360. }
  361. protected void CalAttribute()
  362. {
  363. CalBasicAttribute();
  364. // skillId = modelConfig.skillID;
  365. modelName = modelConfig.model;
  366. isGpu = modelConfig.isUseGpu;
  367. heroType = modelConfig.heroType;
  368. }
  369. public void SetSkillAttSpeed(float attSpeed)
  370. {
  371. _attSpeed = (EncryptionFloat)(1.0f / attSpeed);
  372. }
  373. protected void SetDataConfig(int modelID, int level)
  374. {
  375. modelConfig = ConfigComponent.Instance.Get<HeroModelConfig>(modelID);
  376. if (isMonster)
  377. {
  378. MonsterPowerUpConfig = ConfigComponent.Instance.Get<MonsterPowerUpConfig>(level);
  379. }
  380. else
  381. {
  382. powerUpConfig = ConfigComponent.Instance.Get<HeroPowerUpConfig>(level);
  383. }
  384. this.level = (EncryptionInt)level;
  385. heroName = LanguageManager.Instance.Text(modelConfig.name);
  386. }
  387. public void InitMonster(int modelID, int level)
  388. {
  389. isMonster = true;
  390. SetDataConfig(modelID, level);
  391. CalAttribute();
  392. }
  393. public CombatHeroInfo Copy()
  394. {
  395. CombatHeroInfo combatHeroInfo = (CombatHeroInfo)MemberwiseClone();
  396. return combatHeroInfo;
  397. }
  398. }