From 1b8f17e5f1c04c395e7713ec82e8d88fc95756c9 Mon Sep 17 00:00:00 2001
From: lcy <1459594991@qq.com>
Date: 星期三, 15 四月 2026 12:00:08 +0800
Subject: [PATCH] 603 【坐骑】坐骑优化-服务端 废弃AttrMultiValue,适配骑乘属性HorseEffAttrIDList+ClassSpecAttrValueList的累加
---
Main/System/Horse/HorseSuccessWin.cs | 38 ++++-----
Main/Config/Configs/HorseClassConfig.cs | 32 +++++++
Main/System/Horse/HorseManager.cs | 82 +++++++++++++++-----
Main/Config/Configs/HorseIDConfig.cs | 5 -
Main/System/Horse/HorseWin.cs | 30 ------
Main/System/Horse/HorseRankUPWin.cs | 45 +++++++----
6 files changed, 143 insertions(+), 89 deletions(-)
diff --git a/Main/Config/Configs/HorseClassConfig.cs b/Main/Config/Configs/HorseClassConfig.cs
index 9c9c0b0..96fdade 100644
--- a/Main/Config/Configs/HorseClassConfig.cs
+++ b/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)
{
diff --git a/Main/Config/Configs/HorseIDConfig.cs b/Main/Config/Configs/HorseIDConfig.cs
index 0b55719..0aafe4e 100644
--- a/Main/Config/Configs/HorseIDConfig.cs
+++ b/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)
{
diff --git a/Main/System/Horse/HorseManager.cs b/Main/System/Horse/HorseManager.cs
index 5af7aa5..733f170 100644
--- a/Main/System/Horse/HorseManager.cs
+++ b/Main/System/Horse/HorseManager.cs
@@ -41,7 +41,7 @@
// 鎺掑簭鍚庣殑鍧愰獞閰嶇疆缂撳瓨
private static List<HorseIDConfig> sortedHorseConfigs;
-
+
/// <summary>
/// 鑾峰彇鎺掑簭鍚庣殑鍧愰獞閰嶇疆鍒楄〃锛堝甫缂撳瓨锛�
/// </summary>
@@ -252,7 +252,6 @@
// 鏇存柊鐘舵��
horseIDState = netPack.HorseIDState;
- RefreshAttr();
OnUpdateHorseIDInfoEvent?.Invoke();
}
@@ -572,50 +571,93 @@
}
}
+ public bool GetNowRiderAttrInfo(out int attrID, out long value, out PlayerPropertyConfig playerPropertyConfig)
+ {
+ value = 0;
+ HorseIDConfig horseIDConfig = HorseIDConfig.Get(horseID);
+ attrID = horseIDConfig.AttrID;
+ for (int lv = 0; lv <= classLV; lv++)
+ {
+ 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;
+ }
+
+
+ Dictionary<int, long> mergedResultDic = new Dictionary<int, long>();
public Dictionary<int, long> GetMergedAttrDic()
{
- Dictionary<int, long> resultDic = new Dictionary<int, long>();
+ mergedResultDic.Clear();
// 鍚堝苟 specialAttrDic
foreach (var kvp in specialAttrDic)
{
- resultDic[kvp.Key] = kvp.Value;
+ mergedResultDic[kvp.Key] = kvp.Value;
}
-
- HorseIDConfig horseIDConfig = HorseIDConfig.Get(horseID);
- int horseIDAttrID = horseIDConfig.AttrID;
- float attrMultiValue = horseIDConfig.AttrMultiValue;
- var keys = resultDic.Keys.ToList();
- foreach (var key in keys)
+ if (GetNowRiderAttrInfo(out int attrID, out long value, out PlayerPropertyConfig playerPropertyConfig))
{
- if (key == horseIDAttrID)
+ if (mergedResultDic.TryGetValue(attrID, out long existingValue))
{
- resultDic[key] = (long)(resultDic[key] * attrMultiValue);
+ mergedResultDic[attrID] = existingValue + value;
+ }
+ else
+ {
+ mergedResultDic[attrID] = value;
}
}
-
+
// 鍚堝苟 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;
}
diff --git a/Main/System/Horse/HorseRankUPWin.cs b/Main/System/Horse/HorseRankUPWin.cs
index b7602ac..fc7ebb9 100644
--- a/Main/System/Horse/HorseRankUPWin.cs
+++ b/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);
- // 涓嬩竴闃剁殑灞炴�у��
- int index = Array.IndexOf(nextConfig.ClassSpecAttrIDList, attrID);
- if (index < 0 || index > nextConfig.ClassSpecAttrIDList.Length)
- return;
- long nextAttrValue = (long)((attrValue + nextConfig.ClassSpecAttrValueList[index]) * horseIDConfig.AttrMultiValue);
+ // 棰勬祴涓嬩竴闃剁殑灞炴�у��
+ long nextAttrValue = curAttrValue;
+
+ if (nextConfig.ClassSpecAttrIDList != null)
+ {
+ // 鍔犱笂涓嬩竴闃跺鍔犵殑 ClassSpecAttrValue
+ int index = Array.IndexOf(nextConfig.ClassSpecAttrIDList, attrID);
+ 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);
}
-
}
//鍗囬樁
diff --git a/Main/System/Horse/HorseSuccessWin.cs b/Main/System/Horse/HorseSuccessWin.cs
index 82ccbf7..b80df53 100644
--- a/Main/System/Horse/HorseSuccessWin.cs
+++ b/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 鍒楄〃涓鎵惧搴斿睘鎬х殑绱㈠紩
+ // 鎵i櫎鍒氬鍔犵殑 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)
+ {
+ // 鎵i櫎鍒氬鍔犵殑 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);
}
-
}
}
\ No newline at end of file
diff --git a/Main/System/Horse/HorseWin.cs b/Main/System/Horse/HorseWin.cs
index 8d5fe3a..9f8ef9f 100644
--- a/Main/System/Horse/HorseWin.cs
+++ b/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()
{
--
Gitblit v1.8.0