78 lines
2.9 KiB
C#
78 lines
2.9 KiB
C#
using System.Collections.Generic;
|
||
using Continentis.MainGame;
|
||
using Continentis.MainGame.Card;
|
||
using Continentis.MainGame.Character;
|
||
using SLSUtilities.General;
|
||
|
||
namespace Continentis.Mods.Basic.Buffs
|
||
{
|
||
/// <summary>
|
||
/// 复仇(骑士):必须先持有此 Buff,之后每次被攻击叠加 1 层。
|
||
/// 使用攻击类卡牌时,消耗所有层数对所有目标各造成等量的额外物理伤害。
|
||
/// </summary>
|
||
public class Vengeance : CharacterCombatBuffBase
|
||
{
|
||
public Vengeance()
|
||
{
|
||
Initialize(BuffType.Positive, BuffDispelLevel.Strong);
|
||
|
||
this.contentSubmodule = new ContentSubmodule(this)
|
||
.AddParameterGetter("Stack", () => unitedStackSubmodule.stackAmount.ToString());
|
||
|
||
this.iconSubmodule = new IconSubmodule(this).SetTextFunctions("Stack");
|
||
|
||
// 初始 0 层;层数完全由事件驱动累积
|
||
this.unitedStackSubmodule = new UnitedStackSubmodule(this, 0);
|
||
|
||
this.eventSubmodule = new EventSubmodule(this);
|
||
|
||
// 被攻击时叠层(过滤响应式和生命移除,防止递归)
|
||
this.eventSubmodule.onGetAttacked.Add("Vengeance_Stack", new PrioritizedAction<AttackResult>(result =>
|
||
{
|
||
if (result.context.HasAnyTag(AttackTags.Reactive, AttackTags.HpRemoval)) return;
|
||
unitedStackSubmodule.AddStack(1);
|
||
iconSubmodule.Update();
|
||
}));
|
||
|
||
// 打出攻击类卡牌时消耗所有层数造成额外伤害
|
||
this.eventSubmodule.onAfterPlayCard.Add("Vengeance_Consume",
|
||
new PrioritizedAction<CardInstance, List<CharacterBase>>(OnAfterPlayCard));
|
||
}
|
||
|
||
private void OnAfterPlayCard(CardInstance playedCard, List<CharacterBase> targets)
|
||
{
|
||
if (!playedCard.HasKeyword("Attack")) return;
|
||
if (unitedStackSubmodule.stackAmount <= 0) return;
|
||
|
||
int bonus = unitedStackSubmodule.stackAmount;
|
||
unitedStackSubmodule.ModifyStack(-bonus);
|
||
iconSubmodule.Update();
|
||
|
||
var ctx = new AttackContext()
|
||
.WithTag(AttackTags.Reactive)
|
||
.WithTag(AttackTags.GuaranteedHit)
|
||
.WithDamageKeywords("Physics");
|
||
|
||
foreach (CharacterBase target in targets)
|
||
{
|
||
EnqueueReaction(Cmd.Do(() => attachedCharacter.Attack(target, bonus, ctx)));
|
||
}
|
||
}
|
||
|
||
public override bool OnBuffApply(out CharacterCombatBuffBase existingBuff)
|
||
{
|
||
MainGameManager.Instance.basePrefabs.GenerateInfoText(
|
||
contentSubmodule.displayName, attachedCharacter.characterView);
|
||
|
||
// 若已存在则保留现有实例(不重置层数,不二次叠加)
|
||
if (FindExistingSameBuff(out existingBuff))
|
||
{
|
||
return false;
|
||
}
|
||
|
||
existingBuff = null;
|
||
return true;
|
||
}
|
||
}
|
||
}
|