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