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. //
  58. // int shuxingID = faBaoInfo.FabaoConfig.StarupShuxingIDs[i];
  59. // int shuxingValue = faBaoInfo.FabaoConfig.StarupShuxingValues[i];
  60. // ComputeHeroAttributeType(shuxingID, shuxingValue);
  61. }
  62. }
  63. ///功法加被动属性
  64. List<SkillInfo> allSkill = PlayerManager.Instance.GongFaControl.allSkill;
  65. foreach (var VARIABLE in attributeBlValue)
  66. {
  67. switch (VARIABLE.Key)
  68. {
  69. case HeroAttributeType.HP_BL:
  70. hp.Value += (long)(hp.Value * (VARIABLE.Value / 100f));
  71. break;
  72. case HeroAttributeType.ATT_BL:
  73. attack.Value += (long)(attack.Value * (VARIABLE.Value / 100f));
  74. break;
  75. case HeroAttributeType.DEF_BL:
  76. defense.Value += (long)(defense.Value * (VARIABLE.Value / 100f));
  77. break;
  78. case HeroAttributeType.ShengShi_BL:
  79. shenshi.Value += (long)(shenshi.Value * (VARIABLE.Value / 100f));
  80. break;
  81. }
  82. }
  83. }
  84. private void ComputeHeroAttributeType(int shuxingID, int value)
  85. {
  86. switch ((HeroAttributeType)shuxingID)
  87. {
  88. case HeroAttributeType.HP:
  89. hp.Value += value;
  90. break;
  91. case HeroAttributeType.ATT:
  92. attack.Value += value;
  93. break;
  94. case HeroAttributeType.DEF:
  95. defense.Value += value;
  96. break;
  97. case HeroAttributeType.Gold:
  98. Metal += value;
  99. break;
  100. case HeroAttributeType.Wood:
  101. Wood += value;
  102. break;
  103. case HeroAttributeType.Fire:
  104. Fire += value;
  105. break;
  106. case HeroAttributeType.Water:
  107. Water += value;
  108. break;
  109. case HeroAttributeType.Earth:
  110. Earth += value;
  111. break;
  112. case HeroAttributeType.Shields:
  113. Shield.Value += value;
  114. break;
  115. default:
  116. if (attributeBlValue.TryGetValue((HeroAttributeType)shuxingID, out var value1)
  117. )
  118. {
  119. attributeBlValue[(HeroAttributeType)shuxingID] = value1 + value;
  120. }
  121. else
  122. {
  123. attributeBlValue.Add((HeroAttributeType)shuxingID, value);
  124. }
  125. break;
  126. }
  127. }
  128. }
  129. }