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