| | |
| | | using System.Linq; |
| | | using UnityEngine; |
| | | using LitJson; |
| | | using Spine; |
| | | |
| | | |
| | | //!单英雄查看战力 只算自己的上阵属性 不算羁绊 总上阵属性 光环 |
| | | // 战力的计算方式 |
| | |
| | | Dictionary<string, double> propertyVariables = new Dictionary<string, double>(); |
| | | Dictionary<string, double> fightPowerVariables = new Dictionary<string, double>(); //总战力中的单武将战力 |
| | | |
| | | |
| | | int useFormulaType = 0; //公式调用方式0 代码 1公式 |
| | | public FightPowerManager() |
| | | { |
| | | // 数值1:基础三维属性计算公式 |
| | |
| | | |
| | | dropIndexCalc = dropindex; |
| | | #if UNITY_EDITOR |
| | | Debug.Log("战力:初始化参数 dropIndex:" + dropIndexCalc + " 阵型:" + teamTypeCalc + " ispreview:" + ispreview); |
| | | // Debug.Log("战力:初始化参数 dropIndex:" + dropIndexCalc + " 阵型:" + teamTypeCalc + " ispreview:" + ispreview); |
| | | #endif |
| | | } |
| | | #endregion |
| | |
| | | //等级属性 |
| | | void RefreshLVAttrs() |
| | | { |
| | | lvAttrs.Clear(); |
| | | // lvAttrs.Clear(); |
| | | var playerLVConfig = PlayerLVConfig.Get(PlayerDatas.Instance.baseData.LV); |
| | | foreach (var attrType in PlayerPropertyConfig.baseAttrs) |
| | | { |
| | | lvAttrs[attrType] = GetPlayerLVValue(playerLVConfig, attrType); |
| | | } |
| | | #if UNITY_EDITOR |
| | | Debug.Log("战力:等级属性 " + JsonMapper.ToJson(lvAttrs)); |
| | | // Debug.Log("战力:等级属性 " + JsonMapper.ToJson(lvAttrs)); |
| | | #endif |
| | | |
| | | } |
| | |
| | | //官职属性 |
| | | void RefreshOfficialAttrs() |
| | | { |
| | | officialAttrs.Clear(); |
| | | // officialAttrs.Clear(); |
| | | var config = RealmConfig.Get(PlayerDatas.Instance.baseData.realmLevel); |
| | | for (int i = 0; i < config.AddAttrType.Length; i++) |
| | | { |
| | |
| | | officialAttrs[id] = config.AddAttrNum[i]; |
| | | } |
| | | #if UNITY_EDITOR |
| | | Debug.Log("战力:官职属性 " + JsonMapper.ToJson(officialAttrs)); |
| | | // Debug.Log("战力:官职属性 " + JsonMapper.ToJson(officialAttrs)); |
| | | #endif |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | #if UNITY_EDITOR |
| | | Debug.Log("战力:装备属性 " + JsonMapper.ToJson(equipAttrs)); |
| | | // Debug.Log("战力:装备属性 " + JsonMapper.ToJson(equipAttrs)); |
| | | #endif |
| | | } |
| | | |
| | |
| | | lineUpPerDict = HeroUIManager.Instance.GetLineupPer(teamTypeCalc, isPreviewTeamPower); |
| | | |
| | | #if UNITY_EDITOR |
| | | Debug.Log("战力:上阵属性 " + JsonMapper.ToJson(lineUpPerDict)); |
| | | // Debug.Log("战力:上阵属性 " + JsonMapper.ToJson(lineUpPerDict)); |
| | | #endif |
| | | // 阵容:国家(光环)属性 |
| | | countryAttrs = HeroUIManager.Instance.GetCountryAttrs(teamTypeCalc, isPreviewTeamPower); |
| | | #if UNITY_EDITOR |
| | | Debug.Log("战力:国家(光环)属性 " + JsonMapper.ToJson(countryAttrs)); |
| | | // Debug.Log("战力:国家(光环)属性 " + JsonMapper.ToJson(countryAttrs)); |
| | | #endif |
| | | } |
| | | |
| | |
| | | // 单基础属性计算 |
| | | public double GetPropertyVaule(int attrType, HeroInfo hero, string formula) |
| | | { |
| | | propertyVariables.Clear(); |
| | | // propertyVariables.Clear(); |
| | | propertyVariables["lvValue"] = lvAttrs.ContainsKey(attrType) ? lvAttrs[attrType] : 0; |
| | | propertyVariables["equipValue"] = equipAttrs.ContainsKey(attrType) ? equipAttrs[attrType] : 0; |
| | | propertyVariables["bookValue"] = 0; |
| | |
| | | |
| | | #if UNITY_EDITOR |
| | | //排除值为0的属性输出 |
| | | var tmpPropertyVariables = propertyVariables.Where(x => x.Value > 0).ToDictionary(x => x.Key, x => x.Value); |
| | | if (!tmpPropertyVariables.IsNullOrEmpty()) |
| | | propertyStrForDebug += $"属性ID {attrType} - {JsonMapper.ToJson(tmpPropertyVariables)}"; |
| | | // var tmpPropertyVariables = propertyVariables.Where(x => x.Value > 0).ToDictionary(x => x.Key, x => x.Value); |
| | | // if (!tmpPropertyVariables.IsNullOrEmpty()) |
| | | // propertyStrForDebug += $"属性ID {attrType} - {JsonMapper.ToJson(tmpPropertyVariables)}"; |
| | | #endif |
| | | return JaceCalculator.Calculate(formula, propertyVariables); |
| | | } |
| | | |
| | | public double GetPropertyVaule(int attrType, HeroInfo hero, int type) |
| | | { |
| | | // propertyVariables.Clear(); |
| | | propertyVariables["lvValue"] = lvAttrs.ContainsKey(attrType) ? lvAttrs[attrType] : 0; |
| | | propertyVariables["equipValue"] = equipAttrs.ContainsKey(attrType) ? equipAttrs[attrType] : 0; |
| | | propertyVariables["bookValue"] = 0; |
| | | propertyVariables["bookPer"] = GetBookPer(attrType) / 10000.0f; |
| | | propertyVariables["realmValue"] = officialAttrs.ContainsKey(attrType) ? officialAttrs[attrType] : 0; |
| | | propertyVariables["realmPer"] = GetOfficialPer(attrType) / 10000.0f; |
| | | propertyVariables["gubaoValue"] = 0; |
| | | propertyVariables["gubaoPer"] = 0; |
| | | propertyVariables["hjgValue"] = 0; |
| | | propertyVariables["hjgPer"] = 0; |
| | | propertyVariables["horseValue"] = 0; |
| | | propertyVariables["horsePer"] = 0; |
| | | |
| | | //!!!单武将战力预览的话需要排除队伍影响战力,只算武将自身的上阵属性 |
| | | propertyVariables["lineupInitAddPer"] = GetLineUpPer(attrType, "lineupInitAddPer") / 10000.0f; |
| | | propertyVariables["lineupLVAddPer"] = GetLineUpPer(attrType, "lineupLVAddPer") / 10000.0f; |
| | | propertyVariables["lineupBreakLVAddPer"] = GetLineUpPer(attrType, "lineupBreakLVAddPer") / 10000.0f; |
| | | propertyVariables["lineupStarAddPer"] = GetLineUpPer(attrType, "lineupStarAddPer") / 10000.0f; |
| | | |
| | | //阵容光环 三围百分比加成 |
| | | propertyVariables["lineupHaloValue"] = countryAttrs.ContainsKey(attrType) ? countryAttrs[attrType] : 0; |
| | | propertyVariables["lineupHaloPer"] = GetCountryPer(attrType) / 10000.0f; |
| | | |
| | | |
| | | //武将属性 |
| | | propertyVariables["inheritPer"] = hero.GetInheritAttrPer(attrType) / 10000.0f; |
| | | propertyVariables["heroSelfValue"] = hero.GetSelfAddValue(attrType); |
| | | propertyVariables["heroSelfPer"] = hero.GetSelfAddPer(attrType) / 10000.0f; |
| | | propertyVariables["starTalentValue"] = hero.GetTalentAttrValue(attrType); |
| | | propertyVariables["starTalentPer"] = hero.GetTalentAttrPer(attrType) / 10000.0f; |
| | | propertyVariables["breakLVValue"] = hero.GetBreakAttrValue(attrType); |
| | | propertyVariables["breakLVPer"] = hero.GetBreakAttrPer(attrType) / 10000.0f; |
| | | propertyVariables["awakeTalentValue"] = hero.GetAwakeAttrValue(attrType); |
| | | propertyVariables["awakeTalentPer"] = hero.GetAwakeAttrPer(attrType) / 10000.0f; |
| | | propertyVariables["fetterValue"] = hero.GetFetterAttrValue(attrType); |
| | | propertyVariables["fetterPer"] = hero.GetFetterAttrPer(attrType) / 10000.0f; |
| | | |
| | | #if UNITY_EDITOR |
| | | //排除值为0的属性输出 |
| | | // var tmpPropertyVariables = propertyVariables.Where(x => x.Value > 0).ToDictionary(x => x.Key, x => x.Value); |
| | | // if (!tmpPropertyVariables.IsNullOrEmpty()) |
| | | // propertyStrForDebug += $"属性ID {attrType} - {JsonMapper.ToJson(tmpPropertyVariables)}"; |
| | | #endif |
| | | if (type == 0) |
| | | return FightPowerFormula.GetBaseAttr(propertyVariables); |
| | | else |
| | | return FightPowerFormula.GetFightAttr(propertyVariables); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | int GetLineUpPer(int attrType, string key) |
| | |
| | | public long CalculatePower() |
| | | { |
| | | #if UNITY_EDITOR |
| | | Debug.Log("战力:开始计算"); |
| | | // Debug.Log("战力:开始计算"); |
| | | #endif |
| | | // --- 先计算所有功能的汇总属性 --- |
| | | RefreshLVAttrs(); |
| | |
| | | } |
| | | |
| | | #if UNITY_EDITOR |
| | | Debug.Log("战力:计算完毕 " + fightPower); |
| | | // Debug.Log("战力:计算完毕 " + fightPower); |
| | | #endif |
| | | return fightPower; |
| | | } |
| | |
| | | } |
| | | if (config.showType == 1) |
| | | { |
| | | if (useFormulaType == 0) |
| | | fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, 0), 3); |
| | | else |
| | | fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, propertyFormula), 3); |
| | | } |
| | | else |
| | | { |
| | | if (useFormulaType == 0) |
| | | fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, 1), 3); |
| | | else |
| | | fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, fightPropertyFormula), 3); |
| | | } |
| | | } |
| | | |
| | | #if UNITY_EDITOR |
| | | Debug.Log($"战力:武将ID {hero.heroId} 属性信息 {propertyStrForDebug}"); |
| | | // Debug.Log($"战力:武将ID {hero.heroId} 属性信息 {propertyStrForDebug}"); |
| | | #endif |
| | | |
| | | //属性系数根据官职等级的加成 |
| | |
| | | fightPowerVariables["CurePerRatio"] = fightPowerRatioConfig.CurePerRatio; |
| | | fightPowerVariables["CurePerDefRatio"] = fightPowerRatioConfig.CurePerDefRatio; |
| | | |
| | | long fightPower; |
| | | if (useFormulaType == 0) |
| | | { |
| | | fightPower = (long)FightPowerFormula.GetFightPower(fightPowerVariables); |
| | | } |
| | | else |
| | | { |
| | | |
| | | long fightPower = (long)JaceCalculator.Calculate(fightPowerFormula, fightPowerVariables); |
| | | fightPower = (long)JaceCalculator.Calculate(fightPowerFormula, fightPowerVariables); |
| | | } |
| | | #if UNITY_EDITOR |
| | | //排除值为0的属性输出 |
| | | var tmpFightPowerVariables = fightPowerVariables.Where(x => x.Value > 0).ToDictionary(x => x.Key, x => x.Value); |
| | | if (!tmpFightPowerVariables.IsNullOrEmpty()) |
| | | Debug.Log($"战力:武将ID {hero.heroId} 属性战力 {fightPower} 属性战力参数 {JsonMapper.ToJson(tmpFightPowerVariables)}"); |
| | | // var tmpFightPowerVariables = fightPowerVariables.Where(x => x.Value > 0).ToDictionary(x => x.Key, x => x.Value); |
| | | // if (!tmpFightPowerVariables.IsNullOrEmpty()) |
| | | // Debug.Log($"战力:武将ID {hero.heroId} 属性战力 {fightPower} 属性战力参数 {JsonMapper.ToJson(tmpFightPowerVariables)}"); |
| | | #endif |
| | | |
| | | //加上技能战力 |
| | |
| | | fightPowerVariables["OfficialLV"] = PlayerDatas.Instance.baseData.realmLevel; |
| | | fightPowerVariables["SkillPower"] = hero.GetSkillsFightPower(); |
| | | |
| | | long skillPower = (long)JaceCalculator.Calculate(skillFightPowerFormula, fightPowerVariables); |
| | | long skillPower; |
| | | if (useFormulaType == 0) |
| | | { |
| | | skillPower = (long)FightPowerFormula.GetSkillsFightPower(fightPowerVariables); |
| | | } |
| | | else |
| | | { |
| | | skillPower = (long)JaceCalculator.Calculate(skillFightPowerFormula, fightPowerVariables); |
| | | } |
| | | |
| | | #if UNITY_EDITOR |
| | | Debug.Log($"战力:武将ID {hero.heroId} 技能战力 {skillPower} 技能参数 {JsonMapper.ToJson(fightPowerVariables)}"); |
| | | // Debug.Log($"战力:武将ID {hero.heroId} 技能战力 {skillPower} 技能参数 {JsonMapper.ToJson(fightPowerVariables)}"); |
| | | |
| | | Debug.Log($"战力:武将ID {hero.heroId} 总战力 {fightPower + skillPower}"); |
| | | // Debug.Log($"战力:武将ID {hero.heroId} 总战力 {fightPower + skillPower}"); |
| | | #endif |
| | | |
| | | return fightPower + skillPower; |
| | |
| | | } |
| | | if (config.showType == 1) |
| | | { |
| | | tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero, propertyFormula); |
| | | tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero, 0); |
| | | } |
| | | else |
| | | { |
| | | tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero, fightPropertyFormula); |
| | | tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero, 1); |
| | | } |
| | | } |
| | | #if UNITY_EDITOR |
| | | Debug.Log($"战力:武将ID {hero.heroId} 属性信息 {propertyStrForDebug}"); |
| | | // Debug.Log($"战力:武将ID {hero.heroId} 属性信息 {propertyStrForDebug}"); |
| | | #endif |
| | | return tmpAttrs; |
| | | } |