131 lines
5.3 KiB
C#
131 lines
5.3 KiB
C#
using System.Collections.Generic;
|
||
using Continentis.MainGame;
|
||
using Continentis.MainGame.Card;
|
||
using Continentis.MainGame.Character;
|
||
using Continentis.MainGame.Commands;
|
||
using Continentis.Mods.Basic.Buffs;
|
||
using SLSUtilities.General;
|
||
|
||
namespace Continentis.Mods.Basic.Cards
|
||
{
|
||
/// <summary>
|
||
/// 至圣斩(DivineSmite):
|
||
/// 造成物理伤害和多段光属性魔法伤害,光伤害段数等于连续打出该牌的次数,最后施加致盲Buff。
|
||
/// </summary>
|
||
public class DivineSmite : CardLogicBase
|
||
{
|
||
// 游戏字典里定义的伤害及Buff参数键值点
|
||
private const string DAMAGE_PHYSICS = "Damage_Physics";
|
||
private const string DAMAGE_LIGHT = "Damage_Light";
|
||
private const string BUFF_BLIND_COUNT = "Buff_Blind_Count";
|
||
|
||
/// <summary>
|
||
/// 物理伤害的上下文属性通道
|
||
/// </summary>
|
||
private AttackContext PhysicsCtx => AttackContext.Default(card)
|
||
.WithDamageKeywords("Physics")
|
||
.WithBaseDamageAttribute(DAMAGE_PHYSICS);
|
||
|
||
/// <summary>
|
||
/// 光属性魔法伤害的上下文属性通道
|
||
/// </summary>
|
||
private AttackContext LightCtx => AttackContext.Default(card)
|
||
.WithDamageKeywords("Light")
|
||
.WithBaseDamageAttribute(DAMAGE_LIGHT);
|
||
|
||
public override void SetUpLogicComponents()
|
||
{
|
||
AddLogicComponent<CardLogicComponent_Attack>();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 选中目标时,预览最终会造成的伤害数值和攻击段数
|
||
/// </summary>
|
||
public override void TargetingEffect(CharacterBase target)
|
||
{
|
||
card.SetAttribute("Display_Damage_Physics", GetTargetedFinalDamage(target, PhysicsCtx));
|
||
card.SetAttribute("Display_Damage_Light", GetTargetedFinalDamage(target, LightCtx));
|
||
|
||
// 为界面显示专门设定一个动态的“光属性连击次数”属性
|
||
int lightTimes = GetConsecutiveDivineSmiteCount();
|
||
card.SetAttribute("Hit_Count_Light", lightTimes);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 没有目标、或者取消选中时的默认面板预期伤害
|
||
/// </summary>
|
||
public override void UntargetingEffect()
|
||
{
|
||
card.SetAttribute("Display_Damage_Physics", GetNoTargetFinalDamage(PhysicsCtx));
|
||
card.SetAttribute("Display_Damage_Light", GetNoTargetFinalDamage(LightCtx));
|
||
|
||
int lightTimes = GetConsecutiveDivineSmiteCount();
|
||
card.SetAttribute("Hit_Count_Light", lightTimes);
|
||
}
|
||
|
||
public override CommandGroup PlayEffect(List<CharacterBase> targetList)
|
||
{
|
||
// 通过过往卡牌出牌记录找到需要触发多少次光属性攻击
|
||
int lightTimes = GetConsecutiveDivineSmiteCount();
|
||
|
||
return ForEachTarget(targetList, target => Cmd.Sequential(
|
||
new Cmd_PlayAnimation(user.characterView, "Attack"),
|
||
Cmd.Do(() =>
|
||
{
|
||
// 1. 触发一段基础物理伤害
|
||
AttackContext physCtx = PhysicsCtx;
|
||
AttackTarget(target, GetTargetedFinalDamage(target, physCtx), physCtx);
|
||
|
||
// 2. 根据连续使用的次数,循环触发光属性魔法追击
|
||
AttackContext lightCtx = LightCtx;
|
||
for (int i = 0; i < lightTimes; i++)
|
||
{
|
||
AttackTarget(target, GetTargetedFinalDamage(target, lightCtx), lightCtx);
|
||
}
|
||
|
||
// 3. 结算后对目标挂载致盲 (Blind) 状态
|
||
int blindStacks = GetAttribute(BUFF_BLIND_COUNT);
|
||
CreateCharacterBuff<Blind>(blindStacks).Apply(target, user, this);
|
||
})
|
||
));
|
||
}
|
||
|
||
public override void ApplyAttributeChangesByCard()
|
||
{
|
||
// 在卡牌数据更新层对物理伤害与默认(光属性)伤害渠道做双重初始化
|
||
LogicComponent<CardLogicComponent_Attack>().SetDamage_Physics(DAMAGE_PHYSICS);
|
||
LogicComponent<CardLogicComponent_Attack>().SetDamage_Default(DAMAGE_LIGHT);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 从历史行动记录中寻找过往连续出过的本牌数量,用于充能和统计光爆次数。
|
||
/// </summary>
|
||
private int GetConsecutiveDivineSmiteCount()
|
||
{
|
||
if (user.recordSubmodule == null || user.recordSubmodule.actionRecords == null) return 1;
|
||
|
||
int count = 1; // 包含当前准备打出的这一张本身
|
||
int cardsSeen = 0;
|
||
for (int i = user.recordSubmodule.actionRecords.Count - 1; i >= 0; i--)
|
||
{
|
||
var record = user.recordSubmodule.actionRecords[i];
|
||
for (int j = record.cardsPlayed.Count - 1; j >= 0; j--)
|
||
{
|
||
if (cardsSeen > 0)
|
||
{
|
||
if (record.cardsPlayed[j].cardLogic is DivineSmite)
|
||
{
|
||
count++;
|
||
}
|
||
else
|
||
{
|
||
return count;
|
||
}
|
||
}
|
||
cardsSeen++;
|
||
}
|
||
}
|
||
return count;
|
||
}
|
||
}
|
||
} |