yyl
2026-01-23 d165af063d7365e143d92c3a950a0b52e683a66e
Main/System/Main/FightPowerManager.cs
@@ -123,23 +123,38 @@
    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(int teamType = 1, 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
        FightPowerDebug("战力:初始化参数 dropIndex:" + dropIndexCalc + " 阵型:" + teamTypeCalc + " ispreview:" + ispreview);
#endif
@@ -158,6 +173,7 @@
    public Dictionary<int, int> equipAttrs = new Dictionary<int, int>();   //装备属性
    // 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>();   //命格属性 技能战力为固定的只算个数区别即可
    float allHeroAddPer = 0;  //所有武将加成
@@ -216,13 +232,18 @@
    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;  //替换计算总战力
                }
@@ -288,6 +309,59 @@
#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
        FightPowerDebug("战力:命格属性 " + JsonMapper.ToJson(minggeAttrs));
#endif
    }
    #endregion
    //单属性公式分基础三维和战斗属性
@@ -316,7 +390,7 @@
    public double GetPropertyVaule(int attrType, HeroInfo hero, int type)
    {
        // propertyVariables.Clear();
        propertyVariables[LV_VALUE] = lvAttrs.ContainsKey(attrType) ? lvAttrs[attrType] : 0;
        propertyVariables[EQUIP_VALUE] = equipAttrs.ContainsKey(attrType) ? equipAttrs[attrType] : 0;
        // propertyVariables[BOOK_VALUE] = 0;
@@ -335,8 +409,8 @@
        propertyVariables[FATES_PER] = HeroFatesManager.Instance.GetAttrPer(attrType) / 10000.0f;
        propertyVariables[DINGJUNGE_VALUE] = 0; //默认不需要加,爬塔特殊用,配合公式
        propertyVariables[DINGJUNGE_PER] = 0;   //默认不需要加,爬塔特殊用,配合公式
        propertyVariables[MINGGE_VALUE] = 0;
        propertyVariables[MINGGE_PER] = 0;
        propertyVariables[MINGGE_VALUE] = minggeAttrs.ContainsKey(attrType) ? minggeAttrs[attrType] : 0;
        propertyVariables[MINGGE_PER] = (minggeAttrs.ContainsKey(attrType) ? minggeAttrs[attrType] : 0) / 10000.0f;
        //全体卡牌加成
        propertyVariables[HERO_CARDPER] = allHeroAddPer;
@@ -439,6 +513,7 @@
        RefreshLVAttrs();
        RefreshOfficialAttrs();
        RefrehEquipAttrs();
        RefrehMinggeAttrs();
        RefreshTeamAttrs();
        // --- 算单武将功能属性战力 后相加---
@@ -465,8 +540,9 @@
        }
        fightPower += GetMinggeSkillPower();
// #if UNITY_EDITOR
         FightPowerDebug("战力:计算完毕 " + fightPower);
        FightPowerDebug("战力:计算完毕 " + fightPower);
// #endif
        return fightPower;
    }
@@ -583,6 +659,49 @@
            return fightPower + skillPower;
    }
    //命格技能战力:技能战力*个数;如果是替换的要判断是否技能个数变化
    long GetMinggeSkillPower()
    {
        //当前方案技能信息
        int _skillTypeID = 0;    //取其中一个用于计算即可
        var count = MinggeManager.Instance.GetMinggeSkillCountByPresetID(minggePresetID, out _skillTypeID);
        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, minggeDropIndex);
                //要对比的装备
                var equip = PackManager.Instance.GetItemByIndex(PackType.Mingge, packIndex);
                if (equip == null)
                {
                    count++;
                    if (_skillTypeID == 0)
                    {
                        _skillTypeID = EquipModel.Instance.GetEquipSkillID(dropEquip);
                    }
                }
            }
        }
        if (_skillTypeID == 0)
            return 0;
        //加上技能战力
        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;
    }
    /// <summary>
@@ -594,13 +713,26 @@
    {
        InitFightPowerParam();
        var fightPower = CalculatePower();
        InitFightPowerParam(dropindex: item.gridIndex);
        var tmpFightPower = CalculatePower();
        return tmpFightPower - fightPower;
    }
    /// <summary>
    /// 命格装备对比
    /// </summary>
    /// minggePresetID 指要对比的哪套方案下的命格,玩家可以点击切换对比,自动默认会遍历所有激活方案
    public long GetFightPowerMinggeChange(ItemModel item, int minggePresetID)
    {
        InitFightPowerParam(_minggePresetID: minggePresetID);
        var fightPower = CalculatePower();
        InitFightPowerParam(_minggePresetID: minggePresetID, _minggeDropIndex: item.gridIndex);
        var tmpFightPower = CalculatePower();
        return tmpFightPower - fightPower;
    }
    // 单英雄查看战力 
    // 1. 上阵英雄显示,在主线阵容下的战力
@@ -627,11 +759,13 @@
        InitFightPowerParam(ispreview: ispreview);
        RefreshLVAttrs();
        RefreshOfficialAttrs();
        RefrehMinggeAttrs();
        RefrehEquipAttrs();
        RefreshTeamAttrs();
        var fightPower = CalculateTeamHeroPower(heroInfo);
        fightPower += GetMinggeSkillPower();
        //计算完恢复队伍
        if (ispreview)
            team.RestoreTeam();
@@ -642,7 +776,7 @@
    //查看阵容战力
    public long GetTeamFightPower(int team, bool isPreview)
    {
        InitFightPowerParam(team, -1, isPreview);
        InitFightPowerParam(team, ispreview:isPreview);
        return CalculatePower();
    }
    #endregion