CombatHeroInfo.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. /// 1=英雄 2=小怪 3=精英怪 4=boss
  34. /// </summary>
  35. public int heroType;
  36. public string modelName;
  37. public bool isMonster;
  38. // public int[] skillId;
  39. // public List<SkillConfig> skillConfigs;
  40. /// <summary>
  41. /// 所有已解锁技能的ID
  42. /// </summary>
  43. public List<int> unLockSkills;
  44. public bool isGpu;
  45. public string heroName;
  46. public List<int> MagicWeaponID;
  47. public CombatHeroInfo()
  48. {
  49. }
  50. protected Map<AttributeType, int> _AttributeCacheValue = new Map<AttributeType, int>();
  51. public void AddAttributeValueToCache(AttributeType attributeType, int value)
  52. {
  53. if (_AttributeCacheValue.TryGetValue(attributeType, out int v))
  54. {
  55. value += v;
  56. }
  57. _AttributeCacheValue[attributeType] = value;
  58. }
  59. protected void CalBasicAttribute()
  60. {
  61. _AttributeCacheValue.Clear();
  62. if (isMonster)
  63. {
  64. hp = (EncryptionLong)(modelConfig.hp * MonsterPowerUpConfig.HPFactor );
  65. defense = (EncryptionLong)(modelConfig.def * MonsterPowerUpConfig.DEFFactor );
  66. attack = (EncryptionLong)(modelConfig.attack * MonsterPowerUpConfig.ATKFactor );
  67. }
  68. else
  69. {
  70. hp = (EncryptionLong)(modelConfig.hp * powerUpConfig.HPFactor );
  71. defense = (EncryptionLong)(modelConfig.def * powerUpConfig.DEFFactor );
  72. attack = (EncryptionLong)(modelConfig.attack * powerUpConfig.ATKFactor );
  73. //职业装备提供的属性
  74. hp += PlayerManager.Instance.eqController.zyEqAddAttributeDic[modelConfig.profession].hp;
  75. defense += PlayerManager.Instance.eqController.zyEqAddAttributeDic[modelConfig.profession].def;
  76. attack += PlayerManager.Instance.eqController.zyEqAddAttributeDic[modelConfig.profession].atk;
  77. }
  78. CalUnLockSkill();
  79. for (_AttributeCacheValue.Begin(); _AttributeCacheValue.Next();)
  80. {
  81. switch (_AttributeCacheValue.Key)
  82. {
  83. case AttributeType.Hp:
  84. hp += CombatCalculateTool.Instance.GetVlaueRatioForLong(hp.Value, _AttributeCacheValue.Value);
  85. break;
  86. case AttributeType.Att:
  87. attack += CombatCalculateTool.Instance.GetVlaueRatioForLong(attack.Value,
  88. _AttributeCacheValue.Value);
  89. break;
  90. case AttributeType.Def:
  91. defense += CombatCalculateTool.Instance.GetVlaueRatioForLong(defense.Value,
  92. _AttributeCacheValue.Value);
  93. break;
  94. }
  95. }
  96. }
  97. public SkillConfig GetGroupSkillConfig(int idGroup)
  98. {
  99. if (unLockSkills == null)
  100. {
  101. return default;
  102. }
  103. for (int i = 0; i < unLockSkills.Count; i++)
  104. {
  105. SkillConfig skillConfig = ConfigComponent.Instance.Get<SkillConfig>(unLockSkills[i]);
  106. if (skillConfig.IDGroup == idGroup)
  107. {
  108. return skillConfig;
  109. }
  110. }
  111. return default;
  112. }
  113. protected void CalAttribute()
  114. {
  115. CalBasicAttribute();
  116. attSpeed = (EncryptionFloat)modelConfig.speed_atk;
  117. // skillId = modelConfig.skillID;
  118. modelName = modelConfig.model;
  119. isGpu = modelConfig.isUseGpu;
  120. heroType = modelConfig.heroType;
  121. }
  122. /// <summary>
  123. /// 计算解锁技能
  124. /// </summary>
  125. public void CalUnLockSkill()
  126. {
  127. unLockSkills = new List<int>();
  128. }
  129. protected void AddSkillAttribute(SkillConfig skillConfig)
  130. {
  131. if (skillConfig.addPropertyType == null)
  132. {
  133. return;
  134. }
  135. for (int i = 0; i < skillConfig.addPropertyType.Length; i++)
  136. {
  137. int propertyType = skillConfig.addPropertyType[i];
  138. int value = skillConfig.addPropertyValue[i];
  139. switch (propertyType)
  140. {
  141. case 1:
  142. AddAttributeValueToCache(AttributeType.Hp, value);
  143. break;
  144. case 2:
  145. AddAttributeValueToCache(AttributeType.Att, value);
  146. break;
  147. case 3:
  148. AddAttributeValueToCache(AttributeType.Def, value);
  149. break;
  150. }
  151. }
  152. }
  153. protected void SetDataConfig(int modelID, int level, int star)
  154. {
  155. modelConfig = ConfigComponent.Instance.Get<HeroModelConfig>(modelID);
  156. if (isMonster)
  157. {
  158. MonsterPowerUpConfig = ConfigComponent.Instance.Get<MonsterPowerUpConfig>(level);
  159. }
  160. else
  161. {
  162. powerUpConfig = ConfigComponent.Instance.Get<HeroPowerUpConfig>(level);
  163. }
  164. promoteConfig = ConfigComponent.Instance.Get<HeroPromoteConfig>(star);
  165. this.level = (EncryptionInt)level;
  166. heroName = LanguageManager.Instance.Text(modelConfig.name);
  167. }
  168. public void InitMonster(int modelID, int level, int star = 1)
  169. {
  170. isMonster = true;
  171. SetDataConfig(modelID, level, star);
  172. CalAttribute();
  173. }
  174. public CombatHeroInfo Copy()
  175. {
  176. CombatHeroInfo combatHeroInfo = (CombatHeroInfo)MemberwiseClone();
  177. return combatHeroInfo;
  178. }
  179. }