HeroInfo.cs 4.7 KB

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