卡牌更新
This commit is contained in:
@@ -44,41 +44,31 @@ namespace Continentis.MainGame.Character
|
||||
public partial class CharacterBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取角色的属性值,自动判断属性组(Core/General)
|
||||
/// 获取角色的属性值
|
||||
/// </summary>
|
||||
public int GetAttribute(string attributeName, int defaultValue = 0)
|
||||
{
|
||||
if (attributeSubmodule.coreAttributeGroup.current.ContainsKey(attributeName))
|
||||
{
|
||||
return attributeSubmodule.GetCurrentCoreAttribute(attributeName);
|
||||
}
|
||||
|
||||
if (attributeSubmodule.generalAttributeGroup.current.ContainsKey(attributeName))
|
||||
{
|
||||
return attributeSubmodule.GetGeneralAttribute(attributeName);
|
||||
}
|
||||
|
||||
Debug.LogWarning($"Attribute {attributeName} not found in any attribute group.");
|
||||
Debug.LogWarning($"Attribute {attributeName} not found in attribute group.");
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取角色的原始属性值,自动判断属性组(Core/General)
|
||||
/// 获取角色的原始属性值
|
||||
/// 如果属性名包含“Multiplier”,默认值改为1
|
||||
/// </summary>
|
||||
public float GetRawAttribute(string attributeName, float defaultValue = 0)
|
||||
{
|
||||
if (attributeSubmodule.coreAttributeGroup.current.TryGetValue(attributeName, out float rawAttribute))
|
||||
{
|
||||
return rawAttribute;
|
||||
}
|
||||
|
||||
if (attributeSubmodule.generalAttributeGroup.current.TryGetValue(attributeName, out float attribute))
|
||||
{
|
||||
return attribute;
|
||||
}
|
||||
|
||||
Debug.LogWarning($"Attribute {attributeName} not found in any attribute group.");
|
||||
Debug.LogWarning($"Attribute {attributeName} not found in attribute group.");
|
||||
|
||||
if(attributeName.Contains("Multiplier"))
|
||||
{
|
||||
@@ -89,47 +79,55 @@ namespace Continentis.MainGame.Character
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置角色的属性值,自动判断属性组(Core/General)
|
||||
/// 设置角色的属性值
|
||||
/// </summary>
|
||||
/// <param name="attributeName"></param>
|
||||
/// <param name="value"></param>
|
||||
public void SetAttribute(string attributeName, int value)
|
||||
{
|
||||
if (attributeSubmodule.coreAttributeGroup.current.ContainsKey(attributeName))
|
||||
{
|
||||
attributeSubmodule.coreAttributeGroup.current[attributeName] = value;
|
||||
return;
|
||||
}
|
||||
|
||||
if (attributeSubmodule.generalAttributeGroup.current.ContainsKey(attributeName))
|
||||
{
|
||||
attributeSubmodule.generalAttributeGroup.current[attributeName] = value;
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.LogWarning($"Attribute {attributeName} not found in any attribute group.");
|
||||
Debug.LogWarning($"Attribute {attributeName} not found in attribute group.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改角色的属性值,自动判断属性组(Core/General)
|
||||
/// 修改角色的属性值
|
||||
/// </summary>
|
||||
/// <param name="attributeName"></param>
|
||||
/// <param name="delta"></param>
|
||||
public void ModifyAttribute(string attributeName, int delta)
|
||||
{
|
||||
if (attributeSubmodule.coreAttributeGroup.current.ContainsKey(attributeName))
|
||||
{
|
||||
attributeSubmodule.coreAttributeGroup.current[attributeName] += delta;
|
||||
return;
|
||||
}
|
||||
|
||||
if (attributeSubmodule.generalAttributeGroup.current.ContainsKey(attributeName))
|
||||
{
|
||||
attributeSubmodule.generalAttributeGroup.current[attributeName] += delta;
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.LogWarning($"Attribute {attributeName} not found in any attribute group.");
|
||||
Debug.LogWarning($"Attribute {attributeName} not found in attribute group.");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 修改角色的属性值并进行范围限制
|
||||
/// </summary>
|
||||
/// <returns>实际的添加或减少的数值(可能因为范围限制而小于 delta)</returns>
|
||||
public int ModifyAndClampAttribute(string attributeName, int delta, int min = 0, int max = int.MaxValue)
|
||||
{
|
||||
int currentAttribute = GetAttribute(attributeName);
|
||||
int actualModifiedValue = delta;
|
||||
if (delta < 0)
|
||||
{
|
||||
actualModifiedValue = Mathf.Min(-delta, currentAttribute - min);
|
||||
}
|
||||
else if (delta > 0)
|
||||
{
|
||||
actualModifiedValue = Mathf.Min(delta, max - currentAttribute);
|
||||
}
|
||||
|
||||
ModifyAttribute(attributeName, delta);
|
||||
ClampAttribute(attributeName, min, max);
|
||||
|
||||
return actualModifiedValue;
|
||||
}
|
||||
|
||||
public void ClampAttribute(string attributeName, int min, int max)
|
||||
|
||||
Reference in New Issue
Block a user