HeroInfo.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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.isCombat = false;
  38. heroData.heroPowerId++;
  39. InitHero(heroData);
  40. PlayerManager.Instance.SaveHeroData(this);
  41. return this;
  42. }
  43. public void ComputeHeroInfo()
  44. {
  45. attributeBlValue.Clear();
  46. CalAttribute();
  47. List<FaBaoInfo> myAllFaBao = PlayerManager.Instance.FaBaoControl.myAllFaBao;
  48. foreach (var faBaoInfo in myAllFaBao)
  49. {
  50. int star = faBaoInfo.star;
  51. for (int i = 0; i < star; i++)
  52. {
  53. if (faBaoInfo.FabaoConfig.StarupShuxingIDs.Length <= i)
  54. {
  55. break;
  56. }
  57. int shuxingID = faBaoInfo.FabaoConfig.StarupShuxingIDs[i];
  58. int shuxingValue = faBaoInfo.FabaoConfig.StarupShuxingValues[i];
  59. ComputeHeroAttributeType(shuxingID, shuxingValue);
  60. }
  61. }
  62. ///功法加被动属性
  63. List<SkillInfo> allSkill = PlayerManager.Instance.GongFaControl.allSkill;
  64. foreach (var VARIABLE in attributeBlValue)
  65. {
  66. switch (VARIABLE.Key)
  67. {
  68. case HeroAttributeType.HP_BL:
  69. hp.Value += (long)(hp.Value * (VARIABLE.Value / 100f));
  70. break;
  71. case HeroAttributeType.ATT_BL:
  72. attack.Value += (long)(attack.Value * (VARIABLE.Value / 100f));
  73. break;
  74. case HeroAttributeType.DEF_BL:
  75. defense.Value += (long)(defense.Value * (VARIABLE.Value / 100f));
  76. break;
  77. case HeroAttributeType.ShengShi_BL:
  78. shenshi.Value += (long)(shenshi.Value * (VARIABLE.Value / 100f));
  79. break;
  80. }
  81. }
  82. }
  83. private void ComputeHeroAttributeType(int shuxingID, int value)
  84. {
  85. switch ((HeroAttributeType)shuxingID)
  86. {
  87. case HeroAttributeType.HP:
  88. hp.Value += value;
  89. break;
  90. case HeroAttributeType.ATT:
  91. attack.Value += value;
  92. break;
  93. case HeroAttributeType.DEF:
  94. defense.Value += value;
  95. break;
  96. case HeroAttributeType.Gold:
  97. Metal += value;
  98. break;
  99. case HeroAttributeType.Wood:
  100. Wood += value;
  101. break;
  102. case HeroAttributeType.Fire:
  103. Fire += value;
  104. break;
  105. case HeroAttributeType.Water:
  106. Water += value;
  107. break;
  108. case HeroAttributeType.Earth:
  109. Earth += value;
  110. break;
  111. case HeroAttributeType.Shields:
  112. Shield.Value += value;
  113. break;
  114. default:
  115. if (attributeBlValue.TryGetValue((HeroAttributeType)shuxingID, out var value1)
  116. )
  117. {
  118. attributeBlValue[(HeroAttributeType)shuxingID] = value1 + value;
  119. }
  120. else
  121. {
  122. attributeBlValue.Add((HeroAttributeType)shuxingID, value);
  123. }
  124. break;
  125. }
  126. }
  127. }
  128. }