| | |
| | | dropIndexCalc = dropindex; |
| | | minggeDropIndex = _minggeDropIndex; |
| | | #if UNITY_EDITOR |
| | | FightPowerDebug("战力:初始化参数 dropIndex:" + dropIndexCalc + " 阵型:" + teamTypeCalc + " ispreview:" + ispreview); |
| | | 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<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, int> minggeAttrs = new Dictionary<int, int>(); //命格属性 技能战力为固定的只算个数区别即可 |
| | | public Dictionary<int, long> minggeAttrs = new Dictionary<int, long>(); //命格属性 |
| | | |
| | | float allHeroAddPer = 0; //所有武将加成 |
| | | double allHeroAddPer = 0; //所有武将加成 |
| | | |
| | | //等级属性 |
| | | void RefreshLVAttrs() |
| | |
| | | //阵容属性 |
| | | // 阵容:所有武将上阵属性 |
| | | // lineUpPerDict = HeroUIManager.Instance.GetLineupPer(teamTypeCalc, isPreviewTeamPower); |
| | | allHeroAddPer = HeroUIManager.Instance.GetAllHeroPer() / 10000.0f; |
| | | allHeroAddPer = HeroUIManager.Instance.GetAllHeroPer() / 10000.0; |
| | | #if UNITY_EDITOR |
| | | // Debug.Log("战力:上阵属性 " + JsonMapper.ToJson(lineUpPerDict)); |
| | | #endif |
| | |
| | | countryAttrs = HeroUIManager.Instance.GetCountryAttrs(teamTypeCalc, isPreviewTeamPower); |
| | | #if UNITY_EDITOR |
| | | FightPowerDebug("战力:国家(光环)属性 " + JsonMapper.ToJson(countryAttrs)); |
| | | FightPowerDebug("战力:武将所有加成 " + allHeroAddPer); |
| | | #endif |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public int GetAttrPer(int attrID, Dictionary<int, long> attrDic) |
| | | { |
| | | if (PlayerPropertyConfig.baseAttr2perDict.ContainsKey(attrID)) |
| | | { |
| | | var pertype = PlayerPropertyConfig.baseAttr2perDict[attrID]; |
| | | attrDic.TryGetValue(pertype, out long value); |
| | | return (int)(value); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | //单属性公式分基础三维和战斗属性 |
| | |
| | | propertyVariables[EQUIP_VALUE] = equipAttrs.ContainsKey(attrType) ? equipAttrs[attrType] : 0; |
| | | // propertyVariables[BOOK_VALUE] = 0; |
| | | propertyVariables[REALM_VALUE] = officialAttrs.ContainsKey(attrType) ? officialAttrs[attrType] : 0; |
| | | propertyVariables[REALM_PER] = GetOfficialPer(attrType) / 10000.0f; |
| | | // propertyVariables[BOOK_PER] = GetBookPer(attrType) / 10000.0f; |
| | | propertyVariables[REALM_PER] = GetAttrPer(attrType, officialAttrs) / 10000.0; |
| | | // propertyVariables[BOOK_PER] = GetBookPer(attrType) / 10000.0; |
| | | propertyVariables[GUBAO_VALUE] = GubaoManager.Instance.GetAttrValue(attrType); |
| | | propertyVariables[GUBAO_PER] = GubaoManager.Instance.GetAttrPer(attrType) / 10000.0f; |
| | | propertyVariables[GUBAO_PER] = GubaoManager.Instance.GetAttrPer(attrType) / 10000.0; |
| | | propertyVariables[HJG_VALUE] = PhantasmPavilionManager.Instance.GetAttrValue(attrType); |
| | | propertyVariables[HJG_PER] = PhantasmPavilionManager.Instance.GetAttrPer(attrType) / 10000.0f; |
| | | propertyVariables[HJG_PER] = PhantasmPavilionManager.Instance.GetAttrPer(attrType) / 10000.0; |
| | | propertyVariables[HORSE_VALUE] = HorseManager.Instance.GetAttrValue(attrType); |
| | | propertyVariables[HORSE_PER] = HorseManager.Instance.GetAttrPer(attrType) / 10000.0f; |
| | | propertyVariables[HORSE_PER] = HorseManager.Instance.GetAttrPer(attrType) / 10000.0; |
| | | propertyVariables[BEAUTY_VALUE] = BeautyMMManager.Instance.GetAttrValue(attrType); |
| | | propertyVariables[BEAUTY_PER] = BeautyMMManager.Instance.GetAttrPer(attrType) / 10000.0f; |
| | | propertyVariables[BEAUTY_PER] = BeautyMMManager.Instance.GetAttrPer(attrType) / 10000.0; |
| | | propertyVariables[FATES_VALUE] = HeroFatesManager.Instance.GetAttrValue(attrType); |
| | | propertyVariables[FATES_PER] = HeroFatesManager.Instance.GetAttrPer(attrType) / 10000.0f; |
| | | propertyVariables[FATES_PER] = HeroFatesManager.Instance.GetAttrPer(attrType) / 10000.0; |
| | | propertyVariables[DINGJUNGE_VALUE] = 0; //默认不需要加,爬塔特殊用,配合公式 |
| | | propertyVariables[DINGJUNGE_PER] = 0; //默认不需要加,爬塔特殊用,配合公式 |
| | | propertyVariables[MINGGE_VALUE] = minggeAttrs.ContainsKey(attrType) ? minggeAttrs[attrType] : 0; |
| | | propertyVariables[MINGGE_PER] = (minggeAttrs.ContainsKey(attrType) ? minggeAttrs[attrType] : 0) / 10000.0f; |
| | | propertyVariables[MINGGE_PER] = GetAttrPer(attrType, minggeAttrs) / 10000.0; |
| | | |
| | | //全体卡牌加成 |
| | | propertyVariables[HERO_CARDPER] = allHeroAddPer; |
| | | if (attrType == 6 || attrType == 7 || attrType == 8) |
| | | { |
| | | propertyVariables[HERO_CARDPER] = allHeroAddPer; |
| | | } |
| | | else |
| | | { |
| | | propertyVariables[HERO_CARDPER] = 0; |
| | | } |
| | | //!!!单武将战力预览的话需要排除队伍影响战力,只算武将自身的上阵属性 |
| | | // propertyVariables[LINEUP_INIT_ADD_PER] = GetLineUpPer(attrType, LINEUP_INIT_ADD_PER) / 10000.0f; |
| | | // propertyVariables[LINEUP_LV_ADD_PER] = GetLineUpPer(attrType, LINEUP_LV_ADD_PER) / 10000.0f; |
| | | // propertyVariables[LINEUP_BREAK_LV_ADD_PER] = GetLineUpPer(attrType, LINEUP_BREAK_LV_ADD_PER) / 10000.0f; |
| | | // propertyVariables[LINEUP_STAR_ADD_PER] = GetLineUpPer(attrType, LINEUP_STAR_ADD_PER) / 10000.0f; |
| | | // propertyVariables[LINEUP_INIT_ADD_PER] = GetLineUpPer(attrType, LINEUP_INIT_ADD_PER) / 10000.0; |
| | | // propertyVariables[LINEUP_LV_ADD_PER] = GetLineUpPer(attrType, LINEUP_LV_ADD_PER) / 10000.0; |
| | | // propertyVariables[LINEUP_BREAK_LV_ADD_PER] = GetLineUpPer(attrType, LINEUP_BREAK_LV_ADD_PER) / 10000.0; |
| | | // propertyVariables[LINEUP_STAR_ADD_PER] = GetLineUpPer(attrType, LINEUP_STAR_ADD_PER) / 10000.0; |
| | | |
| | | //阵容光环 三围百分比加成 |
| | | propertyVariables[LINEUP_HALO_VALUE] = countryAttrs.ContainsKey(attrType) ? countryAttrs[attrType] : 0; |
| | | propertyVariables[LINEUP_HALO_PER] = GetCountryPer(attrType) / 10000.0f; |
| | | propertyVariables[LINEUP_HALO_PER] = GetCountryPer(attrType) / 10000.0; |
| | | |
| | | //武将属性 |
| | | propertyVariables[INHERIT_PER] = hero.GetInheritAttrPer(attrType) / 10000.0f; |
| | | propertyVariables[INHERIT_PER] = hero.GetInheritAttrPer(attrType) / 10000.0; |
| | | propertyVariables[HERO_SELF_VALUE] = hero.GetSelfAddValue(attrType); |
| | | propertyVariables[HERO_SELF_PER] = hero.GetSelfAddPer(attrType) / 10000.0f; |
| | | propertyVariables[HERO_SELF_PER] = hero.GetSelfAddPer(attrType) / 10000.0; |
| | | propertyVariables[STAR_TALENT_VALUE] = hero.GetTalentAttrValue(attrType); |
| | | propertyVariables[STAR_TALENT_PER] = hero.GetTalentAttrPer(attrType) / 10000.0f; |
| | | propertyVariables[STAR_TALENT_PER] = hero.GetTalentAttrPer(attrType) / 10000.0; |
| | | propertyVariables[BREAK_LV_VALUE] = hero.GetBreakAttrValue(attrType); |
| | | propertyVariables[BREAK_LV_PER] = hero.GetBreakAttrPer(attrType) / 10000.0f; |
| | | propertyVariables[BREAK_LV_PER] = hero.GetBreakAttrPer(attrType) / 10000.0; |
| | | propertyVariables[AWAKE_TALENT_VALUE] = hero.GetAwakeAttrValue(attrType); |
| | | propertyVariables[AWAKE_TALENT_PER] = hero.GetAwakeAttrPer(attrType) / 10000.0f; |
| | | propertyVariables[AWAKE_TALENT_PER] = hero.GetAwakeAttrPer(attrType) / 10000.0; |
| | | propertyVariables[FETTER_VALUE] = hero.GetFetterAttrValue(attrType); |
| | | propertyVariables[FETTER_PER] = hero.GetFetterAttrPer(attrType) / 10000.0f; |
| | | propertyVariables[FETTER_PER] = hero.GetFetterAttrPer(attrType) / 10000.0; |
| | | propertyVariables[HERO_LV_VALUE] = hero.GetHeroLVValue(attrType); |
| | | propertyVariables[HERO_LV_PER] = hero.GetHeroLVPer(attrType) / 10000.0f; |
| | | propertyVariables[HERO_LV_PER] = hero.GetHeroLVPer(attrType) / 10000.0; |
| | | |
| | | double value; |
| | | if (type == 0) |
| | | { |
| | | value = FightPowerFormula.GetBaseAttr(propertyVariables); |
| | | } |
| | | else |
| | | { |
| | | value = FightPowerFormula.GetFightAttr(propertyVariables); |
| | | } |
| | | |
| | | //保留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)}"; |
| | | { |
| | | FightPowerDebug($"战力:武将ID {hero.heroId} 属性ID {attrType} 值 {value} - {JsonMapper.ToJson(tmpPropertyVariables)}"); |
| | | } |
| | | #endif |
| | | if (type == 0) |
| | | return FightPowerFormula.GetBaseAttr(propertyVariables); |
| | | else |
| | | return FightPowerFormula.GetFightAttr(propertyVariables); |
| | | return value; |
| | | } |
| | | |
| | | |
| | |
| | | // 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; |
| | | } |
| | | |
| | | int GetCountryPer(int attrType) |
| | | { |
| | |
| | | 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 pConfig) |
| | | { |
| | | if (config.showType < 1 || config.showType > 4) |
| | | { |
| | | continue; |
| | | } |
| | | if (config.showType == 1) |
| | | |
| | | //约定死 只有3维才是基础属性 |
| | | if (config.showType == 1 && config.ID != 11) |
| | | { |
| | | fightPowerVariables[config.Parameter] = Math.Round(GetPropertyVaule(config.ID, hero, 0), 3); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | #if UNITY_EDITOR |
| | | FightPowerDebug($"战力:武将ID {hero.heroId} 属性信息 {propertyStrForDebug}"); |
| | | #endif |
| | | |
| | | |
| | | //属性系数根据官职等级的加成 |
| | | var fightPowerRatioConfig = FightPowerRatioConfig.Get(PlayerDatas.Instance.baseData.realmLevel); |
| | |
| | | return fightPower + skillPower; |
| | | } |
| | | |
| | | //命格技能战力:技能战力*个数;如果是替换的要判断是否技能个数变化 |
| | | //命格技能战力:按个数获取对应等级的技能战力 |
| | | long GetMinggeSkillPower() |
| | | { |
| | | //当前方案技能信息 |
| | | int _skillTypeID = 0; //取其中一个用于计算即可 |
| | | var count = MinggeManager.Instance.GetMinggeSkillCountByPresetID(minggePresetID, out _skillTypeID); |
| | | var dict = MinggeManager.Instance.GetMinggeSkillCountDictByPresetID(minggePresetID); |
| | | |
| | | ItemModel dropEquip = null; |
| | | if (minggeDropIndex != -1) |
| | |
| | | //带技能的命格 需判断是否技能个数变化 |
| | | if (MinggeManager.Instance.minggeSkillEquipPlaceList.Contains(dropEquip.config.EquipPlace)) |
| | | { |
| | | var packIndex = MinggeManager.Instance.GetPackIndex(minggePresetID, minggeDropIndex); |
| | | 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) |
| | | { |
| | | count++; |
| | | if (_skillTypeID == 0) |
| | | if (dict.ContainsKey(_skillTypeID)) |
| | | { |
| | | _skillTypeID = EquipModel.Instance.GetEquipSkillID(dropEquip); |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | if (_skillTypeID == 0) |
| | | return 0; |
| | | long skillPower = 0; |
| | | |
| | | foreach (var item in dict) |
| | | { |
| | | // //加上技能战力 |
| | | fightPowerVariables.Clear(); |
| | | fightPowerVariables[PLAYER_LV] = PlayerDatas.Instance.baseData.LV; |
| | | fightPowerVariables[OFFICIAL_LV] = PlayerDatas.Instance.baseData.realmLevel; |
| | | fightPowerVariables[SKILL_POWER] = SkillConfig.Get(item.Key + item.Value - 1).FightPower; |
| | | skillPower += (long)FightPowerFormula.GetSkillsFightPower(fightPowerVariables); |
| | | } |
| | | |
| | | //加上技能战力 |
| | | fightPowerVariables.Clear(); |
| | | fightPowerVariables[PLAYER_LV] = PlayerDatas.Instance.baseData.LV; |
| | | fightPowerVariables[OFFICIAL_LV] = PlayerDatas.Instance.baseData.realmLevel; |
| | | fightPowerVariables[SKILL_POWER] = SkillConfig.Get(_skillTypeID).FightPower; |
| | | |
| | | long skillPower = (long)FightPowerFormula.GetSkillsFightPower(fightPowerVariables); |
| | | |
| | | return skillPower * count; |
| | | #if UNITY_EDITOR |
| | | FightPowerDebug($"命格技能战力 {skillPower}"); |
| | | #endif |
| | | return skillPower; |
| | | } |
| | | |
| | | |
| | |
| | | Dictionary<int, long> tmpAttrs = new Dictionary<int, long>(); |
| | | hero.RefreshFetterAttrsWhenCalcPower(TeamManager.Instance.GetMainTeamID()); //羁绊属性要实时算 |
| | | |
| | | #if UNITY_EDITOR |
| | | propertyStrForDebug = ""; |
| | | #endif |
| | | |
| | | 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, 0); |
| | | } |
| | |
| | | tmpAttrs[config.ID] = (long)GetPropertyVaule(config.ID, hero, 1); |
| | | } |
| | | } |
| | | #if UNITY_EDITOR |
| | | FightPowerDebug($"战力:武将ID {hero.heroId} 属性信息 {propertyStrForDebug}"); |
| | | #endif |
| | | |
| | | return tmpAttrs; |
| | | } |
| | | |
| | | |
| | | bool openLog = true; |
| | | bool openLog = false; |
| | | void FightPowerDebug(string msg) |
| | | { |
| | | #if UNITY_EDITOR |
| | | if (!openLog) return; |
| | | Debug.Log(msg); |
| | | #endif |
| | | #endif |
| | | } |
| | | } |
| | | |