Files
Continentis/Assets/Scripts/MainGame/Card/CardData/CardData.cs

202 lines
9.9 KiB
C#
Raw Normal View History

2025-10-03 00:02:43 -04:00
using System;
using System.Collections.Generic;
using Continentis.MainGame.Character;
2025-10-23 00:49:44 -04:00
using SLSFramework.General;
2026-03-20 11:56:50 -04:00
using Sirenix.OdinInspector;
2025-10-23 00:49:44 -04:00
using SLSFramework.UModAssistance;
2026-03-20 11:56:50 -04:00
using UnityEngine;
2025-10-03 00:02:43 -04:00
using UnityEngine.Serialization;
namespace Continentis.MainGame.Card
{
public enum CardType
{
Attack = 0,
2026-03-20 11:56:50 -04:00
Skill = 10,
Power = 20,
2025-10-03 00:02:43 -04:00
Status = 30,
2026-03-20 11:56:50 -04:00
Curse = 40,
Item = 50,
2025-10-03 00:02:43 -04:00
}
2025-10-27 07:04:34 -04:00
2026-03-20 11:56:50 -04:00
// ─────────────────────────────────────────────────────────────────────────
// CardData — ScriptableObject 数据定义
// ─────────────────────────────────────────────────────────────────────────
2025-10-03 00:02:43 -04:00
[CreateAssetMenu(menuName = "Continentis/MainGame/Card/CardData", fileName = "CardData")]
2025-10-23 00:49:44 -04:00
public partial class CardData : ScriptableObject
2025-10-03 00:02:43 -04:00
{
2026-03-20 11:56:50 -04:00
// ── Fundamental ───────────────────────────────────────────────────────
[BoxGroup("Fundamental"), PropertyOrder(0)]
[ValueDropdown("@CardData.GetCardLogicDropdownItems()", AppendNextDrawer = true, DisableGUIInAppendedDrawer = true)]
[LabelText("逻辑类名"), OnValueChanged("OnCardLogicClassSelected")]
public string className;
[BoxGroup("Fundamental"), PropertyOrder(1)]
[ReadOnly, LabelText("Mod 名称")]
2025-11-10 11:18:19 -05:00
public string modName;
2026-03-20 11:56:50 -04:00
[BoxGroup("Fundamental"), PropertyOrder(2)]
[ReadOnly, LabelText("分类名称")]
2025-11-10 11:18:19 -05:00
public string categoryName;
2026-03-20 11:56:50 -04:00
[BoxGroup("Fundamental"), PropertyOrder(3)]
[ReadOnly, LabelText("显示名称 Key")]
2025-10-23 00:49:44 -04:00
public string displayName;
2026-03-20 11:56:50 -04:00
[BoxGroup("Fundamental"), PropertyOrder(4)]
[LabelText("稀有度")]
2025-10-23 00:49:44 -04:00
public Rarity cardRarity;
2026-03-20 11:56:50 -04:00
[BoxGroup("Fundamental"), PropertyOrder(5)]
[LabelText("卡牌类型")]
2025-10-03 00:02:43 -04:00
public CardType cardType;
2026-03-20 11:56:50 -04:00
[BoxGroup("Fundamental"), PropertyOrder(6)]
[ListDrawerSettings(ShowIndexLabels = false, DraggableItems = true)]
[ValueDropdown("GetAvailableKeywords", AppendNextDrawer = true)]
[LabelText("关键词")]
2025-10-27 07:04:34 -04:00
public List<string> keywords;
2026-03-20 11:56:50 -04:00
// ── Display ───────────────────────────────────────────────────────────
2025-10-27 07:04:34 -04:00
2026-03-20 11:56:50 -04:00
[BoxGroup("Display"), PropertyOrder(7)]
[PreviewField(80, ObjectFieldAlignment.Left)]
[LabelText("卡牌图片")]
public Sprite cardSprite;
[BoxGroup("Display"), PropertyOrder(8)]
[LabelText("功能文本 Key")]
2025-10-23 00:49:44 -04:00
public string functionText;
2026-03-20 11:56:50 -04:00
2026-04-01 12:23:27 -04:00
[FormerlySerializedAs("cardDescription")]
2026-03-20 11:56:50 -04:00
[BoxGroup("Display"), PropertyOrder(9)]
[LabelText("卡牌描述 Key")]
2026-04-01 12:23:27 -04:00
public string descriptionText;
2026-03-20 11:56:50 -04:00
[BoxGroup("Display"), PropertyOrder(10)]
[ListDrawerSettings(ShowIndexLabels = false), LabelText("布局标签")]
public List<string> cardLayoutTags;
2025-10-27 07:04:34 -04:00
2026-03-20 11:56:50 -04:00
// ── Attributes ────────────────────────────────────────────────────────
2025-10-27 07:04:34 -04:00
2026-03-20 11:56:50 -04:00
[TabGroup("Data", "属性"), PropertyOrder(20)]
[DictionaryDrawerSettings(KeyLabel = "属性名", ValueLabel = "属性值")]
[Tooltip("可变属性:自动设置 BaseAttr → Original设置 Attr / BaseAttrOffset=0 / DisplayAttr → Current")]
[LabelText("可变属性 (Variable)")]
2025-10-23 00:49:44 -04:00
public SerializableDictionary<string, float> variableAttributes = new SerializableDictionary<string, float>();
2025-10-27 07:04:34 -04:00
2026-03-20 11:56:50 -04:00
[TabGroup("Data", "属性"), PropertyOrder(21)]
[DictionaryDrawerSettings(KeyLabel = "属性名", ValueLabel = "属性值")]
[Tooltip("基础属性,运行时不会改变,通常不直接使用。")]
[LabelText("基础属性 (Original)")]
2025-10-23 00:49:44 -04:00
public SerializableDictionary<string, float> originalAttributes = new SerializableDictionary<string, float>();
2025-10-27 07:04:34 -04:00
2026-03-20 11:56:50 -04:00
[TabGroup("Data", "属性"), PropertyOrder(22)]
[DictionaryDrawerSettings(KeyLabel = "属性名", ValueLabel = "初始值表达式")]
2025-10-27 07:04:34 -04:00
[FormerlySerializedAs("endowingCurrentAttributes")]
2026-03-20 11:56:50 -04:00
[Tooltip("运行时当前属性Value 填写对应 OriginalAttributes 的 Key 名,或直接填浮点数,留空则默认为 0。")]
[LabelText("运行时当前属性 (Runtime Current)")]
2025-10-23 00:49:44 -04:00
public SerializableDictionary<string, string> runtimeCurrentAttributes = new SerializableDictionary<string, string>();
2025-10-03 00:02:43 -04:00
2026-03-20 11:56:50 -04:00
// ── Upgrade ───────────────────────────────────────────────────────────
[TabGroup("Data", "升级"), PropertyOrder(40)]
[HideLabel]
public CardUpgradeNode upgradeNode;
// ── References ────────────────────────────────────────────────────────
[TabGroup("Data", "引用"), PropertyOrder(50)]
[ListDrawerSettings(ShowIndexLabels = false, DraggableItems = false)]
[ValueDropdown("GetAvailablePrefabs", AppendNextDrawer = true)]
[LabelText("Prefab 引用")]
public List<string> prefabRefs = new List<string>();
2025-10-27 07:04:34 -04:00
2026-03-20 11:56:50 -04:00
[TabGroup("Data", "引用"), PropertyOrder(51)]
[ListDrawerSettings(ShowIndexLabels = false, DraggableItems = false)]
[ValueDropdown("GetAvailableCardData", AppendNextDrawer = true)]
[LabelText("衍生卡牌数据引用")]
2025-10-23 00:49:44 -04:00
public List<string> derivativeCardDataRefs = new List<string>();
2026-03-20 11:56:50 -04:00
[TabGroup("Data", "引用"), PropertyOrder(52)]
[ListDrawerSettings(ShowIndexLabels = false, DraggableItems = false)]
[ValueDropdown("GetAvailableCharacterData", AppendNextDrawer = true)]
[LabelText("衍生角色数据引用")]
2025-10-23 00:49:44 -04:00
public List<string> derivativeCharacterDataRefs = new List<string>();
2026-03-20 11:56:50 -04:00
// ── Intention ────────────────────────────────────────────────────────
[TabGroup("Data", "意图"), PropertyOrder(60)]
[ListDrawerSettings(ShowIndexLabels = false)]
[ValueDropdown("GetAvailableIntentionIcons", AppendNextDrawer = true)]
[LabelText("意图图标 Keys")]
public List<string> intentionIconKeys;
[TabGroup("Data", "意图"), PropertyOrder(61)]
[ListDrawerSettings(ShowIndexLabels = false)]
[ValueDropdown("GetVariableAttributeKeys", AppendNextDrawer = true)]
[LabelText("意图数值名")]
public List<string> intentionValueNames;
[TabGroup("Data", "意图"), PropertyOrder(62)]
[LabelText("意图文本覆盖")]
public string intentionTextOverride;
[FormerlySerializedAs("baseWeight")]
[TabGroup("Data", "意图"), PropertyOrder(63)]
[LabelText("基础权重"), Range(0f, 100f)]
public float intentionBaseWeight = 0f;
2025-10-23 00:49:44 -04:00
}
2026-03-20 11:56:50 -04:00
// ─────────────────────────────────────────────────────────────────────────
// Runtime: 关键词查询
// ─────────────────────────────────────────────────────────────────────────
2025-10-23 00:49:44 -04:00
public partial class CardData
{
2026-03-20 11:56:50 -04:00
/// <summary>
/// 检查此卡牌是否包含指定关键词。
/// </summary>
2025-10-23 00:49:44 -04:00
public bool HasKeyword(string keyword)
{
2025-10-27 07:04:34 -04:00
return keywords.Contains(keyword);
2025-10-23 00:49:44 -04:00
}
}
2026-03-20 11:56:50 -04:00
// ─────────────────────────────────────────────────────────────────────────
// Runtime: 数据库查询
// ─────────────────────────────────────────────────────────────────────────
2025-10-23 00:49:44 -04:00
public partial class CardData
{
2026-03-20 11:56:50 -04:00
/// <summary>
/// 通过 DataID 从 ModManager 数据库查找 CardData。
/// </summary>
2025-10-23 00:49:44 -04:00
public static CardData Get(string dataID)
{
return ModManager.GetData<CardData>(dataID);
}
2025-10-03 00:02:43 -04:00
}
2025-10-27 07:04:34 -04:00
2026-03-20 11:56:50 -04:00
// ─────────────────────────────────────────────────────────────────────────
// Runtime: 衍生数据访问
// ─────────────────────────────────────────────────────────────────────────
2025-10-03 00:02:43 -04:00
public partial class CardData
{
/// <summary>
2026-03-20 11:56:50 -04:00
/// 通过索引获取衍生卡牌数据。
2025-10-03 00:02:43 -04:00
/// </summary>
2025-10-23 00:49:44 -04:00
public CardData GetDerivativeCardData(int index)
2025-10-03 00:02:43 -04:00
{
2025-10-23 00:49:44 -04:00
return ModManager.GetData<CardData>(derivativeCardDataRefs[index]);
}
2025-10-27 07:04:34 -04:00
2025-10-23 00:49:44 -04:00
/// <summary>
2026-03-20 11:56:50 -04:00
/// 通过索引获取衍生角色数据。
2025-10-23 00:49:44 -04:00
/// </summary>
public CharacterData GetDerivativeCharacterData(int index)
{
return ModManager.GetData<CharacterData>(derivativeCharacterDataRefs[index]);
2025-10-03 00:02:43 -04:00
}
}
2026-03-20 11:56:50 -04:00
}