| | |
| | | using System; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using UnityEngine; |
| | | using LitJson; |
| | | using Spine; |
| | | |
| | | |
| | | //!单英雄查看战力 只算自己的上阵属性 不算羁绊 总上阵属性 光环 |
| | | // 战力的计算方式 |
| | |
| | | // 所有武将战力加起来 + 技能战力汇总(公式)就是整个号的战力 |
| | | public class FightPowerManager : Singleton<FightPowerManager> |
| | | { |
| | | public string propertyFormula; |
| | | public string fightPropertyFormula; |
| | | public string fightPowerFormula; |
| | | public string skillFightPowerFormula; |
| | | |
| | | Dictionary<string, double> propertyVariables = new Dictionary<string, double>(); |
| | | Dictionary<string, double> fightPowerVariables = new Dictionary<string, double>(); //总战力中的单武将战力 |
| | | |
| | | |
| | | public FightPowerManager() |
| | | { |
| | | // 数值1:基础三维属性计算公式 |
| | | // 数值2:战斗属性/战斗抗性/特殊属性计算公式 |
| | | // 数值3:属性战力计算公式,计算参数详见 S.属性条目配置 |
| | | var config = FuncConfigConfig.Get("HeroAttrFormula"); |
| | | propertyFormula = config.Numerical1; |
| | | fightPropertyFormula = config.Numerical2; |
| | | fightPowerFormula = config.Numerical3; |
| | | skillFightPowerFormula = config.Numerical4; |
| | | JaceCalculator.Init(); |
| | | } |
| | | |
| | | public long lastFightPower = 0; //上一次的服务端战力,用于重置是否重新计算武将百分比 羁绊等,没有变化则减少计算 |
| | | public long lastMinggeSkillPower = 0; |
| | | |
| | | #region 初始化战力计算的信息 |
| | | TeamType teamTypeCalc = TeamType.Story; //不同阵容战力不同 |
| | | int teamTypeCalc = 1; //不同阵容战力不同 |
| | | bool isPreviewTeamPower; //预览阵容(队伍)战力 |
| | | int dropIndexCalc = -1; //掉落装备在阵容的索引,用于预览战力对比 |
| | | int minggePresetID; //命格预设ID |
| | | int minggeDropIndex; //掉落命格在背包的索引 ,用于预览战力对比 |
| | | |
| | | //计算阵容战力,装备对比等情况需要代入 |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="teamType">阵容类型</param> |
| | | /// <param name="teamType">阵容类型:方案ID下的队伍</param> |
| | | /// <param name="dropindex">掉落装备的索引,-1代表不替换计算</param> |
| | | /// <param name="ispreview">预览阵容战力</param> |
| | | public void InitFightPowerParam(TeamType teamType = TeamType.Story, int dropindex = -1, bool ispreview = false) |
| | | public void InitFightPowerParam(int teamType = 0, int dropindex = -1, bool ispreview = false, |
| | | int _minggePresetID = 0, int _minggeDropIndex = -1) |
| | | { |
| | | #if !UNITY_EDITOR |
| | | openLog = false; |
| | | #endif |
| | | if (teamType == 0) |
| | | { |
| | | // 没有设置默认使用主阵容 |
| | | teamType = TeamManager.Instance.GetMainTeamID(); |
| | | } |
| | | if (_minggePresetID == 0) |
| | | { |
| | | // 没有设置默认当前流派下命格方案 |
| | | _minggePresetID = FuncPresetManager.Instance.GetFuncPresetID((int)FuncPresetType.Mingge); |
| | | } |
| | | teamTypeCalc = teamType; |
| | | minggePresetID = _minggePresetID; |
| | | isPreviewTeamPower = ispreview; |
| | | |
| | | dropIndexCalc = dropindex; |
| | | minggeDropIndex = _minggeDropIndex; |
| | | #if UNITY_EDITOR |
| | | Debug.Log("战力:初始化参数 dropIndex:" + dropIndexCalc + " 阵型:" + teamTypeCalc + " ispreview:" + ispreview); |
| | | if (openLog) |
| | | { |
| | | FightPowerDebug("战力:初始化参数 dropIndex:" + dropIndexCalc + " 阵型:" + teamTypeCalc + " ispreview:" + ispreview |
| | | + " minggePresetID:" + _minggePresetID + " minggeDropIndex:" + _minggeDropIndex); |
| | | } |
| | | #endif |
| | | } |
| | | #endregion |
| | |
| | | #region 先计算所有功能的汇总属性 |
| | | |
| | | //功能属性 类型:值 |
| | | public Dictionary<int, int> lvAttrs = new Dictionary<int, int>(); //等级属性 |
| | | public Dictionary<int, int> officialAttrs = new Dictionary<int, int>(); //官职属性 |
| | | public Dictionary<int, long> lvAttrs = new Dictionary<int, long>(); //等级属性 |
| | | public Dictionary<int, long> officialAttrs = new Dictionary<int, long>(); //官职属性 |
| | | |
| | | //分开存储预览和 真实属性 |
| | | public Dictionary<int, int> equipAttrs = new Dictionary<int, int>(); //装备属性 |
| | | public Dictionary<string, int> lineUpPerDict = new Dictionary<string, int>(); //阵容属性加成 |
| | | public Dictionary<int, long> equipAttrs = new Dictionary<int, long>(); //装备属性 |
| | | // public Dictionary<string, int> lineUpPerDict = new Dictionary<string, int>(); //阵容属性加成 |
| | | public Dictionary<int, int> countryAttrs = new Dictionary<int, int>(); //阵容国家(光环)属性 |
| | | public Dictionary<int, long> minggeAttrs = new Dictionary<int, long>(); //命格属性 |
| | | |
| | | double allHeroAddPer = 0; //所有武将加成 |
| | | |
| | | //等级属性 |
| | | void RefreshLVAttrs() |
| | |
| | | lvAttrs[attrType] = GetPlayerLVValue(playerLVConfig, attrType); |
| | | } |
| | | #if UNITY_EDITOR |
| | | Debug.Log("战力:等级属性 " + JsonMapper.ToJson(lvAttrs)); |
| | | |
| | | if (openLog) |
| | | { |
| | | FightPowerDebug("战力:等级属性 " + JsonMapper.ToJson(lvAttrs)); |
| | | FightPowerDebug("战力:红颜属性 " + JsonMapper.ToJson(BeautyMMManager.Instance.allMMTalentAttr)); |
| | | FightPowerDebug("战力:古宝属性 " + JsonMapper.ToJson(GubaoManager.Instance.gubaoAllAttrDict)); |
| | | } |
| | | #endif |
| | | |
| | | } |
| | |
| | | officialAttrs[id] = config.AddAttrNum[i]; |
| | | } |
| | | #if UNITY_EDITOR |
| | | Debug.Log("战力:官职属性 " + JsonMapper.ToJson(officialAttrs)); |
| | | if (openLog) |
| | | { |
| | | FightPowerDebug("战力:官职属性 " + JsonMapper.ToJson(officialAttrs)); |
| | | } |
| | | #endif |
| | | |
| | | } |
| | |
| | | void RefrehEquipAttrs() |
| | | { |
| | | equipAttrs.Clear(); //身上装备属性重置 |
| | | ItemModel dropEquip = null; |
| | | if (dropIndexCalc != -1) |
| | | { |
| | | dropEquip = PackManager.Instance.GetItemByIndex(PackType.DropItem, dropIndexCalc); |
| | | } |
| | | |
| | | for (int i = 0; i < EquipModel.TotleEquip; i++) |
| | | { |
| | | var equip = EquipModel.Instance.GetEquip(i); |
| | | if (dropIndexCalc != -1) |
| | | { |
| | | var dropEquip = PackManager.Instance.GetItemByIndex(PackType.DropItem, dropIndexCalc); |
| | | if (dropEquip.config.EquipPlace - 1 == i) |
| | | if (dropEquip != null && dropEquip.config.EquipPlace - 1 == i) |
| | | { |
| | | equip = dropEquip; //替换计算总战力 |
| | | } |
| | |
| | | } |
| | | |
| | | #if UNITY_EDITOR |
| | | Debug.Log("战力:装备属性 " + JsonMapper.ToJson(equipAttrs)); |
| | | if (openLog) |
| | | { |
| | | FightPowerDebug("战力:装备属性 " + JsonMapper.ToJson(equipAttrs)); |
| | | } |
| | | #endif |
| | | } |
| | | |
| | |
| | | { |
| | | //阵容属性 |
| | | // 阵容:所有武将上阵属性 |
| | | lineUpPerDict = HeroUIManager.Instance.GetLineupPer(teamTypeCalc, isPreviewTeamPower); |
| | | // lineUpPerDict = HeroUIManager.Instance.GetLineupPer(teamTypeCalc, isPreviewTeamPower); |
| | | allHeroAddPer = HeroUIManager.Instance.GetAllHeroPer() / 10000.0; |
| | | |
| | | #if UNITY_EDITOR |
| | | Debug.Log("战力:上阵属性 " + JsonMapper.ToJson(lineUpPerDict)); |
| | | #endif |
| | | // 阵容:国家(光环)属性 |
| | | countryAttrs = HeroUIManager.Instance.GetCountryAttrs(teamTypeCalc, isPreviewTeamPower); |
| | | #if UNITY_EDITOR |
| | | Debug.Log("战力:国家(光环)属性 " + JsonMapper.ToJson(countryAttrs)); |
| | | if (openLog) |
| | | { |
| | | FightPowerDebug("战力:国家(光环)属性 " + JsonMapper.ToJson(countryAttrs)); |
| | | FightPowerDebug("战力:武将所有加成 " + allHeroAddPer); |
| | | } |
| | | #endif |
| | | } |
| | | |
| | | //类似装备需要实时替换对比;功能处查看重算一次显示 |
| | | void RefrehMinggeAttrs() |
| | | { |
| | | minggeAttrs.Clear(); //身上命格属性重置 |
| | | ItemModel dropEquip = null; |
| | | int packIndex = -1; |
| | | if (minggeDropIndex != -1) |
| | | { |
| | | dropEquip = PackManager.Instance.GetItemByIndex(PackType.MinggeDrop, minggeDropIndex); |
| | | packIndex = MinggeManager.Instance.GetPackIndex(minggePresetID, dropEquip.config.EquipPlace); |
| | | } |
| | | |
| | | var starIndex = (minggePresetID - 1) * MinggeManager.TotleEquip; |
| | | |
| | | for (int i = starIndex; i < starIndex + MinggeManager.TotleEquip; i++) |
| | | { |
| | | var equip = PackManager.Instance.GetItemByIndex(PackType.Mingge, i); |
| | | if (minggeDropIndex != -1) |
| | | { |
| | | if (dropEquip != null && packIndex == i) |
| | | { |
| | | equip = dropEquip; //替换计算总战力 |
| | | } |
| | | } |
| | | if (equip == null) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | var fightIDAttrs = EquipModel.Instance.GetEquipFightAttrs(equip); |
| | | var fightValueAttrs = EquipModel.Instance.GetEquipFightValues(equip); |
| | | if (fightIDAttrs != null) |
| | | { |
| | | for (int j = 0; j < fightIDAttrs.Count; j++) |
| | | { |
| | | if (!minggeAttrs.ContainsKey(fightIDAttrs[j])) |
| | | { |
| | | minggeAttrs[fightIDAttrs[j]] = fightValueAttrs[j]; |
| | | } |
| | | else |
| | | { |
| | | minggeAttrs[fightIDAttrs[j]] += fightValueAttrs[j]; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | #if UNITY_EDITOR |
| | | if (openLog) |
| | | { |
| | | FightPowerDebug("战力:命格属性 " + JsonMapper.ToJson(minggeAttrs)); |
| | | } |
| | | #endif |
| | | } |
| | | |
| | | |
| | | public int GetAttrPer(int attrID, Dictionary<int, long> attrDic) |
| | | { |
| | | if (attrID == 6 || attrID == 7 || attrID == 8) |
| | | { |
| | | var pertype = attrID + 10; |
| | | attrDic.TryGetValue(pertype, out long value); |
| | | return (int)(value); |
| | | } |
| | | return 0; |
| | | |
| | | } |
| | | |
| | | #endregion |
| | |
| | | |
| | | #region 属性公式 |
| | | // 单基础属性计算 |
| | | public double GetPropertyVaule(int attrType, HeroInfo hero, string formula) |
| | | public double GetPropertyVaule(int attrType, HeroInfo hero) |
| | | { |
| | | 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.Clear(); |
| | | |
| | | //!!!单武将战力预览的话需要排除队伍影响战力,只算武将自身的上阵属性 |
| | | 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; |
| | | lvAttrs.TryGetValue(attrType, out var lvValue); |
| | | equipAttrs.TryGetValue(attrType, out var equipValue); |
| | | officialAttrs.TryGetValue(attrType, out var realmValue); |
| | | var realmPer = GetAttrPer(attrType, officialAttrs) / 10000.0; |
| | | var gubaoValue = GubaoManager.Instance.GetAttrValue(attrType); |
| | | var gubaoPer = GubaoManager.Instance.GetAttrPer(attrType) / 10000.0; |
| | | var hjgValue = PhantasmPavilionManager.Instance.GetAttrValue(attrType); |
| | | var hjgPer = PhantasmPavilionManager.Instance.GetAttrPer(attrType) / 10000.0; |
| | | var horseValue = HorseManager.Instance.GetAttrValue(attrType); |
| | | var horsePer = HorseManager.Instance.GetAttrPer(attrType) / 10000.0; |
| | | var beautyValue = BeautyMMManager.Instance.GetAttrValue(attrType); |
| | | var beautyPer = BeautyMMManager.Instance.GetAttrPer(attrType) / 10000.0; |
| | | var fatesValue = HeroFatesManager.Instance.GetAttrValue(attrType); |
| | | var fatesPer = HeroFatesManager.Instance.GetAttrPer(attrType) / 10000.0; |
| | | var dingjungeValue = 0; //默认不需要加,爬塔特殊用,配合公式 |
| | | var dingjungePer = 0; //默认不需要加,爬塔特殊用,配合公式 |
| | | minggeAttrs.TryGetValue(attrType, out var minggeValue); |
| | | var minggePer = GetAttrPer(attrType, minggeAttrs) / 10000.0; |
| | | |
| | | //全体卡牌加成 |
| | | double cardPer = 0; |
| | | if (attrType == 6 || attrType == 7 || attrType == 8) |
| | | { |
| | | cardPer = allHeroAddPer; |
| | | } |
| | | |
| | | //阵容光环 三围百分比加成 |
| | | propertyVariables["lineupHaloValue"] = countryAttrs.ContainsKey(attrType) ? countryAttrs[attrType] : 0; |
| | | propertyVariables["lineupHaloPer"] = GetCountryPer(attrType) / 10000.0f; |
| | | |
| | | var lineupHaloPer = GetCountryPer(attrType) / 10000.0; |
| | | |
| | | //武将属性 |
| | | 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; |
| | | var inheritPer = hero.GetInheritAttrPer(attrType) / 10000.0; |
| | | var heroSelfValue = hero.GetSelfAddValue(attrType); |
| | | var starTalentPer = hero.GetTalentAttrPer(attrType) / 10000.0; |
| | | var breakLVPer = hero.GetBreakAttrPer(attrType) / 10000.0; |
| | | var awakeTalentPer = hero.GetAwakeAttrPer(attrType) / 10000.0; |
| | | var fetterPer = hero.GetFetterAttrPer(attrType) / 10000.0; |
| | | var heroLVValue = hero.GetHeroLVValue(attrType); |
| | | |
| | | //武将皮肤 |
| | | var skinValue = HeroUIManager.Instance.GetSkinAttrValue(attrType); |
| | | var skinPer = HeroUIManager.Instance.GetSkinAttrPer(attrType) / 10000.0; |
| | | var heroSkinValue = hero.GetHeroSkinValue(attrType); |
| | | |
| | | |
| | | double value = (lvValue+equipValue+realmValue+gubaoValue+hjgValue+horseValue+beautyValue+fatesValue+skinValue+dingjungeValue+minggeValue)*(1+lineupHaloPer+realmPer+gubaoPer+hjgPer+horsePer+beautyPer+fatesPer+skinPer+cardPer+minggePer)*(inheritPer+fetterPer+starTalentPer+breakLVPer+awakeTalentPer)*(1+dingjungePer)+heroSelfValue+heroLVValue+heroSkinValue; |
| | | |
| | | //保留2位小数 |
| | | value = Math.Round(value, 2); |
| | | |
| | | #if UNITY_EDITOR |
| | | //排除值为0的属性输出 |
| | | // var tmpPropertyVariables = propertyVariables.Where(x => x.Value > 0).ToDictionary(x => x.Key, x => x.Value); |
| | | // if (!tmpPropertyVariables.IsNullOrEmpty()) |
| | | // { |
| | | // FightPowerDebug($"战力:武将ID {hero.heroId} 属性ID {attrType} 值 {value} - {JsonMapper.ToJson(tmpPropertyVariables)}"); |
| | | // } |
| | | #endif |
| | | return value; |
| | | } |
| | | |
| | | |
| | | public double GetFighttPropertyVaule(int attrType, HeroInfo hero) |
| | | { |
| | | lvAttrs.TryGetValue(attrType, out var lvValue); |
| | | equipAttrs.TryGetValue(attrType, out var equipValue); |
| | | officialAttrs.TryGetValue(attrType, out var realmValue); |
| | | var gubaoValue = GubaoManager.Instance.GetAttrValue(attrType); |
| | | var hjgValue = PhantasmPavilionManager.Instance.GetAttrValue(attrType); |
| | | var horseValue = HorseManager.Instance.GetAttrValue(attrType); |
| | | var beautyValue = BeautyMMManager.Instance.GetAttrValue(attrType); |
| | | var fatesValue = HeroFatesManager.Instance.GetAttrValue(attrType); |
| | | var dingjungeValue = 0; //默认不需要加,爬塔特殊用,配合公式 |
| | | minggeAttrs.TryGetValue(attrType, out var minggeValue); |
| | | |
| | | //阵容光环 三围百分比加成 |
| | | countryAttrs.TryGetValue(attrType, out var lineupHaloValue); |
| | | |
| | | //武将属性 |
| | | var heroSelfValue = hero.GetSelfAddValue(attrType); |
| | | var starTalentValue = hero.GetTalentAttrValue(attrType); |
| | | var breakLVValue = hero.GetBreakAttrValue(attrType); |
| | | var awakeTalentValue = hero.GetAwakeAttrValue(attrType); |
| | | var fetterValue = hero.GetFetterAttrValue(attrType); |
| | | |
| | | //武将皮肤 |
| | | var heroSkinValue = hero.GetHeroSkinValue(attrType); |
| | | |
| | | double value = (lvValue+equipValue+realmValue+gubaoValue+hjgValue+horseValue+beautyValue+fatesValue+dingjungeValue+minggeValue)+(heroSelfValue+heroSkinValue+lineupHaloValue+starTalentValue+breakLVValue+awakeTalentValue)+fetterValue; |
| | | |
| | | //保留2位小数 |
| | | value = Math.Round(value, 2); |
| | | |
| | | #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()) |
| | | // { |
| | | // FightPowerDebug($"战力:武将ID {hero.heroId} 属性ID {attrType} 值 {value} - {JsonMapper.ToJson(tmpPropertyVariables)}"); |
| | | // } |
| | | #endif |
| | | return JaceCalculator.Calculate(formula, propertyVariables); |
| | | return value; |
| | | } |
| | | |
| | | // int GetLineUpPer(int attrType, string key) |
| | | // { |
| | | // if (!PlayerPropertyConfig.baseAttrs.Contains(attrType)) |
| | | // { |
| | | // return 0; |
| | | // } |
| | | |
| | | int GetLineUpPer(int attrType, string key) |
| | | { |
| | | if (!PlayerPropertyConfig.baseAttrs.Contains(attrType)) |
| | | { |
| | | return 0; |
| | | } |
| | | // return lineUpPerDict[key]; |
| | | // } |
| | | |
| | | return lineUpPerDict[key]; |
| | | } |
| | | // int GetBookPer(int attrType) |
| | | // { |
| | | // if (!PlayerPropertyConfig.baseAttrs.Contains(attrType)) |
| | | // { |
| | | // return 0; |
| | | // } |
| | | // return HeroUIManager.Instance.allHeroBookPer; |
| | | // } |
| | | |
| | | int GetBookPer(int attrType) |
| | | { |
| | | if (!PlayerPropertyConfig.baseAttrs.Contains(attrType)) |
| | | { |
| | | return 0; |
| | | } |
| | | return HeroUIManager.Instance.allHeroBookPer; |
| | | } |
| | | |
| | | int GetOfficialPer(int attrType) |
| | | { |
| | | if (PlayerPropertyConfig.baseAttr2perDict.ContainsKey(attrType)) |
| | | { |
| | | var pertype = PlayerPropertyConfig.baseAttr2perDict[attrType]; |
| | | return officialAttrs.ContainsKey(pertype) ? officialAttrs[pertype] : 0; |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | //PlayerPropertyConfig.baseAttr2perDict 频繁调用字典效率差 |
| | | int GetCountryPer(int attrType) |
| | | { |
| | | if (PlayerPropertyConfig.baseAttr2perDict.ContainsKey(attrType)) |
| | | if (attrType == 6 || attrType == 7 || attrType == 8) |
| | | { |
| | | var pertype = PlayerPropertyConfig.baseAttr2perDict[attrType]; |
| | | return countryAttrs.ContainsKey(pertype) ? countryAttrs[pertype] : 0; |
| | | var pertype = attrType + 10; |
| | | countryAttrs.TryGetValue(pertype, out var value); |
| | | return value; |
| | | } |
| | | |
| | | return 0; |
| | |
| | | //装备战力为最终总战力的结果比(提升整个角色总战力) |
| | | |
| | | //计算总战力中的武将战力,几个武将加起来就是总战力,其他功能属性计算应该涵盖在英雄里 |
| | | public long CalculatePower() |
| | | // calcType 计算战力缘由 0 武将 1 装备 2命格,用于节省部分开销 |
| | | public long CalculatePower(int calcType) |
| | | { |
| | | |
| | | #if UNITY_EDITOR |
| | | Debug.Log("战力:开始计算"); |
| | | if (openLog) |
| | | { |
| | | FightPowerDebug("战力:开始计算"); |
| | | } |
| | | #endif |
| | | // --- 先计算所有功能的汇总属性 --- |
| | | RefreshLVAttrs(); |
| | | RefreshOfficialAttrs(); |
| | | RefrehEquipAttrs(); |
| | | RefreshTeamAttrs(); |
| | | RefrehMinggeAttrs(); |
| | | |
| | | bool diffFP = lastFightPower != PlayerDatas.Instance.baseData.FightPower; //战力是否有变化 |
| | | if (diffFP || calcType == 0) |
| | | { |
| | | lastFightPower = PlayerDatas.Instance.baseData.FightPower; |
| | | RefreshTeamAttrs(); |
| | | } |
| | | |
| | | // --- 算单武将功能属性战力 后相加--- |
| | | long fightPower = 0; |
| | |
| | | |
| | | } |
| | | |
| | | if (diffFP || calcType == 2) |
| | | { |
| | | lastMinggeSkillPower = GetMinggeSkillPower(); |
| | | } |
| | | |
| | | fightPower += lastMinggeSkillPower; |
| | | #if UNITY_EDITOR |
| | | Debug.Log("战力:计算完毕 " + fightPower); |
| | | if (openLog) |
| | | { |
| | | FightPowerDebug("命格技能战力 " + lastMinggeSkillPower); |
| | | FightPowerDebug("战力:计算完毕 " + fightPower); |
| | | } |
| | | #endif |
| | | return fightPower; |
| | | } |
| | | |
| | | #if UNITY_EDITOR |
| | | string propertyStrForDebug = ""; |
| | | #endif |
| | | |
| | | |
| | | //计算阵容中武将战力 |
| | | public long CalculateTeamHeroPower(HeroInfo hero) |
| | | { |
| | | |
| | | fightPowerVariables.Clear(); |
| | | hero.RefreshFetterAttrsWhenCalcPower(teamTypeCalc); //羁绊属性要实时算 |
| | | |
| | | #if UNITY_EDITOR |
| | | propertyStrForDebug = ""; |
| | | #endif |
| | | foreach (var config in PlayerPropertyConfig.GetValues()) |
| | | { |
| | | if (config.showType < 1 || config.showType > 4) |
| | | { |
| | | continue; |
| | | } |
| | | if (config.showType == 1) |
| | | { |
| | | fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, propertyFormula), 3); |
| | | } |
| | | else |
| | | { |
| | | fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, fightPropertyFormula), 3); |
| | | } |
| | | } |
| | | var Atk = GetPropertyVaule(6, hero); |
| | | var Def = GetPropertyVaule(7, hero); |
| | | var MaxHP = GetPropertyVaule(8, hero); |
| | | var AtkSpeed = GetFighttPropertyVaule(11, hero); |
| | | var StunRate = GetFighttPropertyVaule(21, hero); |
| | | var StunRateDef = GetFighttPropertyVaule(22, hero); |
| | | var SuperHitRate = GetFighttPropertyVaule(23, hero); |
| | | var SuperHitRateDef = GetFighttPropertyVaule(24, hero); |
| | | var ComboRate = GetFighttPropertyVaule(25, hero); |
| | | var ComboRateDef = GetFighttPropertyVaule(26, hero); |
| | | var MissRate = GetFighttPropertyVaule(27, hero); |
| | | var MissRateDef = GetFighttPropertyVaule(28, hero); |
| | | var ParryRate = GetFighttPropertyVaule(29, hero); |
| | | var ParryRateDef = GetFighttPropertyVaule(30, hero); |
| | | var SuckHPPer = GetFighttPropertyVaule(31, hero); |
| | | var SuckHPPerDef = GetFighttPropertyVaule(32, hero); |
| | | |
| | | #if UNITY_EDITOR |
| | | Debug.Log($"战力:武将ID {hero.heroId} 属性信息 {propertyStrForDebug}"); |
| | | #endif |
| | | var FinalDamPer = GetFighttPropertyVaule(35, hero); |
| | | var FinalDamPerDef = GetFighttPropertyVaule(36, hero); |
| | | var PhyDamPer = GetFighttPropertyVaule(37, hero); |
| | | var PhyDamPerDef = GetFighttPropertyVaule(38, hero); |
| | | var MagDamPer = GetFighttPropertyVaule(39, hero); |
| | | var MagDamPerDef = GetFighttPropertyVaule(40, hero); |
| | | var NormalSkillPer = GetFighttPropertyVaule(41, hero); |
| | | var NormalSkillPerDef = GetFighttPropertyVaule(42, hero); |
| | | var AngerSkillPer = GetFighttPropertyVaule(43, hero); |
| | | var AngerSkillPerDef = GetFighttPropertyVaule(44, hero); |
| | | var SuperDamPer = GetFighttPropertyVaule(45, hero); |
| | | var SuperDamPerDef = GetFighttPropertyVaule(46, hero); |
| | | |
| | | var CurePer = GetFighttPropertyVaule(51, hero); |
| | | var CurePerDef = GetFighttPropertyVaule(52, hero); |
| | | var ShieldPer = GetFighttPropertyVaule(53, hero); |
| | | var ShieldPerDef = GetFighttPropertyVaule(54, hero); |
| | | var DOTPer = GetFighttPropertyVaule(55, hero); |
| | | var DOTPerDef = GetFighttPropertyVaule(56, hero); |
| | | var WeiFinalDamPer = GetFighttPropertyVaule(57, hero); |
| | | var WeiFinalDamPerDef = GetFighttPropertyVaule(58, hero); |
| | | var ShuFinalDamPer = GetFighttPropertyVaule(59, hero); |
| | | var ShuFinalDamPerDef = GetFighttPropertyVaule(60, hero); |
| | | var WuFinalDamPer = GetFighttPropertyVaule(61, hero); |
| | | var WuFinalDamPerDef = GetFighttPropertyVaule(62, hero); |
| | | var QunFinalDamPer = GetFighttPropertyVaule(63, hero); |
| | | var QunFinalDamPerDef = GetFighttPropertyVaule(64, hero); |
| | | |
| | | var PVPDamPer = GetFighttPropertyVaule(71, hero); |
| | | var PVPDamPerDef = GetFighttPropertyVaule(72, hero); |
| | | var Guanchuan = GetFighttPropertyVaule(77, hero); |
| | | var GuanchuanDef = GetFighttPropertyVaule(78, hero); |
| | | var Zhaojia = GetFighttPropertyVaule(79, hero); |
| | | var ZhaojiaDef = GetFighttPropertyVaule(80, hero); |
| | | |
| | | |
| | | //属性系数根据官职等级的加成 |
| | | var fightPowerRatioConfig = FightPowerRatioConfig.Get(PlayerDatas.Instance.baseData.realmLevel); |
| | | var AtkSpeedRatio = fightPowerRatioConfig.AtkSpeedRatio; |
| | | var AtkRatio = fightPowerRatioConfig.AtkRatio; |
| | | var DefRatio = fightPowerRatioConfig.DefRatio; |
| | | var MaxHPRatio = fightPowerRatioConfig.MaxHPRatio; |
| | | var StunRateRatio = fightPowerRatioConfig.StunRateRatio; |
| | | var SuperHitRateRatio = fightPowerRatioConfig.SuperHitRateRatio; |
| | | var ComboRateRatio = fightPowerRatioConfig.ComboRateRatio; |
| | | var MissRateRatio = fightPowerRatioConfig.MissRateRatio; |
| | | var ParryRateRatio = fightPowerRatioConfig.ParryRateRatio; |
| | | var SuckHPPerRatio = fightPowerRatioConfig.SuckHPPerRatio; |
| | | var StunRateDefRatio = fightPowerRatioConfig.StunRateDefRatio; |
| | | var SuperHitRateDefRatio = fightPowerRatioConfig.SuperHitRateDefRatio; |
| | | var ComboRateDefRatio = fightPowerRatioConfig.ComboRateDefRatio; |
| | | var MissRateDefRatio = fightPowerRatioConfig.MissRateDefRatio; |
| | | var ParryRateDefRatio = fightPowerRatioConfig.ParryRateDefRatio; |
| | | var SuckHPPerDefRatio = fightPowerRatioConfig.SuckHPPerDefRatio; |
| | | var NormalSkillPerRatio = fightPowerRatioConfig.NormalSkillPerRatio; |
| | | var NormalSkillPerDefRatio = fightPowerRatioConfig.NormalSkillPerDefRatio; |
| | | var AngerSkillPerRatio = fightPowerRatioConfig.AngerSkillPerRatio; |
| | | var AngerSkillPerDefRatio = fightPowerRatioConfig.AngerSkillPerDefRatio; |
| | | var SuperDamPerRatio = fightPowerRatioConfig.SuperDamPerRatio; |
| | | var SuperDamPerDefRatio = fightPowerRatioConfig.SuperDamPerDefRatio; |
| | | var ShieldPerRatio = fightPowerRatioConfig.ShieldPerRatio; |
| | | var ShieldPerDefRatio = fightPowerRatioConfig.ShieldPerDefRatio; |
| | | var DOTPerRatio = fightPowerRatioConfig.DOTPerRatio; |
| | | var DOTPerDefRatio = fightPowerRatioConfig.DOTPerDefRatio; |
| | | var WeiFinalDamPerRatio = fightPowerRatioConfig.WeiFinalDamPerRatio; |
| | | var WeiFinalDamPerDefRatio = fightPowerRatioConfig.WeiFinalDamPerDefRatio; |
| | | var ShuFinalDamPerRatio = fightPowerRatioConfig.ShuFinalDamPerRatio; |
| | | var ShuFinalDamPerDefRatio = fightPowerRatioConfig.ShuFinalDamPerDefRatio; |
| | | var WuFinalDamPerRatio = fightPowerRatioConfig.WuFinalDamPerRatio; |
| | | var WuFinalDamPerDefRatio = fightPowerRatioConfig.WuFinalDamPerDefRatio; |
| | | var QunFinalDamPerRatio = fightPowerRatioConfig.QunFinalDamPerRatio; |
| | | var QunFinalDamPerDefRatio = fightPowerRatioConfig.QunFinalDamPerDefRatio; |
| | | var FinalDamPerRatio = fightPowerRatioConfig.FinalDamPerRatio; |
| | | var FinalDamPerDefRatio = fightPowerRatioConfig.FinalDamPerDefRatio; |
| | | var PhyDamPerRatio = fightPowerRatioConfig.PhyDamPerRatio; |
| | | var PhyDamPerDefRatio = fightPowerRatioConfig.PhyDamPerDefRatio; |
| | | var MagDamPerRatio = fightPowerRatioConfig.MagDamPerRatio; |
| | | var MagDamPerDefRatio = fightPowerRatioConfig.MagDamPerDefRatio; |
| | | var CurePerRatio = fightPowerRatioConfig.CurePerRatio; |
| | | var CurePerDefRatio = fightPowerRatioConfig.CurePerDefRatio; |
| | | var PVPDamPerRatio = fightPowerRatioConfig.PVPDamPerRatio; |
| | | var PVPDamPerDefRatio = fightPowerRatioConfig.PVPDamPerDefRatio; |
| | | var GuanchuanRatio = fightPowerRatioConfig.GuanchuanRatio; |
| | | var GuanchuanDefRatio = fightPowerRatioConfig.GuanchuanDefRatio; |
| | | var ZhaojiaRatio = fightPowerRatioConfig.ZhaojiaRatio; |
| | | var ZhaojiaDefRatio = fightPowerRatioConfig.ZhaojiaDefRatio; |
| | | |
| | | fightPowerVariables["AtkRatio"] = fightPowerRatioConfig.AtkRatio; |
| | | fightPowerVariables["MaxHPRatio"] = fightPowerRatioConfig.MaxHPRatio; |
| | | fightPowerVariables["DefRatio"] = fightPowerRatioConfig.DefRatio; |
| | | fightPowerVariables["StunRateRatio"] = fightPowerRatioConfig.StunRateRatio; |
| | | fightPowerVariables["SuperHitRateRatio"] = fightPowerRatioConfig.SuperHitRateRatio; |
| | | fightPowerVariables["ComboRateRatio"] = fightPowerRatioConfig.ComboRateRatio; |
| | | fightPowerVariables["MissRateRatio"] = fightPowerRatioConfig.MissRateRatio; |
| | | fightPowerVariables["ParryRateRatio"] = fightPowerRatioConfig.ParryRateRatio; |
| | | fightPowerVariables["SuckHPPerRatio"] = fightPowerRatioConfig.SuckHPPerRatio; |
| | | fightPowerVariables["StunRateDefRatio"] = fightPowerRatioConfig.StunRateDefRatio; |
| | | fightPowerVariables["SuperHitRateDefRatio"] = fightPowerRatioConfig.SuperHitRateDefRatio; |
| | | fightPowerVariables["ComboRateDefRatio"] = fightPowerRatioConfig.ComboRateDefRatio; |
| | | fightPowerVariables["MissRateDefRatio"] = fightPowerRatioConfig.MissRateDefRatio; |
| | | fightPowerVariables["ParryRateDefRatio"] = fightPowerRatioConfig.ParryRateDefRatio; |
| | | fightPowerVariables["SuckHPPerDefRatio"] = fightPowerRatioConfig.SuckHPPerDefRatio; |
| | | fightPowerVariables["NormalSkillPerRatio"] = fightPowerRatioConfig.NormalSkillPerRatio; |
| | | fightPowerVariables["NormalSkillPerDefRatio"] = fightPowerRatioConfig.NormalSkillPerDefRatio; |
| | | fightPowerVariables["AngerSkillPerRatio"] = fightPowerRatioConfig.AngerSkillPerRatio; |
| | | fightPowerVariables["AngerSkillPerDefRatio"] = fightPowerRatioConfig.AngerSkillPerDefRatio; |
| | | fightPowerVariables["SuperDamPerRatio"] = fightPowerRatioConfig.SuperDamPerRatio; |
| | | fightPowerVariables["SuperDamPerDefRatio"] = fightPowerRatioConfig.SuperDamPerDefRatio; |
| | | fightPowerVariables["ShieldPerRatio"] = fightPowerRatioConfig.ShieldPerRatio; |
| | | fightPowerVariables["ShieldPerDefRatio"] = fightPowerRatioConfig.ShieldPerDefRatio; |
| | | fightPowerVariables["DOTPerRatio"] = fightPowerRatioConfig.DOTPerRatio; |
| | | fightPowerVariables["DOTPerDefRatio"] = fightPowerRatioConfig.DOTPerDefRatio; |
| | | fightPowerVariables["WeiFinalDamPerRatio"] = fightPowerRatioConfig.WeiFinalDamPerRatio; |
| | | fightPowerVariables["WeiFinalDamPerDefRatio"] = fightPowerRatioConfig.WeiFinalDamPerDefRatio; |
| | | fightPowerVariables["ShuFinalDamPerRatio"] = fightPowerRatioConfig.ShuFinalDamPerRatio; |
| | | fightPowerVariables["ShuFinalDamPerDefRatio"] = fightPowerRatioConfig.ShuFinalDamPerDefRatio; |
| | | fightPowerVariables["WuFinalDamPerRatio"] = fightPowerRatioConfig.WuFinalDamPerRatio; |
| | | fightPowerVariables["WuFinalDamPerDefRatio"] = fightPowerRatioConfig.WuFinalDamPerDefRatio; |
| | | fightPowerVariables["QunFinalDamPerRatio"] = fightPowerRatioConfig.QunFinalDamPerRatio; |
| | | fightPowerVariables["QunFinalDamPerDefRatio"] = fightPowerRatioConfig.QunFinalDamPerDefRatio; |
| | | fightPowerVariables["FinalDamPerRatio"] = fightPowerRatioConfig.FinalDamPerRatio; |
| | | fightPowerVariables["FinalDamPerDefRatio"] = fightPowerRatioConfig.FinalDamPerDefRatio; |
| | | fightPowerVariables["PhyDamPerRatio"] = fightPowerRatioConfig.PhyDamPerRatio; |
| | | fightPowerVariables["PhyDamPerDefRatio"] = fightPowerRatioConfig.PhyDamPerDefRatio; |
| | | fightPowerVariables["MagDamPerRatio"] = fightPowerRatioConfig.MagDamPerRatio; |
| | | fightPowerVariables["MagDamPerDefRatio"] = fightPowerRatioConfig.MagDamPerDefRatio; |
| | | fightPowerVariables["CurePerRatio"] = fightPowerRatioConfig.CurePerRatio; |
| | | fightPowerVariables["CurePerDefRatio"] = fightPowerRatioConfig.CurePerDefRatio; |
| | | |
| | | |
| | | long 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)}"); |
| | | #endif |
| | | long fightPower = (long)(Atk*AtkRatio+MaxHP*MaxHPRatio+Def*DefRatio+AtkSpeed*AtkSpeedRatio+(StunRate*StunRateRatio+SuperHitRate*SuperHitRateRatio+ComboRate*ComboRateRatio+MissRate*MissRateRatio+ParryRate*ParryRateRatio+SuckHPPer*SuckHPPerRatio+StunRateDef*StunRateDefRatio+SuperHitRateDef*SuperHitRateDefRatio+ComboRateDef*ComboRateDefRatio+MissRateDef*MissRateDefRatio+ParryRateDef*ParryRateDefRatio+SuckHPPerDef*SuckHPPerDefRatio+FinalDamPer*FinalDamPerRatio+FinalDamPerDef*FinalDamPerDefRatio+PhyDamPer*PhyDamPerRatio+PhyDamPerDef*PhyDamPerDefRatio+MagDamPer*MagDamPerRatio+MagDamPerDef*MagDamPerDefRatio+NormalSkillPer*NormalSkillPerRatio+NormalSkillPerDef*NormalSkillPerDefRatio+AngerSkillPer*AngerSkillPerRatio+AngerSkillPerDef*AngerSkillPerDefRatio+SuperDamPer*SuperDamPerRatio+SuperDamPerDef*SuperDamPerDefRatio+CurePer*CurePerRatio+CurePerDef*CurePerDefRatio+ShieldPer*ShieldPerRatio+ShieldPerDef*ShieldPerDefRatio+DOTPer*DOTPerRatio+DOTPerDef*DOTPerDefRatio+WeiFinalDamPer*WeiFinalDamPerRatio+WeiFinalDamPerDef*WeiFinalDamPerDefRatio+ShuFinalDamPer*ShuFinalDamPerRatio+ShuFinalDamPerDef*ShuFinalDamPerDefRatio+WuFinalDamPer*WuFinalDamPerRatio+WuFinalDamPerDef*WuFinalDamPerDefRatio+QunFinalDamPer*QunFinalDamPerRatio+QunFinalDamPerDef*QunFinalDamPerDefRatio+PVPDamPer*PVPDamPerRatio+PVPDamPerDef*PVPDamPerDefRatio+Guanchuan*GuanchuanRatio+GuanchuanDef*GuanchuanDefRatio+Zhaojia*ZhaojiaRatio+ZhaojiaDef*ZhaojiaDefRatio)/100.0-55000); |
| | | |
| | | // #if UNITY_EDITOR |
| | | // //排除值为0的属性输出 |
| | | // var tmpFightPowerVariables = fightPowerVariables.Where(x => x.Value > 0).ToDictionary(x => x.Key, x => x.Value); |
| | | // if (!tmpFightPowerVariables.IsNullOrEmpty()) |
| | | // FightPowerDebug($"战力:武将ID {hero.heroId} 属性战力 {fightPower} 属性战力参数 {JsonMapper.ToJson(tmpFightPowerVariables)}"); |
| | | // #endif |
| | | |
| | | //加上技能战力 |
| | | fightPowerVariables.Clear(); |
| | | fightPowerVariables["PlayerLV"] = PlayerDatas.Instance.baseData.LV; |
| | | fightPowerVariables["OfficialLV"] = PlayerDatas.Instance.baseData.realmLevel; |
| | | fightPowerVariables["SkillPower"] = hero.GetSkillsFightPower(); |
| | | |
| | | long skillPower = (long)JaceCalculator.Calculate(skillFightPowerFormula, fightPowerVariables); |
| | | var SkillPower = hero.GetSkillsFightPower(); |
| | | var OfficialLV = PlayerDatas.Instance.baseData.realmLevel; |
| | | |
| | | long skillPower = SkillPower*OfficialLV;; |
| | | |
| | | #if UNITY_EDITOR |
| | | Debug.Log($"战力:武将ID {hero.heroId} 技能战力 {skillPower} 技能参数 {JsonMapper.ToJson(fightPowerVariables)}"); |
| | | if (openLog) |
| | | { |
| | | FightPowerDebug($"战力:武将ID {hero.heroId} 总战力 {fightPower + skillPower}"); |
| | | } |
| | | |
| | | Debug.Log($"战力:武将ID {hero.heroId} 总战力 {fightPower + skillPower}"); |
| | | #endif |
| | | |
| | | return fightPower + skillPower; |
| | | return fightPower + skillPower; |
| | | } |
| | | |
| | | //命格技能战力:按个数获取对应等级的技能战力 |
| | | long GetMinggeSkillPower() |
| | | { |
| | | //当前方案技能信息 |
| | | var dict = MinggeManager.Instance.GetMinggeSkillCountDictByPresetID(minggePresetID); |
| | | |
| | | ItemModel dropEquip = null; |
| | | if (minggeDropIndex != -1) |
| | | { |
| | | dropEquip = PackManager.Instance.GetItemByIndex(PackType.MinggeDrop, minggeDropIndex); |
| | | //带技能的命格 需判断是否技能个数变化 |
| | | if (MinggeManager.Instance.minggeSkillEquipPlaceList.Contains(dropEquip.config.EquipPlace)) |
| | | { |
| | | var packIndex = MinggeManager.Instance.GetPackIndex(minggePresetID, dropEquip.config.EquipPlace); |
| | | //要对比的装备 |
| | | var equip = PackManager.Instance.GetItemByIndex(PackType.Mingge, packIndex); |
| | | var _skillTypeID = EquipModel.Instance.GetEquipSkillID(dropEquip); |
| | | if (equip == null) |
| | | { |
| | | if (dict.ContainsKey(_skillTypeID)) |
| | | { |
| | | dict[_skillTypeID] += 1; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var oldSkillTypeID = EquipModel.Instance.GetEquipSkillID(equip); |
| | | if (oldSkillTypeID != _skillTypeID) |
| | | { |
| | | |
| | | if (dict.ContainsKey(_skillTypeID)) |
| | | { |
| | | dict[_skillTypeID] += 1; |
| | | } |
| | | else |
| | | { |
| | | dict[_skillTypeID] = 1; |
| | | } |
| | | if (dict.ContainsKey(oldSkillTypeID)) |
| | | { |
| | | dict[oldSkillTypeID] -= 1; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | long skillPower = 0; |
| | | |
| | | foreach (var item in dict) |
| | | { |
| | | if (item.Value == 0) |
| | | { |
| | | continue; |
| | | } |
| | | var skill = SkillConfig.Get(item.Key + item.Value - 1); |
| | | if (skill == null) |
| | | { |
| | | Debug.LogError("skill is null" + (item.Key + item.Value - 1)); |
| | | continue; |
| | | } |
| | | var SkillPower = skill.FightPower; |
| | | var OfficialLV = PlayerDatas.Instance.baseData.realmLevel; |
| | | skillPower += SkillPower*OfficialLV;; |
| | | } |
| | | |
| | | |
| | | #if UNITY_EDITOR |
| | | if (openLog) |
| | | { |
| | | FightPowerDebug($"命格技能战力 {skillPower}"); |
| | | } |
| | | #endif |
| | | return skillPower; |
| | | } |
| | | |
| | | |
| | |
| | | public long GetFightPowerChange(ItemModel item) |
| | | { |
| | | InitFightPowerParam(); |
| | | var fightPower = CalculatePower(); |
| | | var fightPower = CalculatePower(1); |
| | | |
| | | InitFightPowerParam(dropindex: item.gridIndex); |
| | | var tmpFightPower = CalculatePower(); |
| | | return tmpFightPower - fightPower; |
| | | var tmpFightPower = CalculatePower(1); |
| | | EquipRecordManager.Instance.showFightPower = tmpFightPower - fightPower; |
| | | // 同时记录装备日志战力 |
| | | return EquipRecordManager.Instance.showFightPower; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 命格装备对比 |
| | | /// </summary> |
| | | /// minggePresetID 指要对比的哪套方案下的命格,玩家可以点击切换对比,自动默认会遍历所有激活方案 |
| | | public long GetFightPowerMinggeChange(ItemModel item, int minggePresetID) |
| | | { |
| | | InitFightPowerParam(_minggePresetID: minggePresetID); |
| | | var fightPower = CalculatePower(2); |
| | | |
| | | InitFightPowerParam(_minggePresetID: minggePresetID, _minggeDropIndex: item.gridIndex); |
| | | var tmpFightPower = CalculatePower(2); |
| | | return tmpFightPower - fightPower; |
| | | } |
| | | |
| | | |
| | | // 单英雄查看战力 |
| | | // 1. 上阵英雄显示,在主线阵容下的战力 |
| | |
| | | public long GetHeroFightPower(HeroInfo heroInfo) |
| | | { |
| | | bool ispreview = false; |
| | | var team = TeamManager.Instance.GetTeam(TeamType.Story); |
| | | var team = TeamManager.Instance.GetTeam(TeamManager.Instance.GetMainTeamID()); |
| | | if (!team.HasHero(heroInfo.itemHero.guid)) |
| | | { |
| | | //替换上阵位置 |
| | |
| | | var index = team.GetEmptyPosition(); |
| | | if (index < 0) |
| | | { |
| | | team.AddHero(heroInfo, 5); |
| | | team.AddHero(heroInfo, 5, false); |
| | | } |
| | | else |
| | | { |
| | | team.AddHero(heroInfo, index); |
| | | team.AddHero(heroInfo, index, false); |
| | | } |
| | | } |
| | | |
| | | InitFightPowerParam(ispreview: ispreview); |
| | | RefreshLVAttrs(); |
| | | RefreshOfficialAttrs(); |
| | | RefrehMinggeAttrs(); |
| | | RefrehEquipAttrs(); |
| | | RefreshTeamAttrs(); |
| | | |
| | | var fightPower = CalculateTeamHeroPower(heroInfo); |
| | | |
| | | fightPower += GetMinggeSkillPower(); |
| | | |
| | | //计算完恢复队伍 |
| | | if (ispreview) |
| | | team.RestoreTeam(); |
| | |
| | | |
| | | |
| | | //查看阵容战力 |
| | | public long GetTeamFightPower(TeamType team, bool isPreview) |
| | | public long GetTeamFightPower(int team, bool isPreview) |
| | | { |
| | | InitFightPowerParam(team, -1, isPreview); |
| | | return CalculatePower(); |
| | | InitFightPowerParam(team, ispreview:isPreview); |
| | | return CalculatePower(0); |
| | | } |
| | | #endregion |
| | | |
| | |
| | | { |
| | | |
| | | Dictionary<int, long> tmpAttrs = new Dictionary<int, long>(); |
| | | hero.RefreshFetterAttrsWhenCalcPower(TeamType.Story); //羁绊属性要实时算 |
| | | hero.RefreshFetterAttrsWhenCalcPower(TeamManager.Instance.GetMainTeamID()); //羁绊属性要实时算 |
| | | |
| | | #if UNITY_EDITOR |
| | | propertyStrForDebug = ""; |
| | | #endif |
| | | |
| | | foreach (var config in PlayerPropertyConfig.GetValues()) |
| | | var pConfig = PlayerPropertyConfig.GetValues(); |
| | | foreach (var config in pConfig) |
| | | { |
| | | if (config.showType < 1 || config.showType > 4) |
| | | { |
| | | continue; |
| | | } |
| | | if (config.showType == 1) |
| | | //约定死 只有3维才是基础属性 |
| | | if (config.showType == 1 && config.ID != 11) |
| | | { |
| | | tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero, propertyFormula); |
| | | tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero); |
| | | } |
| | | else |
| | | { |
| | | tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero, fightPropertyFormula); |
| | | tmpAttrs[config.ID] = (long)GetFighttPropertyVaule(config.ID, hero); |
| | | } |
| | | } |
| | | #if UNITY_EDITOR |
| | | Debug.Log($"战力:武将ID {hero.heroId} 属性信息 {propertyStrForDebug}"); |
| | | #endif |
| | | |
| | | return tmpAttrs; |
| | | } |
| | | |
| | | |
| | | bool openLog = false; |
| | | void FightPowerDebug(string msg) |
| | | { |
| | | #if UNITY_EDITOR |
| | | if (!openLog) return; |
| | | Debug.Log(msg); |
| | | #endif |
| | | } |
| | | } |
| | | |
| | | |