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