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

100 lines
3.2 KiB
C#
Raw Normal View History

2025-10-03 00:02:43 -04:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Continentis.MainGame.Character;
2025-10-23 00:49:44 -04:00
using SLSFramework.General;
2025-10-03 00:02:43 -04:00
using UnityEngine;
2025-10-23 00:49:44 -04:00
using NaughtyAttributes;
using SLSFramework.UModAssistance;
2025-10-03 00:02:43 -04:00
using UnityEngine.Serialization;
2025-10-23 00:49:44 -04:00
#if UNITY_EDITOR
using UnityEditor;
#endif
2025-10-03 00:02:43 -04:00
namespace Continentis.MainGame.Card
{
public enum CardType
{
Attack = 0,
Skill = 10,
Power = 20,
Status = 30,
Curse = 40,
Item = 50,
}
2025-10-27 07:04:34 -04:00
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
{
2025-10-27 07:04:34 -04:00
[Header("Fundamental")] public string modName;
2025-10-24 09:11:22 -04:00
public string className;
2025-10-23 00:49:44 -04:00
public string displayName;
public Rarity cardRarity;
2025-10-03 00:02:43 -04:00
public CardType cardType;
2025-10-27 07:04:34 -04:00
public List<string> keywords;
2025-10-03 00:02:43 -04:00
public Sprite cardSprite;
2025-10-27 07:04:34 -04:00
public List<string> cardLayoutTags;
2025-10-23 00:49:44 -04:00
public string functionText;
2025-10-03 00:02:43 -04:00
public string cardDescription;
2025-10-27 07:04:34 -04:00
[Header("Intention")] public float baseWeight = 1f;
[Header("Attributes")] [Tooltip("可变属性这个属性会自动设置BaseAttr进入Original设置AttrBaseAttrOffset=0以及DisplayAttr进入Current")]
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
2025-10-03 00:02:43 -04:00
[Tooltip("基础属性,不会改变,通常情况下不会直接使用")]
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
[FormerlySerializedAs("endowingCurrentAttributes")]
[Tooltip("初始化时赋予给CurrentAttributes的属性第一栏是属性名第二栏是初始化时使用对应名称的OriginalAttributes的留空则默认为0如果是float数字则直接使用该数字")]
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
2025-10-27 07:04:34 -04:00
[Header("Upgrade")] public CardUpgradeNode upgradeNode;
[Header("References")] public List<string> prefabRefs = new List<string>();
2025-10-23 00:49:44 -04:00
public List<string> derivativeCardDataRefs = new List<string>();
public List<string> derivativeCharacterDataRefs = new List<string>();
}
public partial class CardData
{
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
}
}
public partial class CardData
{
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
2025-10-03 00:02:43 -04:00
public partial class CardData
{
2025-10-27 07:04:34 -04:00
2025-10-03 00:02:43 -04:00
/// <summary>
2025-10-23 00:49:44 -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>
/// 通过索引获取衍生角色数据
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public CharacterData GetDerivativeCharacterData(int index)
{
return ModManager.GetData<CharacterData>(derivativeCharacterDataRefs[index]);
2025-10-03 00:02:43 -04:00
}
}
}