CombatHeroInfo.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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.Hero;
  8. using UnityEngine;
  9. using UnityEngine.Serialization;
  10. using Utility;
  11. [System.Serializable]
  12. public class CombatHeroInfo
  13. {
  14. public SkillData SkillData;
  15. public int modelID;
  16. public EncryptionLong hp = new EncryptionLong();
  17. public EncryptionLong defense = new EncryptionLong();
  18. public EncryptionLong attack = new EncryptionLong();
  19. /// <summary>
  20. /// 闪避 evasion
  21. /// </summary>
  22. public EncryptionInt shanbi = new EncryptionInt();
  23. /// <summary>
  24. /// 经验产出
  25. /// </summary>
  26. public EncryptionLong expGain = new EncryptionLong();
  27. public EncryptionFloat attSpeed = new EncryptionFloat();
  28. public EncryptionFloat crit =new EncryptionFloat();
  29. public EncryptionFloat critDamage =new EncryptionFloat();
  30. // public EncryptionFloat dodge = new EncryptionFloat();
  31. public EncryptionInt level;
  32. public EncryptionInt star;
  33. public HeroModelConfig modelConfig;
  34. public HeroPowerUpConfig powerUpConfig;
  35. public HeroPromoteConfig promoteConfig;
  36. public HeroBasicEquipConfig basicEquipConfig;
  37. /// <summary>
  38. /// 闪避 默认10%的几率
  39. /// </summary>
  40. public float dodge=10;
  41. /// <summary>
  42. /// 1=英雄 2=小怪 3=精英怪 4=boss
  43. /// </summary>
  44. public int heroType;
  45. public string modelName;
  46. public float maxDis=2;
  47. public float maxDisTo=2*2;
  48. public int[] skillId;
  49. public List<SkillConfig> skillConfigs;
  50. public bool isGpu;
  51. public string heroName;
  52. public CombatHeroInfo()
  53. {
  54. }
  55. // public CombatHeroInfo(AccountFileInfo.HeroData heroData)
  56. // {
  57. // modelConfig = ConfigComponent.Instance.Get<HeroModelConfig>(heroData.heroModelId);
  58. // promoteConfig = ConfigComponent.Instance.Get<HeroPromoteConfig>(heroData.heroPromoteId);
  59. // powerConfig = ConfigComponent.Instance.Get<HeroPowerConfig>(heroData.heroPowerId);
  60. // star = promoteConfig.starGrade;
  61. // lv = powerConfig.heroLevel;
  62. // }
  63. private float rarityFactor;
  64. private float starFactor;
  65. private float factor;
  66. /// <summary>
  67. /// 计算影响基础属性的参数
  68. /// (稀有度、星级)
  69. /// </summary>
  70. protected void CalFactor()
  71. {
  72. rarityFactor = PlayerManager.Instance.gameConstantConfig.monsterRarityAttributeFactor[modelConfig.rarity-1]
  73. / 100f;
  74. starFactor = promoteConfig.star_Power / 100f;
  75. factor = rarityFactor * starFactor;
  76. }
  77. protected void CalBasicAttribute()
  78. {
  79. hp = (EncryptionLong)(modelConfig.hp * powerUpConfig.HPFactor * factor);
  80. defense = (EncryptionLong)(modelConfig.def * powerUpConfig.DEFFactor * factor);
  81. attack = (EncryptionLong)(modelConfig.attack * powerUpConfig.ATKFactor * factor);
  82. shanbi = (EncryptionInt)(modelConfig.shanbi * powerUpConfig.SHANBIFactor * factor);
  83. expGain = (EncryptionLong)(modelConfig.expGain * powerUpConfig.EXPFactor * factor);
  84. }
  85. protected void CalAttribute()
  86. {
  87. CalBasicAttribute();
  88. attSpeed = (EncryptionFloat)modelConfig.speed_atk;
  89. crit = (EncryptionFloat)modelConfig.crit;
  90. skillId = modelConfig.skillID;
  91. modelName = modelConfig.model;
  92. isGpu = modelConfig.isUseGpu;
  93. maxDis = modelConfig.range_atk;
  94. maxDisTo = maxDis * maxDis;
  95. heroType = modelConfig.heroType;
  96. }
  97. protected void SetDataConfig(int modelID,int level, int star)
  98. {
  99. modelConfig = ConfigComponent.Instance.Get<HeroModelConfig>(modelID);
  100. powerUpConfig = ConfigComponent.Instance.Get<HeroPowerUpConfig>(level);
  101. promoteConfig = ConfigComponent.Instance.Get<HeroPromoteConfig>(star);
  102. this.level = (EncryptionInt)level;
  103. this.star = (EncryptionInt)star;
  104. heroName = LanguageManager.Instance.Text(modelConfig.name);
  105. }
  106. public void InitMonster(int modelID,int level, int star = 1)
  107. {
  108. SetDataConfig(modelID, level, star);
  109. CalFactor();
  110. CalAttribute();
  111. SkillData = new SkillData(this);
  112. SkillData.InitSkills();
  113. }
  114. // public void InitMonster(int id,int level)
  115. // {
  116. // HeroModelConfig heroModelConfig = ConfigComponent.Instance.Get<HeroModelConfig>(id);
  117. // HeroPowerUpConfig heroPowerUpConfig = ConfigComponent.Instance.Get<HeroPowerUpConfig>(level);
  118. // hp = (EncryptionLong)(heroModelConfig.hp*heroPowerUpConfig.HPFactor);
  119. // defense=(EncryptionLong)(heroModelConfig.def*heroPowerUpConfig.DEFFactor);
  120. // attack=(EncryptionLong)(heroModelConfig.attack*heroPowerUpConfig.ATKFactor);
  121. // attSpeed=(EncryptionFloat)heroModelConfig.speed_atk;
  122. // crit=(EncryptionFloat)heroModelConfig.crit;
  123. // skillId = heroModelConfig.skillID;
  124. // modelName = heroModelConfig.model;
  125. // isGpu = heroModelConfig.isUseGpu;
  126. // maxDis=heroModelConfig.range_atk;
  127. // maxDisTo = maxDis * maxDis;
  128. // }
  129. public CombatHeroInfo Copy()
  130. {
  131. CombatHeroInfo combatHeroInfo = (CombatHeroInfo)MemberwiseClone();
  132. return combatHeroInfo;
  133. }
  134. }