更新
This commit is contained in:
75
Assets/Mods/Basic/Cards/Scripts/Knight/Attack/ShieldSlam.cs
Normal file
75
Assets/Mods/Basic/Cards/Scripts/Knight/Attack/ShieldSlam.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System.Collections.Generic;
|
||||
using Continentis.MainGame;
|
||||
using Continentis.MainGame.Card;
|
||||
using Continentis.MainGame.Character;
|
||||
using Continentis.MainGame.Commands;
|
||||
using SLSUtilities.General;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Continentis.Mods.Basic.Cards
|
||||
{
|
||||
/// <summary>
|
||||
/// 盾牌猛击(ShieldSlam):
|
||||
/// 对单体造成等同于当前格挡值的物理伤害,并消耗自身一半的格挡。
|
||||
/// </summary>
|
||||
public class ShieldSlam : CardLogicBase
|
||||
{
|
||||
private AttackContext PhysicsCtx => AttackContext.Default(card).WithDamageKeywords("Physics");
|
||||
private float Block => user?.GetAttribute("Block") ?? 0;
|
||||
|
||||
public override void SetUpLogicComponents()
|
||||
{
|
||||
AddLogicComponent<CardLogicComponent_Attack>();
|
||||
}
|
||||
|
||||
public override void TargetingEffect(CharacterBase target)
|
||||
{
|
||||
if (user != null) card.SetAttribute("Damage", Block);
|
||||
card.SetAttribute("Display_Damage", GetTargetedFinalDamage(target, PhysicsCtx));
|
||||
}
|
||||
|
||||
public override void UntargetingEffect()
|
||||
{
|
||||
if (user != null) card.SetAttribute("Damage", Block);
|
||||
card.SetAttribute("Display_Damage", GetNoTargetFinalDamage(PhysicsCtx));
|
||||
}
|
||||
|
||||
public override CommandGroup PlayEffect(List<CharacterBase> targetList)
|
||||
{
|
||||
CommandGroup mainGroup = new CommandGroup();
|
||||
|
||||
mainGroup.AddCommand(ForEachTarget(targetList, target => Cmd.Sequential(
|
||||
new Cmd_PlayAnimation(user.characterView, "Attack"),
|
||||
Cmd.Do(() =>
|
||||
{
|
||||
// 在造成伤害前,强制按当前的 Block 更新一下基础伤害,避免状态延迟带来的数值偏差
|
||||
if (user != null) card.SetAttribute("Damage", Block);
|
||||
|
||||
AttackContext physCtx = PhysicsCtx;
|
||||
AttackTarget(target, GetTargetedFinalDamage(target, physCtx), physCtx);
|
||||
})
|
||||
)));
|
||||
|
||||
// 格挡削减放置于 ForEachTarget 循环之外,保证无论造成几次伤害、目标有几个,消耗仅仅执行一次
|
||||
mainGroup.AddCommand(Cmd.Do(() =>
|
||||
{
|
||||
if (user != null && Block > 0)
|
||||
{
|
||||
int blockToConsume = Mathf.FloorToInt(Block / 2f);
|
||||
user.ModifyAndClampAttribute(CharacterAttributes.Block, -blockToConsume);
|
||||
}
|
||||
}));
|
||||
|
||||
return mainGroup;
|
||||
}
|
||||
|
||||
public override void ApplyAttributeChangesByCard()
|
||||
{
|
||||
if (user != null)
|
||||
{
|
||||
card.SetAttribute("Damage", Block);
|
||||
}
|
||||
LogicComponent<CardLogicComponent_Attack>().SetDamage_Physics();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user