CombatHeroInfo.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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. /// 1=英雄 2=小怪 3=精英怪 4=boss
  95. /// </summary>
  96. public int heroType;
  97. public string modelName;
  98. public bool isMonster;
  99. public int k;
  100. // public int[] skillId;
  101. // public List<SkillConfig> skillConfigs;
  102. /// <summary>
  103. /// 所有已解锁技能的ID
  104. /// </summary>
  105. public List<SkillInfo> unLockSkills = new List<SkillInfo>();
  106. public bool isGpu;
  107. public string heroName;
  108. public List<FaBaoInfo> MagicWeaponID = new List<FaBaoInfo>();
  109. /// <summary>
  110. /// 大道修炼ID
  111. /// </summary>
  112. public int TaoismSkillId;
  113. public float GetAttSpeed
  114. {
  115. get
  116. {
  117. float speed = CombatCalculateTool.Instance.GetVlaueRatioForFloat(attSpeed.Value,
  118. addAttSpeed_bl + 100);
  119. if (speed < 0)
  120. {
  121. speed = 0.01f;
  122. }
  123. return speed;
  124. }
  125. }
  126. public float GetAnimationSpeed
  127. {
  128. get { return GetAttSpeed / _attSpeed.Value; }
  129. }
  130. public CombatHeroInfo()
  131. {
  132. }
  133. protected Map<AttributeType, float> _AttributeCacheValue = new Map<AttributeType, float>();
  134. public void AddAttributeValueToCache(AttributeType attributeType, float value)
  135. {
  136. if (_AttributeCacheValue.TryGetValue(attributeType, out float v))
  137. {
  138. value += v;
  139. }
  140. _AttributeCacheValue[attributeType] = value;
  141. }
  142. /// <summary>
  143. /// 获取五行灵根属性
  144. /// </summary>
  145. /// <param name="wuXingType"></param>
  146. /// <returns></returns>
  147. public float GetWuXingShuXing(WuXingType wuXingType)
  148. {
  149. switch (wuXingType)
  150. {
  151. case WuXingType.Gold:
  152. float Metal_v = Metal - Metal_Injury;
  153. if (Metal_v < 0)
  154. {
  155. Metal_v = 0;
  156. }
  157. return Metal_v;
  158. break;
  159. case WuXingType.Wood:
  160. float Wood_v = Wood - Wood_Injury;
  161. if (Wood_v < 0)
  162. {
  163. Wood_v = 0;
  164. }
  165. return Wood_v;
  166. break;
  167. case WuXingType.Water:
  168. float Water_v = Water - Water_Injury;
  169. if (Water_v < 0)
  170. {
  171. Water_v = 0;
  172. }
  173. return Water_v;
  174. break;
  175. case WuXingType.Fire:
  176. float Fire_v = Fire - Fire_Injury;
  177. if (Fire_v < 0)
  178. {
  179. Fire_v = 0;
  180. }
  181. return Fire_v;
  182. break;
  183. case WuXingType.Earth:
  184. float Earth_v = Earth - Earth_Injury;
  185. if (Earth_v < 0)
  186. {
  187. Earth_v = 0;
  188. }
  189. return Earth_v;
  190. break;
  191. default:
  192. return 0;
  193. }
  194. }
  195. protected void CalBasicAttribute()
  196. {
  197. _AttributeCacheValue.Clear();
  198. if (isMonster)
  199. {
  200. unLockSkills.Clear();
  201. hp = (EncryptionLong)(modelConfig.hp * MonsterPowerUpConfig.HPFactor);
  202. defense = (EncryptionLong)(modelConfig.def * MonsterPowerUpConfig.DEFFactor);
  203. attack = (EncryptionLong)(modelConfig.attack * MonsterPowerUpConfig.ATKFactor);
  204. k = MonsterPowerUpConfig.defK;
  205. Metal= modelConfig.Linggen[0]*MonsterPowerUpConfig.LinggenUp/100;
  206. Water= modelConfig.Linggen[1]*MonsterPowerUpConfig.LinggenUp/100;
  207. Wood= modelConfig.Linggen[2]*MonsterPowerUpConfig.LinggenUp/100;
  208. Fire= modelConfig.Linggen[3]*MonsterPowerUpConfig.LinggenUp/100;
  209. Earth= modelConfig.Linggen[4]*MonsterPowerUpConfig.LinggenUp/100;
  210. if (modelConfig.skillID != null)
  211. {
  212. for (int i = 0; i < modelConfig.skillID.Length; i++)
  213. {
  214. int id = modelConfig.skillID[i];
  215. if (id <= 0)
  216. {
  217. continue;
  218. }
  219. int start = MonsterPowerUpConfig.GongfaStar;
  220. int skillid = id * 10 + start;
  221. while (start >= 0)
  222. {
  223. SkillConfig skillConfig = ConfigComponent.Instance.Get<SkillConfig>(skillid);
  224. if (skillConfig.ID > 0)
  225. {
  226. break;
  227. }
  228. start--;
  229. skillid = id * 10 + start;
  230. }
  231. SkillInfo skillInfo = new SkillInfo(skillid, MonsterPowerUpConfig.GongfaLv);
  232. skillInfo.index = i;
  233. unLockSkills.Add(skillInfo);
  234. }
  235. }
  236. if (modelConfig.fa_bao_id != null)
  237. {
  238. for (int i = 0; i < modelConfig.fa_bao_id.Length; i++)
  239. {
  240. int faBaoId = modelConfig.fa_bao_id[i];
  241. if (faBaoId > 0)
  242. {
  243. FaBaoInfo faBaoInfo = new FaBaoInfo(faBaoId, MonsterPowerUpConfig.FabaoLv,
  244. MonsterPowerUpConfig.FabaoStar);
  245. MagicWeaponID.Add(faBaoInfo);
  246. }
  247. }
  248. }
  249. }
  250. else
  251. {
  252. hp = (EncryptionLong)(modelConfig.hp * powerUpConfig.HPFactor);
  253. defense = (EncryptionLong)(modelConfig.def * powerUpConfig.DEFFactor);
  254. attack = (EncryptionLong)(modelConfig.attack * powerUpConfig.ATKFactor);
  255. Shield = (EncryptionLong)(modelConfig.shield * powerUpConfig.HudunFactor);
  256. // shenshi = (EncryptionLong)(modelConfig.shenshi * powerUpConfig.ShenshiFactor);
  257. k = powerUpConfig.defK;
  258. }
  259. for (_AttributeCacheValue.Begin(); _AttributeCacheValue.Next();)
  260. {
  261. switch (_AttributeCacheValue.Key)
  262. {
  263. case AttributeType.Hp:
  264. hp += CombatCalculateTool.Instance.GetVlaueRatioForLong(hp.Value, _AttributeCacheValue.Value);
  265. break;
  266. case AttributeType.Att:
  267. attack += CombatCalculateTool.Instance.GetVlaueRatioForLong(attack.Value,
  268. _AttributeCacheValue.Value);
  269. break;
  270. case AttributeType.Def:
  271. defense += CombatCalculateTool.Instance.GetVlaueRatioForLong(defense.Value,
  272. _AttributeCacheValue.Value);
  273. break;
  274. }
  275. }
  276. }
  277. public SkillConfig GetGroupSkillConfig(int idGroup)
  278. {
  279. if (unLockSkills == null)
  280. {
  281. return default;
  282. }
  283. for (int i = 0; i < unLockSkills.Count; i++)
  284. {
  285. // SkillConfig skillConfig = ConfigComponent.Instance.Get<SkillConfig>(unLockSkills[i]);
  286. if (unLockSkills[i].skillConfig.IDGroup == idGroup)
  287. {
  288. return unLockSkills[i].skillConfig;
  289. }
  290. }
  291. return default;
  292. }
  293. protected void CalAttribute()
  294. {
  295. CalBasicAttribute();
  296. _attSpeed = (EncryptionFloat)(1.0f / modelConfig.speed_atk);
  297. // skillId = modelConfig.skillID;
  298. modelName = modelConfig.model;
  299. isGpu = modelConfig.isUseGpu;
  300. heroType = modelConfig.heroType;
  301. }
  302. protected void AddSkillAttribute(SkillConfig skillConfig)
  303. {
  304. if (skillConfig.addPropertyType == null)
  305. {
  306. return;
  307. }
  308. for (int i = 0; i < skillConfig.addPropertyType.Length; i++)
  309. {
  310. int propertyType = skillConfig.addPropertyType[i];
  311. float value = skillConfig.addPropertyValue[i];
  312. switch (propertyType)
  313. {
  314. case 101:
  315. AddAttributeValueToCache(AttributeType.Hp, value);
  316. break;
  317. case 102:
  318. AddAttributeValueToCache(AttributeType.Att, value);
  319. break;
  320. case 103:
  321. AddAttributeValueToCache(AttributeType.Def, value);
  322. break;
  323. }
  324. }
  325. }
  326. protected void SetDataConfig(int modelID, int level)
  327. {
  328. modelConfig = ConfigComponent.Instance.Get<HeroModelConfig>(modelID);
  329. if (isMonster)
  330. {
  331. MonsterPowerUpConfig = ConfigComponent.Instance.Get<MonsterPowerUpConfig>(level);
  332. }
  333. else
  334. {
  335. powerUpConfig = ConfigComponent.Instance.Get<HeroPowerUpConfig>(level);
  336. }
  337. this.level = (EncryptionInt)level;
  338. heroName = LanguageManager.Instance.Text(modelConfig.name);
  339. }
  340. public void InitMonster(int modelID, int level)
  341. {
  342. isMonster = true;
  343. SetDataConfig(modelID, level);
  344. CalAttribute();
  345. }
  346. public CombatHeroInfo Copy()
  347. {
  348. CombatHeroInfo combatHeroInfo = (CombatHeroInfo)MemberwiseClone();
  349. return combatHeroInfo;
  350. }
  351. }