603 【坐骑】坐骑优化-服务端 废弃AttrMultiValue,适配骑乘属性HorseEffAttrIDList+ClassSpecAttrValueList的累加
6个文件已修改
232 ■■■■■ 已修改文件
Main/Config/Configs/HorseClassConfig.cs 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Config/Configs/HorseIDConfig.cs 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Horse/HorseManager.cs 84 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Horse/HorseRankUPWin.cs 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Horse/HorseSuccessWin.cs 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Horse/HorseWin.cs 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/Config/Configs/HorseClassConfig.cs
@@ -1,6 +1,6 @@
//--------------------------------------------------------
//    [Author]:           YYL
//    [  Date ]:           2025年11月16日
//    [  Date ]:           2026年4月15日
//--------------------------------------------------------
using System.Collections.Generic;
@@ -25,6 +25,8 @@
    public int[] AttrIDList;
    public int[] ClassAttrValueList;
    public int[] PerLVAttrValueList;
    public int[] HorseEffAttrIDList;
    public int[] HorseEffAttrValueList;
    public override int LoadKey(string _key)
    {
@@ -113,6 +115,34 @@
                     int.TryParse(PerLVAttrValueListStringArray[i],out PerLVAttrValueList[i]);
                }
            }
            if (tables[9].Contains("["))
            {
                HorseEffAttrIDList = JsonMapper.ToObject<int[]>(tables[9]);
            }
            else
            {
                string[] HorseEffAttrIDListStringArray = tables[9].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries);
                HorseEffAttrIDList = new int[HorseEffAttrIDListStringArray.Length];
                for (int i=0;i<HorseEffAttrIDListStringArray.Length;i++)
                {
                     int.TryParse(HorseEffAttrIDListStringArray[i],out HorseEffAttrIDList[i]);
                }
            }
            if (tables[10].Contains("["))
            {
                HorseEffAttrValueList = JsonMapper.ToObject<int[]>(tables[10]);
            }
            else
            {
                string[] HorseEffAttrValueListStringArray = tables[10].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries);
                HorseEffAttrValueList = new int[HorseEffAttrValueListStringArray.Length];
                for (int i=0;i<HorseEffAttrValueListStringArray.Length;i++)
                {
                     int.TryParse(HorseEffAttrValueListStringArray[i],out HorseEffAttrValueList[i]);
                }
            }
        }
        catch (Exception exception)
        {
Main/Config/Configs/HorseIDConfig.cs
@@ -1,6 +1,6 @@
//--------------------------------------------------------
//    [Author]:           YYL
//    [  Date ]:           Monday, April 13, 2026
//    [  Date ]:           Wednesday, April 15, 2026
//--------------------------------------------------------
using System.Collections.Generic;
@@ -21,7 +21,6 @@
    public int UnlockValue;
    public int UnlockNeedCnt;
    public int AttrID;
    public float AttrMultiValue;
    public override int LoadKey(string _key)
    {
@@ -42,8 +41,6 @@
            int.TryParse(tables[3],out UnlockNeedCnt); 
            int.TryParse(tables[4],out AttrID); 
            float.TryParse(tables[5],out AttrMultiValue);
        }
        catch (Exception exception)
        {
Main/System/Horse/HorseManager.cs
@@ -252,7 +252,6 @@
        // 更新状态
        horseIDState = netPack.HorseIDState;
        RefreshAttr();
        OnUpdateHorseIDInfoEvent?.Invoke();
    }
@@ -572,27 +571,70 @@
        }
    }
    public Dictionary<int, long> GetMergedAttrDic()
    public bool GetNowRiderAttrInfo(out int attrID, out long value, out PlayerPropertyConfig playerPropertyConfig)
    {
        value = 0;
        HorseIDConfig horseIDConfig = HorseIDConfig.Get(horseID);
        attrID = horseIDConfig.AttrID;
        Dictionary<int, long> resultDic = new Dictionary<int, long>();
        // 合并 specialAttrDic
        foreach (var kvp in specialAttrDic)
        for (int lv = 0; lv <= classLV; lv++)
        {
            resultDic[kvp.Key] = kvp.Value;
            var config = HorseClassConfig.Get(lv);
            if (config.HorseEffAttrIDList.IsNullOrEmpty())
                continue;
            for (int i = 0; i < config.HorseEffAttrIDList.Length; i++)
            {
                if (config.HorseEffAttrIDList[i] == attrID)
                {
                    value += config.HorseEffAttrValueList[i];
                }
            }
        }
        playerPropertyConfig = PlayerPropertyConfig.Get(attrID);
        return playerPropertyConfig != null;
    }
    public bool GetNowRiderTotalAttrInfo(out int attrID, out long value, out PlayerPropertyConfig playerPropertyConfig)
    {
        GetNowRiderAttrInfo(out attrID, out value, out playerPropertyConfig);
        for (int lv = 0; lv <= classLV; lv++)
        {
            var config = HorseClassConfig.Get(lv);
            if (config.ClassSpecAttrIDList.IsNullOrEmpty())
                continue;
            for (int i = 0; i < config.ClassSpecAttrIDList.Length; i++)
            {
                if (config.ClassSpecAttrIDList[i] == attrID)
                {
                    value += config.ClassSpecAttrValueList[i];
                }
            }
        }
        return playerPropertyConfig != null;
        }
        HorseIDConfig horseIDConfig = HorseIDConfig.Get(horseID);
        int horseIDAttrID = horseIDConfig.AttrID;
        float attrMultiValue = horseIDConfig.AttrMultiValue;
        var keys = resultDic.Keys.ToList();
        foreach (var key in keys)
    Dictionary<int, long> mergedResultDic = new Dictionary<int, long>();
    public Dictionary<int, long> GetMergedAttrDic()
        {
            if (key == horseIDAttrID)
        mergedResultDic.Clear();
        // 合并 specialAttrDic
        foreach (var kvp in specialAttrDic)
            {
                resultDic[key] = (long)(resultDic[key] * attrMultiValue);
            mergedResultDic[kvp.Key] = kvp.Value;
        }
        if (GetNowRiderAttrInfo(out int attrID, out long value, out PlayerPropertyConfig playerPropertyConfig))
        {
            if (mergedResultDic.TryGetValue(attrID, out long existingValue))
            {
                mergedResultDic[attrID] = existingValue + value;
            }
            else
            {
                mergedResultDic[attrID] = value;
            }
        }
@@ -600,22 +642,22 @@
        // 合并 attrDic
        foreach (var kvp in attrDic)
        {
            if (resultDic.ContainsKey(kvp.Key))
                resultDic[kvp.Key] += kvp.Value;
            if (mergedResultDic.ContainsKey(kvp.Key))
                mergedResultDic[kvp.Key] += kvp.Value;
            else
                resultDic[kvp.Key] = kvp.Value;
                mergedResultDic[kvp.Key] = kvp.Value;
        }
        // 合并 skinAttrDic
        foreach (var kvp in skinAttrDic)
        {
            if (resultDic.ContainsKey(kvp.Key))
                resultDic[kvp.Key] += kvp.Value;
            if (mergedResultDic.ContainsKey(kvp.Key))
                mergedResultDic[kvp.Key] += kvp.Value;
            else
                resultDic[kvp.Key] = kvp.Value;
                mergedResultDic[kvp.Key] = kvp.Value;
        }
        return resultDic;
        return mergedResultDic;
    }
