HeroInfo.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. EventManager.Instance.Dispatch(CustomEventType.JingJieUpgrade,null);
  43. return this;
  44. }
  45. public void ComputeHeroInfo()
  46. {
  47. attributeBlValue.Clear();
  48. CalAttribute();
  49. if (!PlayerManager.Instance.isTest)
  50. {
  51. List<FaBaoInfo> myAllFaBao = PlayerManager.Instance.FaBaoControl.myAllFaBao;
  52. foreach (var faBaoInfo in myAllFaBao)
  53. {
  54. if (faBaoInfo.SkillConfig.addPropertyType != null)
  55. {
  56. for (int i = 0; i < faBaoInfo.SkillConfig.addPropertyType.Length; i++)
  57. {
  58. int shuxingID = faBaoInfo.SkillConfig.addPropertyType[i];
  59. float shuxingValue = faBaoInfo.SkillConfig.addPropertyValue[i];
  60. ComputeHeroAttributeType(shuxingID, shuxingValue);
  61. }
  62. }
  63. }
  64. ///功法加被动属性
  65. List<SkillInfo> allSkill = PlayerManager.Instance.GongFaControl.allSkill;
  66. for (int j = 0; j < allSkill.Count; j++)
  67. {
  68. SkillInfo skillInfo = allSkill[j];
  69. if (skillInfo.skillConfig.addPropertyType != null)
  70. {
  71. for (int i = 0; i < skillInfo.skillConfig.addPropertyType.Length; i++)
  72. {
  73. int shuxingID = skillInfo.skillConfig.addPropertyType[i];
  74. float shuxingValue = skillInfo.skillConfig.addPropertyValue[i];
  75. ComputeHeroAttributeType(shuxingID, shuxingValue);
  76. }
  77. }
  78. }
  79. foreach (var VARIABLE in attributeBlValue)
  80. {
  81. switch (VARIABLE.Key)
  82. {
  83. case HeroAttributeType.HP_BL:
  84. hp.Value += (long)(hp.Value * (VARIABLE.Value / 100f));
  85. break;
  86. case HeroAttributeType.ATT_BL:
  87. attack.Value += (long)(attack.Value * (VARIABLE.Value / 100f));
  88. break;
  89. case HeroAttributeType.DEF_BL:
  90. defense.Value += (long)(defense.Value * (VARIABLE.Value / 100f));
  91. break;
  92. case HeroAttributeType.ShengShi_BL:
  93. shenshi.Value += (long)(shenshi.Value * (VARIABLE.Value / 100f));
  94. break;
  95. }
  96. }
  97. }
  98. if (CombatController.currActiveCombat != null && CombatController.currActiveCombat.playerHeroEntity != null)
  99. {
  100. CombatController.currActiveCombat.playerHeroEntity.CurrCombatHeroInfo = this.Copy();
  101. CombatController.currActiveCombat.playerHeroEntity.MaxCombatHeroInfo = this.Copy();
  102. }
  103. }
  104. private void ComputeHeroAttributeType(int shuxingID, float value)
  105. {
  106. switch ((HeroAttributeType)shuxingID)
  107. {
  108. case HeroAttributeType.HP:
  109. hp.Value += (int)value;
  110. break;
  111. case HeroAttributeType.ATT:
  112. attack.Value += (int)value;
  113. break;
  114. case HeroAttributeType.DEF:
  115. defense.Value += (int)value;
  116. break;
  117. case HeroAttributeType.Gold:
  118. Metal += value;
  119. break;
  120. case HeroAttributeType.Wood:
  121. Wood += value;
  122. break;
  123. case HeroAttributeType.Fire:
  124. Fire += value;
  125. break;
  126. case HeroAttributeType.Water:
  127. Water += value;
  128. break;
  129. case HeroAttributeType.Earth:
  130. Earth += value;
  131. break;
  132. case HeroAttributeType.Shields:
  133. Shield.Value += (int)value;
  134. break;
  135. default:
  136. if (attributeBlValue.TryGetValue((HeroAttributeType)shuxingID, out var value1)
  137. )
  138. {
  139. attributeBlValue[(HeroAttributeType)shuxingID] = value1 + value;
  140. }
  141. else
  142. {
  143. attributeBlValue.Add((HeroAttributeType)shuxingID, value);
  144. }
  145. break;
  146. }
  147. }
  148. }
  149. }