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 attributeBlValue = new Map(); 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 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 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; } } } }