CombatHeroInfo.cs 5.0 KB

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