using System.Collections.Generic; using System.Linq; using Common.Utility.CombatEvent; using Core.Utility; using Excel2Json; using Fort23.Core; using Fort23.UTool; using GameLogic.Combat.CombatTool; using Utility; namespace GameLogic.Hero { public class DaoLVBiData { public int id; public float value; } public class HeroInfo : CombatHeroInfo { public AccountFileInfo.HeroData heroData; private string _iconZhiYe; private Map attributeBlValue = new Map(); public Map daolvBlMap = new Map(); public List daolvBl = new List(); // public List ImmortalBond = new List(); private Map attributeValue = new Map(); public HeroInfo() { } public HeroInfo CopyHero() { AccountFileInfo.HeroData heroDataCopy = new AccountFileInfo.HeroData(); heroDataCopy.heroModelId = heroData.heroModelId; heroDataCopy.heroPowerId = heroData.heroPowerId; heroDataCopy.exp = heroData.exp; heroDataCopy.upTime = heroData.upTime; heroDataCopy.isCombat = heroData.isCombat; heroDataCopy.TaoismSkillId = heroData.TaoismSkillId; heroDataCopy.ImmortalBond = heroData.ImmortalBond.ToList(); HeroInfo heroInfo = new HeroInfo(); heroInfo.MagicWeaponID = MagicWeaponID.ToList(); heroInfo.unLockSkills = unLockSkills.ToList(); heroInfo.InitHero(heroData); return 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); float 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); RedDotManager.Instance.AllRedDotUpDate(); return this; } public void GetDaoLvBl() { daolvBl.Clear(); foreach (var i in heroData?.ImmortalBond) { DaoyouModelConfig daoyouModelConfig = ConfigComponent.Instance.Get(i); foreach (var i1 in daoyouModelConfig.daolvSkillID) { daolvSkill daolvSkill = ConfigComponent.Instance.Get(i1); // //唯一只加一次 // if (daolvSkill.type == 1) // { // if (!daolvBlMap.ContainsKey(i1)) // { // daolvBlMap.Add(i1, daolvSkill.para[0]); // } // } // else // { // if (!daolvBlMap.ContainsKey(i1)) // { // daolvBlMap.Add(i1, daolvSkill.para[0]); // } // else // { // daolvBlMap[i1] += daolvSkill.para[0]; // } // } DaoLVBiData daoLvBiData; if (daolvSkill.type == 1) { daoLvBiData = daolvBl.FirstOrDefault(d => d.id == i1); if (daoLvBiData != null) { daoLvBiData = new DaoLVBiData(); daoLvBiData.id = i1; daoLvBiData.value = daolvSkill.para[0]; daolvBl.Add(daoLvBiData); } } else { daoLvBiData = new DaoLVBiData(); daoLvBiData.id = i1; daoLvBiData.value = daolvSkill.para[0]; daolvBl.Add(daoLvBiData); // if (!daolvBlMap.ContainsKey(i1)) // { // daolvBlMap.Add(i1, daolvSkill.para[0]); // } // else // { // daolvBlMap[i1] += daolvSkill.para[0]; // } } } } } public void ComputeHeroInfo() { attributeValue.Clear(); attributeBlValue.Clear(); Metal = 100; Wood = 100; Water = 100; Fire = 100; Earth = 100; CalAttribute(); GetDaoLvBl(); 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) { ComputeHeroAttributeType((int)VARIABLE.Key, VARIABLE.Value); } } //道侣带来的属性加成 foreach (var keyValuePair in daolvBlMap) { daolvSkill daolvSkill = ConfigComponent.Instance.Get(keyValuePair.Key); ComputeHeroAttributeType(daolvSkill.AttrID, keyValuePair.Value); } //心境带来的加成 AddSentimentData(); if (CombatController.currActiveCombat != null && CombatController.currActiveCombat.playerHeroEntity != null) { CombatController.currActiveCombat.playerHeroEntity.CurrCombatHeroInfo = this.Copy(); CombatController.currActiveCombat.playerHeroEntity.MaxCombatHeroInfo = this.Copy(); } AddAttributeValue(); } private void AddSentimentData() { SentimentEffectConfig[] allSentimentEffectConfigs = ConfigComponent.Instance.GetAll(); List SentimentDatas = AccountFileInfo.Instance.playerData.SentimentDatas; for (int i = 0; i < SentimentDatas.Count; i++) { AccountFileInfo.SentimentData sentimentData = SentimentDatas[i]; for (int j = 0; j < sentimentData.sentimentProperties.Count; j++) { AddSentimentProperty(sentimentData.sentimentProperties[i], allSentimentEffectConfigs); } } } private void AddSentimentProperty(AccountFileInfo.SentimentProperty sentimentProperty, SentimentEffectConfig[] allSentimentEffectConfigs) { SentimentEffectConfig currSentimentEffectConfig = default; for (int i = 0; i < allSentimentEffectConfigs.Length; i++) { SentimentEffectConfig sentimentEffectConfig = allSentimentEffectConfigs[i]; if (sentimentEffectConfig.groupId == sentimentProperty.groupId && sentimentEffectConfig.level == sentimentProperty.level) { currSentimentEffectConfig = sentimentEffectConfig; } } switch (currSentimentEffectConfig.effectType) { case 1: attack += (EncryptionLong)(attack.Value * currSentimentEffectConfig.effectVale[0] * 0.01f); break; case 2: gongFaStrength += currSentimentEffectConfig.effectVale[0]; break; case 3: hp += (EncryptionLong)(hp.Value * currSentimentEffectConfig.effectVale[0] * 0.01f); break; case 4: defense += (EncryptionLong)(defense.Value * currSentimentEffectConfig.effectVale[0] * 0.01f); break; case 5: int type = currSentimentEffectConfig.effectVale[0]; switch ((HeroAttributeType)type) { case HeroAttributeType.Gold: Metal += currSentimentEffectConfig.effectVale[1]; break; case HeroAttributeType.Wood: Wood += currSentimentEffectConfig.effectVale[1]; break; case HeroAttributeType.Fire: Fire += currSentimentEffectConfig.effectVale[1]; break; case HeroAttributeType.Water: Water += currSentimentEffectConfig.effectVale[1]; break; case HeroAttributeType.Earth: Earth += currSentimentEffectConfig.effectVale[1]; break; } break; case 6: finallyHarmReduce = currSentimentEffectConfig.effectVale[0]; break; case 7: abnormalHarmAdd = currSentimentEffectConfig.effectVale[0]; break; case 8: Fire_Proficient = currSentimentEffectConfig.effectVale[0]; break; case 9: Wood_Proficient = currSentimentEffectConfig.effectVale[0]; break; case 10: Metal_Proficient = currSentimentEffectConfig.effectVale[0]; break; case 11: Water_Proficient = currSentimentEffectConfig.effectVale[0]; break; case 12: Earth_Proficient = currSentimentEffectConfig.effectVale[0]; break; case 99: // Fire_HarmAdd= currSentimentEffectConfig.effectVale[0]; break; } } private void AddAttributeValue() { for (attributeValue.Begin(); attributeValue.Next();) { HeroAttributeType heroAttributeType = attributeValue.Key; float value = attributeValue.Value; switch (heroAttributeType) { 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.HP_BL: hp.Value += (long)(hp.Value * (value / 100f)); break; case HeroAttributeType.ATT_BL: attack.Value += (long)(attack.Value * (value / 100f)); break; case HeroAttributeType.DEF_BL: defense.Value += (long)(defense.Value * (value / 100f)); break; case HeroAttributeType.ShengShi_BL: shenshi.Value += (long)(shenshi.Value * (value / 100f)); 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; } } attributeValue.Clear(); } private void ComputeHeroAttributeType(int shuxingID, float value) { HeroAttributeType heroAttributeType = (HeroAttributeType)shuxingID; if (attributeValue.TryGetValue(heroAttributeType, out float oldValue)) { attributeValue[heroAttributeType] = oldValue + value; } else { attributeValue.Add(heroAttributeType, value); } // attributeValue.Add((HeroAttributeType)shuxingID,); } } }