CombatHeroInfo.cs 4.8 KB

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