Files
Continentis/Assets/Mods/Basic/Cards/Scripts/General/Skill/Anticipation.cs
SoulliesOfficial ac98ec3aef 更新
2026-04-17 12:01:50 -04:00

59 lines
2.0 KiB
C#

using System.Collections.Generic;
using System.Linq;
using Continentis.MainGame.Card;
using Continentis.MainGame.Character;
using Continentis.MainGame.Combat;
using Continentis.MainGame.Commands;
using SLSUtilities.General;
using UnityEngine;
namespace Continentis.Mods.Basic.Cards
{
/// <summary>
/// 预判:获得闪避值。
/// 若本回合内没有任何敌人在使用者之前行动,则额外获得 Bonus_Dodge 的闪避值。
/// </summary>
public class Anticipation : CardLogicBase
{
private const string BONUS_DODGE = "Bonus_Dodge";
public override void SetUpLogicComponents()
{
AddLogicComponent<CardLogicComponent_Defense>();
}
public override CommandGroup PlayEffect(List<CharacterBase> targetList)
{
base.PlayEffect(targetList);
int baseDodge = GetAttribute("Dodge");
int finalDodge = IsBeforeAnyEnemy()
? Mathf.RoundToInt(baseDodge + GetAttribute(BONUS_DODGE))
: baseDodge;
return Cmd.Parallel(
new Cmd_PlayAnimation(user.characterView, "Skill"),
Cmd.Do(() => user.AddDodge(finalDodge))
);
}
public override void ApplyAttributeChangesByCard()
{
LogicComponent<CardLogicComponent_Defense>().SetDodge();
}
/// <summary>
/// 判断本回合内是否没有任何敌方角色在使用者之前行动过。
/// </summary>
private bool IsBeforeAnyEnemy()
{
int currentRound = CombatMainManager.Instance.currentRound;
int userActionIndex = user.recordSubmodule.currentAction;
return !CombatMainManager.Instance.characterController.characters
.Any(c => c.fraction == Fraction.Enemy
&& c.recordSubmodule.currentRound == currentRound
&& c.recordSubmodule.currentAction < userActionIndex);
}
}
}