HeroInfo.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. using System.Collections.Generic;
  2. using Common.Utility.CombatEvent;
  3. using Excel2Json;
  4. using Fort23.Core;
  5. using Fort23.UTool;
  6. using GameLogic.Combat.CombatTool;
  7. using Utility;
  8. namespace GameLogic.Hero
  9. {
  10. public class HeroInfo : CombatHeroInfo
  11. {
  12. public AccountFileInfo.HeroData heroData;
  13. private string _iconZhiYe;
  14. private Map<HeroAttributeType, float> attributeBlValue = new Map<HeroAttributeType, float>();
  15. public HeroInfo()
  16. {
  17. }
  18. public void InitHero(AccountFileInfo.HeroData heroData)
  19. {
  20. this.heroData = heroData;
  21. InitHero(heroData.heroModelId, heroData.heroPowerId);
  22. }
  23. public void InitHero(int modelID, int powerID)
  24. {
  25. this.modelID = modelID;
  26. SetDataConfig(modelID,
  27. powerID);
  28. ComputeHeroInfo();
  29. CalBasicAttribute();
  30. }
  31. public HeroInfo Upgrade()
  32. {
  33. int currentMiao = (int)((TimeHelper.ClientNow() - PlayerManager.Instance.myHero.heroData.upTime) / 1000);
  34. int allexp = currentMiao * PlayerManager.Instance.myHero.powerUpConfig.AutoXiuwei;
  35. heroData.exp += allexp;
  36. heroData.exp -= powerUpConfig.levelUpExp;
  37. heroData.upTime = TimeHelper.ClientNow();
  38. heroData.isCombat = false;
  39. heroData.heroPowerId++;
  40. InitHero(heroData);
  41. PlayerManager.Instance.SaveHeroData(this);
  42. return this;
  43. }
  44. public void ComputeHeroInfo()
  45. {
  46. attributeBlValue.Clear();
  47. CalAttribute();
  48. List<FaBaoInfo> myAllFaBao = PlayerManager.Instance.FaBaoControl.myAllFaBao;
  49. foreach (var faBaoInfo in myAllFaBao)
  50. {
  51. if (faBaoInfo.SkillConfig.addPropertyType != null)
  52. {
  53. for (int i = 0; i < faBaoInfo.SkillConfig.addPropertyType.Length; i++)
  54. {
  55. int shuxingID = faBaoInfo.SkillConfig.addPropertyType[i];
  56. float shuxingValue = faBaoInfo.SkillConfig.addPropertyValue[i];
  57. ComputeHeroAttributeType(shuxingID, shuxingValue);
  58. }
  59. }
  60. }
  61. ///功法加被动属性
  62. List<SkillInfo> allSkill = PlayerManager.Instance.GongFaControl.allSkill;
  63. for (int j = 0; j < allSkill.Count; j++)
  64. {
  65. SkillInfo skillInfo = allSkill[j];
  66. if (skillInfo.skillConfig.addPropertyType != null)
  67. {
  68. for (int i = 0; i < skillInfo.skillConfig.addPropertyType.Length; i++)
  69. {
  70. int shuxingID = skillInfo.skillConfig.addPropertyType[i];
  71. float shuxingValue = skillInfo.skillConfig.addPropertyValue[i];
  72. ComputeHeroAttributeType(shuxingID, shuxingValue);
  73. }
  74. }
  75. }
  76. foreach (var VARIABLE in attributeBlValue)
  77. {
  78. switch (VARIABLE.Key)
  79. {
  80. case HeroAttributeType.HP_BL:
  81. hp.Value += (long)(hp.Value * (VARIABLE.Value / 100f));
  82. break;
  83. case HeroAttributeType.ATT_BL:
  84. attack.Value += (long)(attack.Value * (VARIABLE.Value / 100f));
  85. break;
  86. case HeroAttributeType.DEF_BL:
  87. defense.Value += (long)(defense.Value * (VARIABLE.Value / 100f));
  88. break;
  89. case HeroAttributeType.ShengShi_BL:
  90. shenshi.Value += (long)(shenshi.Value * (VARIABLE.Value / 100f));
  91. break;
  92. }
  93. }
  94. if (CombatController.currActiveCombat != null && CombatController.currActiveCombat.playerHeroEntity != null)
  95. {
  96. CombatController.currActiveCombat.playerHeroEntity.CurrCombatHeroInfo = this.Copy();
  97. CombatController.currActiveCombat.playerHeroEntity.MaxCombatHeroInfo = this.Copy();
  98. }
  99. }
  100. private void ComputeHeroAttributeType(int shuxingID, float value)
  101. {
  102. switch ((HeroAttributeType)shuxingID)
  103. {
  104. case HeroAttributeType.HP:
  105. hp.Value += (int)value;
  106. break;
  107. case HeroAttributeType.ATT:
  108. attack.Value += (int)value;
  109. break;
  110. case HeroAttributeType.DEF:
  111. defense.Value += (int)value;
  112. break;
  113. case HeroAttributeType.Gold:
  114. Metal += value;
  115. break;
  116. case HeroAttributeType.Wood:
  117. Wood += value;
  118. break;
  119. case HeroAttributeType.Fire:
  120. Fire += value;
  121. break;
  122. case HeroAttributeType.Water:
  123. Water += value;
  124. break;
  125. case HeroAttributeType.Earth:
  126. Earth += value;
  127. break;
  128. case HeroAttributeType.Shields:
  129. Shield.Value += (int)value;
  130. break;
  131. default:
  132. if (attributeBlValue.TryGetValue((HeroAttributeType)shuxingID, out var value1)
  133. )
  134. {
  135. attributeBlValue[(HeroAttributeType)shuxingID] = value1 + value;
  136. }
  137. else
  138. {
  139. attributeBlValue.Add((HeroAttributeType)shuxingID, value);
  140. }
  141. break;
  142. }
  143. }
  144. }
  145. }