2025-11-25 08:19:33 -05:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
2026-01-03 18:19:39 -05:00
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2025-11-25 08:19:33 -05:00
|
|
|
|
namespace Cielonos.MainGame.Characters
|
|
|
|
|
|
{
|
|
|
|
|
|
[CreateAssetMenu(fileName = "AttributesData", menuName = "Cielonos/Characters/AttributesData", order = 1)]
|
2026-01-03 18:19:39 -05:00
|
|
|
|
public partial class AttributeData : SerializedScriptableObject
|
2025-11-25 08:19:33 -05:00
|
|
|
|
{
|
2026-01-03 18:19:39 -05:00
|
|
|
|
[Title("Attributes")] [Tooltip("角色的通常属性:第一栏是属性名,第二栏是属性值")]
|
2025-11-25 08:19:33 -05:00
|
|
|
|
public Dictionary<string, float> originalAttributes;
|
2026-01-03 18:19:39 -05:00
|
|
|
|
|
2025-11-25 08:19:33 -05:00
|
|
|
|
[Tooltip("初始化时赋予给CurrentAttributes的属性:第一栏是属性名,第二栏是初始化时使用对应名称的originalAttributes的数据,留空则默认为0,如果是float数字则直接使用该数字")]
|
|
|
|
|
|
public Dictionary<string, string> runtimeAttributes;
|
|
|
|
|
|
}
|
2026-01-03 18:19:39 -05:00
|
|
|
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
|
public partial class AttributeData
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 从项目中得到AttributeCollection组件,并将其数据复制到此ScriptableObject中。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Button("Paste Attributes From Collection")]
|
|
|
|
|
|
public void PasteAttributesFromCollection()
|
|
|
|
|
|
{
|
|
|
|
|
|
string[] collectionID = AssetDatabase.FindAssets("t:AttributeCollection");
|
|
|
|
|
|
if (collectionID.Length == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogWarning("No AttributeCollection found in the project.");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string collectionPath = AssetDatabase.GUIDToAssetPath(collectionID[0]);
|
|
|
|
|
|
AttributeCollection collection = AssetDatabase.LoadAssetAtPath<AttributeCollection>(collectionPath);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (KeyValuePair<string, float> pair in collection.originalAttributes)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!originalAttributes.ContainsKey(pair.Key))
|
|
|
|
|
|
{
|
|
|
|
|
|
originalAttributes.Add(pair.Key, pair.Value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (KeyValuePair<string, string> pair in collection.runtimeAttributes)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!runtimeAttributes.ContainsKey(pair.Key))
|
|
|
|
|
|
{
|
|
|
|
|
|
runtimeAttributes.Add(pair.Key, pair.Value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
2025-11-25 08:19:33 -05:00
|
|
|
|
}
|