Main/System/Horse/HorseRankUPWin.cs
@@ -84,17 +84,11 @@
        costText.text = UIHelper.ShowUseItem(PackType.Item, HorseManager.Instance.rankUPItemID, HorseClassConfig.Get(HorseManager.Instance.classLV).ClassUPItemCnt);
        costItemImg.SetItemSprite(HorseManager.Instance.rankUPItemID);
        int nowhorseID = HorseManager.Instance.horseID;
        HorseSkinConfig.horseIDTohorseSkinIDDict.TryGetValue(nowhorseID, out int horseSkinID);
        var horseIdSkinConfig = HorseSkinConfig.Get(horseSkinID);
        var horseIDConfig = HorseIDConfig.Get(nowhorseID);
        if (horseIdSkinConfig == null || horseIDConfig == null) return;
        int attrID = horseIDConfig.AttrID;
        int attrValue = HorseManager.Instance.GetNowAttrValue(attrID);
        // 使用新方法获取当前的总值和属性配置
        bool hasAttr = HorseManager.Instance.GetNowRiderTotalAttrInfo(out int attrID, out long curAttrValue, out PlayerPropertyConfig propConfig);
        // 检查属性是否存在
        var propConfig = PlayerPropertyConfig.Get(attrID);
        if (propConfig == null)
        if (!hasAttr)
        {
            // 没有属性
            noRiderText.SetActive(true);
@@ -106,16 +100,35 @@
            noRiderText.SetActive(false);
            riderAttrRect.SetActive(true);
            riderAttrNameText.text = propConfig.Name;
            riderAttrValueText.text = PlayerPropertyConfig.GetValueDescription(attrID, (long)(attrValue * horseIDConfig.AttrMultiValue), 2);
            // 下一阶的属性值
            // 当前阶的属性值
            riderAttrValueText.text = PlayerPropertyConfig.GetValueDescription(attrID, curAttrValue, 2);
            // 预测下一阶的属性值
            long nextAttrValue = curAttrValue;
            if (nextConfig.ClassSpecAttrIDList != null)
            {
                // 加上下一阶增加的 ClassSpecAttrValue
            int index = Array.IndexOf(nextConfig.ClassSpecAttrIDList, attrID);
            if (index < 0 || index > nextConfig.ClassSpecAttrIDList.Length)
                return;
            long nextAttrValue = (long)((attrValue + nextConfig.ClassSpecAttrValueList[index]) * horseIDConfig.AttrMultiValue);
            riderNextAttrValueText.text = PlayerPropertyConfig.GetValueDescription(attrID, nextAttrValue, 2);
                if (index >= 0 && nextConfig.ClassSpecAttrValueList != null && index < nextConfig.ClassSpecAttrValueList.Length)
                {
                    nextAttrValue += nextConfig.ClassSpecAttrValueList[index];
                }
        }
            if (nextConfig.HorseEffAttrIDList != null)
            {
                // 加上下一阶增加的 HorseEffAttrValue
                int effIndex = Array.IndexOf(nextConfig.HorseEffAttrIDList, attrID);
                if (effIndex >= 0 && nextConfig.HorseEffAttrValueList != null && effIndex < nextConfig.HorseEffAttrValueList.Length)
                {
                    nextAttrValue += nextConfig.HorseEffAttrValueList[effIndex];
                }
            }
            riderNextAttrValueText.text = PlayerPropertyConfig.GetValueDescription(attrID, nextAttrValue, 2);
        }
    }
    //升阶
