Files
Continentis/Assets/Scripts/MainGame/Character/CharacterAssistanceFunctions.cs

91 lines
3.2 KiB
C#
Raw Normal View History

2025-10-03 00:02:43 -04:00
using UnityEngine;
namespace Continentis.MainGame.Character
{
#region Attributes
public partial class CharacterBase
{
/// <summary>
/// 获取角色的属性值自动判断属性组Core/General
/// </summary>
/// <param name="attributeName"></param>
/// <returns></returns>
public int GetAttribute(string attributeName)
{
if (attributeSubmodule.coreAttributeGroup.current.ContainsKey(attributeName))
{
return attributeSubmodule.GetRoundCurrentCoreAttribute(attributeName);
}
if (attributeSubmodule.generalAttributeGroup.current.ContainsKey(attributeName))
{
return attributeSubmodule.GetRoundCurrentGeneralAttribute(attributeName);
}
Debug.LogWarning($"Attribute {attributeName} not found in any attribute group.");
return 0;
}
public float GetRawAttribute(string attributeName)
{
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.");
return 0;
}
/// <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.");
}
/// <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.");
}
}
#endregion
}