123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- using System.Collections.Generic;
- using Common.Utility.CombatEvent;
- using Excel2Json;
- using Fort23.Core;
- using Fort23.UTool;
- using GameLogic.Combat.CombatTool;
- using Utility;
- namespace GameLogic.Hero
- {
- public class HeroInfo : CombatHeroInfo
- {
- public AccountFileInfo.HeroData heroData;
- private string _iconZhiYe;
- private Map<HeroAttributeType, float> attributeBlValue = new Map<HeroAttributeType, float>();
- public HeroInfo()
- {
- }
- public void InitHero(AccountFileInfo.HeroData heroData)
- {
- this.heroData = heroData;
- InitHero(heroData.heroModelId, heroData.heroPowerId);
- }
- public void InitHero(int modelID, int powerID)
- {
- this.modelID = modelID;
- SetDataConfig(modelID,
- powerID);
- ComputeHeroInfo();
- CalBasicAttribute();
- }
- public HeroInfo Upgrade()
- {
- int currentMiao = (int)((TimeHelper.ClientNow() - PlayerManager.Instance.myHero.heroData.upTime) / 1000);
- int allexp = currentMiao * PlayerManager.Instance.myHero.powerUpConfig.AutoXiuwei;
- heroData.exp += allexp;
- heroData.exp -= powerUpConfig.levelUpExp;
- heroData.upTime = TimeHelper.ClientNow();
- heroData.isCombat = false;
- heroData.heroPowerId++;
- InitHero(heroData);
- PlayerManager.Instance.SaveHeroData(this);
- EventManager.Instance.Dispatch(CustomEventType.JingJieUpgrade,null);
- return this;
- }
- public void ComputeHeroInfo()
- {
- attributeBlValue.Clear();
- CalAttribute();
-
- if (!PlayerManager.Instance.isTest)
- {
- List<FaBaoInfo> myAllFaBao = PlayerManager.Instance.FaBaoControl.myAllFaBao;
- foreach (var faBaoInfo in myAllFaBao)
- {
- if (faBaoInfo.SkillConfig.addPropertyType != null)
- {
- for (int i = 0; i < faBaoInfo.SkillConfig.addPropertyType.Length; i++)
- {
- int shuxingID = faBaoInfo.SkillConfig.addPropertyType[i];
- float shuxingValue = faBaoInfo.SkillConfig.addPropertyValue[i];
- ComputeHeroAttributeType(shuxingID, shuxingValue);
- }
- }
- }
- ///功法加被动属性
- List<SkillInfo> allSkill = PlayerManager.Instance.GongFaControl.allSkill;
- for (int j = 0; j < allSkill.Count; j++)
- {
- SkillInfo skillInfo = allSkill[j];
- if (skillInfo.skillConfig.addPropertyType != null)
- {
- for (int i = 0; i < skillInfo.skillConfig.addPropertyType.Length; i++)
- {
- int shuxingID = skillInfo.skillConfig.addPropertyType[i];
- float shuxingValue = skillInfo.skillConfig.addPropertyValue[i];
- ComputeHeroAttributeType(shuxingID, shuxingValue);
- }
- }
- }
- foreach (var VARIABLE in attributeBlValue)
- {
- switch (VARIABLE.Key)
- {
- case HeroAttributeType.HP_BL:
- hp.Value += (long)(hp.Value * (VARIABLE.Value / 100f));
- break;
- case HeroAttributeType.ATT_BL:
- attack.Value += (long)(attack.Value * (VARIABLE.Value / 100f));
- break;
- case HeroAttributeType.DEF_BL:
- defense.Value += (long)(defense.Value * (VARIABLE.Value / 100f));
- break;
- case HeroAttributeType.ShengShi_BL:
- shenshi.Value += (long)(shenshi.Value * (VARIABLE.Value / 100f));
- break;
- }
- }
- }
- if (CombatController.currActiveCombat != null && CombatController.currActiveCombat.playerHeroEntity != null)
- {
- CombatController.currActiveCombat.playerHeroEntity.CurrCombatHeroInfo = this.Copy();
- CombatController.currActiveCombat.playerHeroEntity.MaxCombatHeroInfo = this.Copy();
- }
- }
- private void ComputeHeroAttributeType(int shuxingID, float value)
- {
- switch ((HeroAttributeType)shuxingID)
- {
- case HeroAttributeType.HP:
- hp.Value += (int)value;
- break;
- case HeroAttributeType.ATT:
- attack.Value += (int)value;
- break;
- case HeroAttributeType.DEF:
- defense.Value += (int)value;
- break;
- case HeroAttributeType.Gold:
- Metal += value;
- break;
- case HeroAttributeType.Wood:
- Wood += value;
- break;
- case HeroAttributeType.Fire:
- Fire += value;
- break;
- case HeroAttributeType.Water:
- Water += value;
- break;
- case HeroAttributeType.Earth:
- Earth += value;
- break;
- case HeroAttributeType.Shields:
- Shield.Value += (int)value;
- break;
- default:
- if (attributeBlValue.TryGetValue((HeroAttributeType)shuxingID, out var value1)
- )
- {
- attributeBlValue[(HeroAttributeType)shuxingID] = value1 + value;
- }
- else
- {
- attributeBlValue.Add((HeroAttributeType)shuxingID, value);
- }
- break;
- }
- }
- }
- }
|