Main/System/Horse/HorseSuccessWin.cs
@@ -80,19 +80,11 @@
                specialAttrRect[i].SetActive(false);
            }
        }
        int nowhorseID = HorseManager.Instance.horseID;
        HorseSkinConfig.horseIDTohorseSkinIDDict.TryGetValue(nowhorseID, out int horseSkinID);
        var horseIdSkinConfig = HorseSkinConfig.Get(horseSkinID);
        var horseIDConfig = HorseIDConfig.Get(nowhorseID);
        if (horseIdSkinConfig == null || horseIDConfig == null) return;
        int attrID = horseIDConfig.AttrID;
        // 【注意】因为已经进阶成功,此处获取的是进阶【后】的最新总值
        int newAttrValue = HorseManager.Instance.GetNowAttrValue(attrID);
        // 使用新方法获取进阶【后】的最新总值和属性配置
        bool hasAttr = HorseManager.Instance.GetNowRiderTotalAttrInfo(out int attrID, out long newAttrValue, out PlayerPropertyConfig propConfig);
        // 检查属性是否存在
        var propConfig = PlayerPropertyConfig.Get(attrID);
        if (propConfig == null)
        if (!hasAttr)
        {
            // 没有属性
            noRiderText.SetActive(true);
@@ -106,30 +98,34 @@
            riderAttrNameText.text = propConfig.Name;
            // 计算进阶前的旧值
            int oldAttrValue = newAttrValue; // 默认如果没有增量,旧值等于新值
            long oldAttrValue = newAttrValue; // 默认如果没有增量,旧值等于新值
            // nextConfig 变量在这里其实代表的是“刚达到的新阶级配置”
            if (nextConfig.ClassSpecAttrIDList != null)
            {
                // 在 ID 列表中寻找对应属性的索引
                // 扣除刚增加的 ClassSpecAttrValue
                int index = Array.IndexOf(nextConfig.ClassSpecAttrIDList, attrID);
                // 确保找到了,且索引没有越界(避免直接return导致UI没刷新)
                if (index >= 0 && nextConfig.ClassSpecAttrValueList != null && index < nextConfig.ClassSpecAttrValueList.Length)
                {
                    // 旧值 = 最新总值 - 本次进阶增加的数值
                    oldAttrValue = newAttrValue - nextConfig.ClassSpecAttrValueList[index];
                    oldAttrValue -= nextConfig.ClassSpecAttrValueList[index];
                }
            }
            float multi = horseIDConfig.AttrMultiValue;
            if (nextConfig.HorseEffAttrIDList != null)
            {
                // 扣除刚增加的 HorseEffAttrValue
                int effIndex = Array.IndexOf(nextConfig.HorseEffAttrIDList, attrID);
                if (effIndex >= 0 && nextConfig.HorseEffAttrValueList != null && effIndex < nextConfig.HorseEffAttrValueList.Length)
                {
                    oldAttrValue -= nextConfig.HorseEffAttrValueList[effIndex];
                }
            }
            // 左边显示升阶前的旧值
            riderAttrValueText.text = PlayerPropertyConfig.GetValueDescription(attrID, (long)(oldAttrValue * multi), 2);
            riderAttrValueText.text = PlayerPropertyConfig.GetValueDescription(attrID, oldAttrValue, 2);
            // 右边显示升阶后的新值
            riderNextAttrValueText.text = PlayerPropertyConfig.GetValueDescription(attrID, (long)(newAttrValue * multi), 2);
            riderNextAttrValueText.text = PlayerPropertyConfig.GetValueDescription(attrID, newAttrValue, 2);
        }
    }
}
Main/System/Horse/HorseWin.cs
@@ -231,16 +231,14 @@
        nameText.text = isChangeState ? HorseSkinConfig.Get(nowSkinID).Name : horseIdSkinConfig.Name;
        HorseIDConfig horseIDConfig = HorseIDConfig.Get(showHorseID);
        float attrMultiValue = horseIDConfig.AttrMultiValue;
        var attrConfig = PlayerPropertyConfig.Get(horseIDConfig.AttrID);
        bool hasAttr = attrConfig != null;
        bool hasAttr = HorseManager.Instance.GetNowRiderTotalAttrInfo(out int attrID, out long value, out PlayerPropertyConfig playerPropertyConfig);
        attrImg.SetActive(hasAttr);
        noAttrTxt.SetActive(!hasAttr);
        if (hasAttr)
        {
            attrTxt.text = StringUtility.Concat(attrConfig.ShowName, " ", "+", PlayerPropertyConfig.GetValueDescription(horseIDConfig.AttrID, GetAttrValue(horseIDConfig.AttrID, attrMultiValue)));
            attrTxt.text = StringUtility.Concat(playerPropertyConfig.ShowName, " ", "+", PlayerPropertyConfig.GetValueDescription(attrID, value));
        }
        useBtn.SetActive(carouselView.CurrentHorseId != nowhorseID && HorseManager.Instance.IsHorseUnlocked(carouselView.CurrentHorseId));
        usingTxt.SetActive(carouselView.CurrentHorseId == nowhorseID);
@@ -253,28 +251,6 @@
        }
    }
    public int GetAttrValue(int attrID, float attrMultiValue)
    {
        int totalValue = 0;
        int currentClassLV = HorseManager.Instance.classLV;
        // 从0阶累加到当前阶
        for (int lv = 0; lv <= currentClassLV; lv++)
        {
            var config = HorseClassConfig.Get(lv);
            if (config.ClassSpecAttrIDList != null)
            {
                int index = Array.IndexOf(config.ClassSpecAttrIDList, attrID);
                if (index >= 0 && config.ClassSpecAttrValueList != null && index < config.ClassSpecAttrValueList.Length)
                {
                    totalValue += config.ClassSpecAttrValueList[index];
                }
            }
        }
        return totalValue * (int)attrMultiValue;
    }
    void Display()
    {