2025-10-03 00:02:43 -04:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using Continentis.MainGame.Character;
|
2025-10-24 09:11:22 -04:00
|
|
|
|
using Continentis.MainGame.Equipment;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
using SLSFramework.General;
|
2025-10-24 09:11:22 -04:00
|
|
|
|
using SLSFramework.UModAssistance;
|
2025-11-08 09:50:55 -05:00
|
|
|
|
using UniRx;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Continentis.MainGame.Card
|
|
|
|
|
|
{
|
|
|
|
|
|
public abstract partial class CardLogicBase
|
|
|
|
|
|
{
|
2025-10-24 09:11:22 -04:00
|
|
|
|
[Header("Reference")]
|
2025-11-15 12:17:34 -05:00
|
|
|
|
public CardInstance card;
|
|
|
|
|
|
public CardData cardData => card.cardData;
|
|
|
|
|
|
public CharacterBase user => card.user;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
public HashSet<CardLogicComponentBase> logicComponents { get; private set; }
|
|
|
|
|
|
|
2025-10-24 09:11:22 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 生成卡牌逻辑实例
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static CardLogicBase GenerateCardLogic(CardData data)
|
|
|
|
|
|
{
|
2025-11-10 12:57:04 -05:00
|
|
|
|
string typeID = ModManager.GetTypeID(data.modName, "Cards", data.categoryName, data.className);
|
2025-10-24 09:11:22 -04:00
|
|
|
|
Type logicType = ModManager.GetType(typeID);
|
|
|
|
|
|
|
|
|
|
|
|
if(logicType == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError($"Card class '{typeID}' not found in assemblies.");
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (Activator.CreateInstance(logicType) is CardLogicBase cardLogic)
|
|
|
|
|
|
{
|
|
|
|
|
|
return cardLogic;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Debug.LogError($"Card class '{typeID}' not found or could not be instantiated.");
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-15 12:17:34 -05:00
|
|
|
|
public virtual void Initialize(CardInstance cardInstance)
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2025-11-15 12:17:34 -05:00
|
|
|
|
card = cardInstance;
|
|
|
|
|
|
logicComponents = new HashSet<CardLogicComponentBase>();
|
|
|
|
|
|
card.eventSubmodule.onTargeting += TargetingEffect;
|
|
|
|
|
|
card.eventSubmodule.onUntargeting += UntargetingEffect;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-15 12:17:34 -05:00
|
|
|
|
public virtual void SetUpLogicComponents()
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2025-11-08 09:50:55 -05:00
|
|
|
|
|
2025-10-23 00:49:44 -04:00
|
|
|
|
}
|
2025-11-15 12:17:34 -05:00
|
|
|
|
|
2025-10-23 00:49:44 -04:00
|
|
|
|
public T AddLogicComponent<T>() where T : CardLogicComponentBase, new()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (logicComponents.Any(component => component is T))
|
|
|
|
|
|
{
|
2025-11-15 12:17:34 -05:00
|
|
|
|
Debug.LogWarning($"Card {card.cardData.className} already has component of type {typeof(T)}, cannot add duplicate.");
|
2025-10-23 00:49:44 -04:00
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
T component = new T();
|
|
|
|
|
|
component.Initialize(this);
|
|
|
|
|
|
logicComponents.Add(component);
|
|
|
|
|
|
return component;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public T LogicComponent<T>() where T : CardLogicComponentBase
|
|
|
|
|
|
{
|
|
|
|
|
|
return logicComponents.OfType<T>().FirstOrDefault();
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-15 12:17:34 -05:00
|
|
|
|
public virtual void ApplyAttributeChangesByCard()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual List<CommandBase> PlayEffect(List<CharacterBase> targetList)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void AfterPlayEffect(List<CharacterBase> targetList)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region Attributes
|
|
|
|
|
|
public partial class CardLogicBase
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置可变属性值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="attributeName">属性名,通常为</param>
|
|
|
|
|
|
/// <param name="additive">是否为叠加,true为叠加,false为覆盖,true时,originalValue为外部传入值</param>
|
|
|
|
|
|
/// <param name="originalValue">原始伤害值,仅在additive为true时有效,否则此值被覆盖为BaseAttribute</param>
|
|
|
|
|
|
/// <param name="baseOffset">伤害增量</param>
|
|
|
|
|
|
public void SetVariableAttribute(string attributeName, int baseOffset, bool additive = false, int originalValue = 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
card.SetVariableAttribute(attributeName, baseOffset, additive, originalValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 检查卡牌是否具有某属性
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool HasAttribute(string attributeName)
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2025-11-15 12:17:34 -05:00
|
|
|
|
return card.HasAttribute(attributeName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取卡牌的属性值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int GetAttribute(string attributeName, int defaultValue = 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return card.GetAttribute(attributeName, defaultValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public float GetRawAttribute(string attributeName, float defaultValue = 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return card.GetRawAttribute(attributeName, defaultValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置卡牌的属性值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void SetAttribute(string attributeName, int value)
|
|
|
|
|
|
{
|
|
|
|
|
|
card.SetAttribute(attributeName, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置卡牌的属性值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void SetAttribute(string attributeName, float value)
|
|
|
|
|
|
{
|
|
|
|
|
|
card.SetAttribute(attributeName, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 修改卡牌的属性值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void ModifyAttribute(string attributeName, int delta)
|
|
|
|
|
|
{
|
|
|
|
|
|
card.ModifyAttribute(attributeName, delta);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Command
|
|
|
|
|
|
|
|
|
|
|
|
public partial class CardLogicBase
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 创建一个命令组,组内命令按顺序执行
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="commands">命令模板</param>
|
|
|
|
|
|
protected CommandGroup SingleCommandGroup(params CommandBase[] commands)
|
|
|
|
|
|
{
|
|
|
|
|
|
return SingleCommandGroup(ExecutionMode.Parallel, commands);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 创建一个命令组,组内命令按指定顺序执行
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="executionMode">执行模式,顺序或并行</param>
|
|
|
|
|
|
/// <param name="commands">命令模板</param>
|
|
|
|
|
|
protected virtual CommandGroup SingleCommandGroup(
|
|
|
|
|
|
ExecutionMode executionMode = ExecutionMode.Parallel, params CommandBase[] commands)
|
|
|
|
|
|
{
|
|
|
|
|
|
CommandGroup singleGroup = new CommandGroup(executionMode);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (CommandBase template in commands)
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2025-11-15 12:17:34 -05:00
|
|
|
|
singleGroup.AddCommand(template.Clone());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return singleGroup;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 对目标列表中的每个目标,依次执行一组有参函数命令,每组命令的参数为targetList中的个体,主体Group顺序执行,单体Group并行执行。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="targetList">目标列表</param>
|
|
|
|
|
|
/// <param name="singleCommands">单体命令模板</param>
|
|
|
|
|
|
protected CommandGroup TargetListCommandGroup(List<CharacterBase> targetList,
|
|
|
|
|
|
params CommandBase[] singleCommands)
|
|
|
|
|
|
{
|
|
|
|
|
|
return TargetListCommandGroup(targetList, ExecutionMode.Sequential, ExecutionMode.Parallel,
|
|
|
|
|
|
singleCommands);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 对目标列表中的每个目标,依次执行一组有参函数命令,每组命令的参数为targetList中的个体。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="targetList">目标列表</param>
|
|
|
|
|
|
/// <param name="mainExecutionMode">主体Group(各个目标)的执行顺序</param>
|
|
|
|
|
|
/// <param name="singleExecutionMode">单体Group(一个目标中指令)的执行顺序</param>
|
|
|
|
|
|
/// <param name="singleCommands">单体命令模板</param>
|
|
|
|
|
|
protected virtual CommandGroup TargetListCommandGroup(
|
|
|
|
|
|
List<CharacterBase> targetList, ExecutionMode mainExecutionMode = ExecutionMode.Sequential,
|
|
|
|
|
|
ExecutionMode singleExecutionMode = ExecutionMode.Parallel,
|
|
|
|
|
|
params CommandBase[] singleCommands)
|
|
|
|
|
|
{
|
|
|
|
|
|
CommandGroup mainGroup = new CommandGroup(mainExecutionMode);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (CharacterBase target in targetList)
|
|
|
|
|
|
{
|
|
|
|
|
|
CommandGroup singleGroup = new CommandGroup(singleExecutionMode);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (CommandBase template in singleCommands)
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2025-11-15 12:17:34 -05:00
|
|
|
|
CommandBase clone = template.Clone();
|
|
|
|
|
|
|
|
|
|
|
|
List<CommandBase> allCommands = new List<CommandBase>();
|
|
|
|
|
|
|
|
|
|
|
|
if (clone is CommandGroup group)
|
|
|
|
|
|
{
|
|
|
|
|
|
allCommands.AddRange(group.GetAllCommands(true));
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
allCommands.Add(clone);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (CommandBase cmd in allCommands)
|
|
|
|
|
|
{
|
|
|
|
|
|
cmd.selfContext.context["Target"] = target;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
singleGroup.AddCommand(clone);
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
2025-11-15 12:17:34 -05:00
|
|
|
|
|
|
|
|
|
|
mainGroup.AddCommand(singleGroup);
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
2025-11-15 12:17:34 -05:00
|
|
|
|
|
|
|
|
|
|
return mainGroup;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Attack
|
|
|
|
|
|
public partial class CardLogicBase
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取最终伤害
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="target">目标</param>
|
|
|
|
|
|
/// <param name="elementalTags">元素标签,若为null则使用卡牌的元素标签</param>
|
|
|
|
|
|
public virtual int GetTargetedFinalDamage(CharacterBase target, List<string> elementalTags = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetFinalDamage(target, elementalTags, out _, out _, out _, out _);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取最终伤害
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="elementalTags">元素标签,若为null则使用卡牌的元素标签</param>
|
|
|
|
|
|
public virtual int GetNoTargetFinalDamage(List<string> elementalTags = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetFinalDamage(null, elementalTags, out _, out _, out _, out _);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual int GetFinalDamage(CharacterBase target, List<string> elementalTags,
|
|
|
|
|
|
out float baseDamageAfterOffset, out float elementalMultiplier,
|
|
|
|
|
|
out float magicMultiplier, out float finalMultiplier)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool haveTarget = target != null;
|
|
|
|
|
|
|
|
|
|
|
|
elementalTags ??= card.GetElementalKeywords();
|
|
|
|
|
|
|
|
|
|
|
|
//----计算基础伤害增量----
|
|
|
|
|
|
int physicsOffset = 0;
|
|
|
|
|
|
if (card.HasKeyword("Physics") || card.HasKeyword("Slash") || card.HasKeyword("Prick") || card.HasKeyword("Strike"))
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2025-11-15 12:17:34 -05:00
|
|
|
|
physicsOffset = user.GetAttribute("PhysicsDamageDealtOffset"); //物理伤害基础增量
|
|
|
|
|
|
}
|
2025-10-23 00:49:44 -04:00
|
|
|
|
|
2025-11-15 12:17:34 -05:00
|
|
|
|
int magicOffset = 0;
|
|
|
|
|
|
if (card.HasKeyword("Magic") || card.HasKeyword("Arcane") || card.HasKeyword("Sorcery"))
|
|
|
|
|
|
{
|
|
|
|
|
|
magicOffset = user.GetAttribute("MagicDamageDealtOffset"); //魔法伤害基础增量
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----计算伤害因数----
|
|
|
|
|
|
|
|
|
|
|
|
//计算元素伤害加成,注意,“物理Physics”也是一种元素,因此下方没有“通用物理伤害加成”的计算
|
|
|
|
|
|
elementalMultiplier = 1;
|
|
|
|
|
|
foreach (string element in elementalTags)
|
|
|
|
|
|
{
|
|
|
|
|
|
float targetGain = haveTarget ? target.GetRawAttribute(element + "DamageGainMultiplier", 1) : 1;
|
|
|
|
|
|
|
|
|
|
|
|
elementalMultiplier *= user.GetRawAttribute(element + "DamageDealtMultiplier", 1) * targetGain;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//计算通用的魔法伤害加成
|
|
|
|
|
|
magicMultiplier = 1;
|
|
|
|
|
|
if (card.HasKeyword("Magic") || card.HasKeyword("Arcane") || card.HasKeyword("Sorcery"))
|
|
|
|
|
|
{
|
|
|
|
|
|
float targetGain = haveTarget ? target.GetRawAttribute("MagicDamageGainMultiplier", 1) : 1;
|
|
|
|
|
|
|
|
|
|
|
|
magicMultiplier = user.GetRawAttribute("MagicDamageDealtMultiplier", 1) * targetGain;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//计算最终伤害加成
|
|
|
|
|
|
float targetFinalGain = haveTarget ? target.GetRawAttribute("FinalDamageGainMultiplier", 1) : 1;
|
|
|
|
|
|
finalMultiplier = user.GetRawAttribute("FinalDamageDealtMultiplier", 1) * targetFinalGain;
|
|
|
|
|
|
|
|
|
|
|
|
//----计算最终伤害----
|
|
|
|
|
|
baseDamageAfterOffset = card.attributeSubmodule.GetCurrentAttribute("Damage") + physicsOffset + magicOffset;
|
|
|
|
|
|
float finalDamage = baseDamageAfterOffset * elementalMultiplier * magicMultiplier * finalMultiplier;
|
|
|
|
|
|
|
|
|
|
|
|
return Mathf.RoundToInt(finalDamage);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Buffs
|
|
|
|
|
|
public partial class CardLogicBase
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 创建一个角色战斗Buff实例
|
|
|
|
|
|
/// 注意,此函数依赖ModManager的类型注册功能,请确保在Mod加载时已注册对应Buff类型
|
|
|
|
|
|
/// 此函数中的T并不是原型参数,而是获取Mod中注册的类型用的
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public T CreateCharacterBuff<T>(params object[] parameters) where T :CharacterCombatBuffBase
|
|
|
|
|
|
{
|
|
|
|
|
|
string buffTypeID = ModManager.GetTypeID(typeof(T));
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(buffTypeID))
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError($"Failed to get buff name for type {typeof(T).FullName}");
|
|
|
|
|
|
return null;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
2025-11-15 12:17:34 -05:00
|
|
|
|
|
|
|
|
|
|
return ModManager.CreateInstance<T>(buffTypeID, parameters);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public T CreateCharacterBuff<T>(string buffTypeID, params object[] parameters) where T :CharacterCombatBuffBase
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(buffTypeID))
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError($"Failed to get buff name for type {typeof(T).FullName}");
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return ModManager.CreateInstance<T>(buffTypeID, parameters);
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
2025-10-27 07:04:34 -04:00
|
|
|
|
|
2025-11-15 12:17:34 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 创建一个卡牌战斗Buff实例
|
|
|
|
|
|
/// 注意,此函数依赖ModManager的类型注册功能,请确保在Mod加载时已注册对应Buff类型
|
|
|
|
|
|
/// 此函数中的T并不是原型参数,而是获取Mod中注册的类型用的
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public T CreateCardBuff<T>(params object[] parameters) where T :CardBuffBase
|
|
|
|
|
|
{
|
|
|
|
|
|
string buffTypeID = ModManager.GetTypeID(typeof(T));
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(buffTypeID))
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError($"Failed to get buff name for type {typeof(T).FullName}");
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return ModManager.CreateInstance<T>(buffTypeID, parameters);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public T CreateCardBuff<T>(string buffTypeID, params object[] parameters) where T :CardBuffBase
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(buffTypeID))
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError($"Failed to get buff name for type {typeof(T).FullName}");
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return ModManager.CreateInstance<T>(buffTypeID, parameters);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
public abstract partial class CardLogicBase
|
|
|
|
|
|
{
|
2025-10-27 07:04:34 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取衍生卡牌数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public CardData GetDerivativeCardData(int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
return ModManager.GetData<CardData>(cardData.derivativeCardDataRefs[index]);
|
|
|
|
|
|
}
|
2025-10-30 12:07:59 -04:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取衍生卡牌数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public CardData GetDerivativeCardData(string dataName)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cardData.derivativeCardDataRefs.Contains(dataName))
|
|
|
|
|
|
{
|
|
|
|
|
|
return ModManager.GetData<CardData>(dataName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Debug.LogError($"Card {cardData.className} does not contain derivative card data '{dataName}'.");
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2025-11-15 12:17:34 -05:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 选中目标时触发的效果,效果在所有逻辑组件的Targeting之前执行(在SetUp函数生成EventSubmodule的时候)。
|
|
|
|
|
|
/// 如果必须需要在逻辑组件之后执行,请重写Initialize函数。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void TargetingEffect(CharacterBase target)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 取消选中目标时触发的效果,效果在所有逻辑组件的Untargeting之前执行(在SetUp函数生成EventSubmodule的时候)。
|
|
|
|
|
|
/// 如果必须需要在逻辑组件之后执行,请重写Initialize函数。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void UntargetingEffect()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
2025-10-23 00:49:44 -04:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 卡牌逻辑组件基类接口
|
|
|
|
|
|
/// 注意,所有的子接口需要实现的函数:
|
|
|
|
|
|
/// ComponentTargetingEffect:此牌瞄准目标时调用
|
|
|
|
|
|
/// ComponentUntargetingEffect:此牌取消瞄准目标时调用
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public abstract class CardLogicComponentBase
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2025-11-15 12:17:34 -05:00
|
|
|
|
protected CardLogicBase mainLogic;
|
|
|
|
|
|
protected CardInstance card => mainLogic.card;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
protected CharacterBase user => card.user;
|
2025-11-15 12:17:34 -05:00
|
|
|
|
protected CombatTeam usingTeam => card.usingTeam;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
|
2025-10-23 00:49:44 -04:00
|
|
|
|
public virtual void Initialize(CardLogicBase card)
|
|
|
|
|
|
{
|
2025-11-15 12:17:34 -05:00
|
|
|
|
this.mainLogic = card;
|
|
|
|
|
|
this.card.eventSubmodule.onTargeting += TargetingEffect;
|
|
|
|
|
|
this.card.eventSubmodule.onUntargeting += UntargetingEffect;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void TargetingEffect(CharacterBase target)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void UntargetingEffect()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|