CombatHeroInfo.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. /// 1=英雄 2=小怪 3=精英怪 4=boss
  37. /// </summary>
  38. public int heroType;
  39. public string modelName;
  40. public float maxDis=2;
  41. public float maxDisTo=2*2;
  42. public int[] skillId;
  43. public bool isGpu;
  44. public string heroName;
  45. public CombatHeroInfo()
  46. {
  47. }
  48. // public CombatHeroInfo(AccountFileInfo.HeroData heroData)
  49. // {
  50. // modelConfig = ConfigComponent.Instance.Get<HeroModelConfig>(heroData.heroModelId);
  51. // promoteConfig = ConfigComponent.Instance.Get<HeroPromoteConfig>(heroData.heroPromoteId);
  52. // powerConfig = ConfigComponent.Instance.Get<HeroPowerConfig>(heroData.heroPowerId);
  53. // star = promoteConfig.starGrade;
  54. // lv = powerConfig.heroLevel;
  55. // }
  56. private float rarityFactor;
  57. private float starFactor;
  58. private float factor;
  59. /// <summary>
  60. /// 计算影响基础属性的参数
  61. /// (稀有度、星级)
  62. /// </summary>
  63. protected void CalFactor()
  64. {
  65. rarityFactor = PlayerManager.Instance.gameConstantConfig.monsterRarityAttributeFactor[modelConfig.rarity-1]
  66. / 100f;
  67. starFactor = promoteConfig.star_Power / 100f;
  68. factor = rarityFactor * starFactor;
  69. }
  70. protected void CalBasicAttribute()
  71. {
  72. hp = (EncryptionLong)(modelConfig.hp * powerUpConfig.HPFactor * factor);
  73. defense = (EncryptionLong)(modelConfig.def * powerUpConfig.DEFFactor * factor);
  74. attack = (EncryptionLong)(modelConfig.attack * powerUpConfig.ATKFactor * factor);
  75. shanbi = (EncryptionInt)(modelConfig.shanbi * powerUpConfig.SHANBIFactor * factor);
  76. expGain = (EncryptionLong)(modelConfig.expGain * powerUpConfig.EXPFactor * factor);
  77. }
  78. protected void CalAttribute()
  79. {
  80. CalBasicAttribute();
  81. attSpeed = (EncryptionFloat)modelConfig.speed_atk;
  82. crit = (EncryptionFloat)modelConfig.crit;
  83. skillId = modelConfig.skillID;
  84. modelName = modelConfig.model;
  85. isGpu = modelConfig.isUseGpu;
  86. maxDis = modelConfig.range_atk;
  87. maxDisTo = maxDis * maxDis;
  88. heroType = modelConfig.heroType;
  89. }
  90. protected void SetDataConfig(int modelID,int level, int star)
  91. {
  92. modelConfig = ConfigComponent.Instance.Get<HeroModelConfig>(modelID);
  93. powerUpConfig = ConfigComponent.Instance.Get<HeroPowerUpConfig>(level);
  94. promoteConfig = ConfigComponent.Instance.Get<HeroPromoteConfig>(star);
  95. this.level = (EncryptionInt)level;
  96. this.star = (EncryptionInt)star;
  97. heroName = LanguageManager.Instance.Text(modelConfig.name);
  98. }
  99. public void InitMonster(int modelID,int level, int star = 1)
  100. {
  101. SetDataConfig(modelID, level, star);
  102. CalFactor();
  103. CalAttribute();
  104. }
  105. // public void InitMonster(int id,int level)
  106. // {
  107. // HeroModelConfig heroModelConfig = ConfigComponent.Instance.Get<HeroModelConfig>(id);
  108. // HeroPowerUpConfig heroPowerUpConfig = ConfigComponent.Instance.Get<HeroPowerUpConfig>(level);
  109. // hp = (EncryptionLong)(heroModelConfig.hp*heroPowerUpConfig.HPFactor);
  110. // defense=(EncryptionLong)(heroModelConfig.def*heroPowerUpConfig.DEFFactor);
  111. // attack=(EncryptionLong)(heroModelConfig.attack*heroPowerUpConfig.ATKFactor);
  112. // attSpeed=(EncryptionFloat)heroModelConfig.speed_atk;
  113. // crit=(EncryptionFloat)heroModelConfig.crit;
  114. // skillId = heroModelConfig.skillID;
  115. // modelName = heroModelConfig.model;
  116. // isGpu = heroModelConfig.isUseGpu;
  117. // maxDis=heroModelConfig.range_atk;
  118. // maxDisTo = maxDis * maxDis;
  119. // }
  120. public CombatHeroInfo Copy()
  121. {
  122. CombatHeroInfo combatHeroInfo = (CombatHeroInfo)MemberwiseClone();
  123. return combatHeroInfo;
  124. }
  125. }