Files
Continentis/Assets/Scripts/MainGame/Card/LogicComponents/CardLogicComponent_SelectHandCards.cs
SoulliesOfficial dd2657573a 卡牌更新
2026-04-08 04:48:35 -04:00

80 lines
3.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using System.Linq;
using Continentis.MainGame.Commands;
using Continentis.MainGame.UI;
using SLSFramework.General;
namespace Continentis.MainGame.Card
{
public class CardLogicComponent_SelectHandCards : CardLogicComponentBase
{
private Func<CardInstance, bool> selectCondition;
private Action<CardInstance> selectEffect;
public List<CardInstance> selectedCards;
public CardLogicComponent_SelectHandCards SetCondition(Func<CardInstance, bool> condition)
{
selectCondition = condition;
return this;
}
public CardLogicComponent_SelectHandCards SetEffect(Action<CardInstance> effect)
{
selectEffect = effect;
return this;
}
/// <summary>
/// 添加选择手牌的指令
/// </summary>
/// <param name="commandGroup">目标指令组</param>
/// <param name="title">选择卡牌的描述性标题</param>
/// <param name="includeTeam">是否包含队伍内的卡牌,如果不包含,则强制切换到角色手牌,且禁用切换按钮</param>
/// <param name="maxSelection">最大选择数量</param>
/// <param name="forceMax">是否强制选择最大数量</param>
public void AddSelectionCommands(ref CommandGroup commandGroup, string title, int maxSelection, bool forceMax = false, bool includeTeam = false)
{
selectedCards = new List<CardInstance>();
HandCardSelectionInterface handCardSelector = CombatUIManager.Instance.combatMainPage.handCardSelector;
commandGroup.AddCommand(Cmd.Do(() =>
{
handCardSelector.Setup(title, mainLogic.card, maxSelection, selectCondition, forceMax);
if (!includeTeam)
{
CombatUIManager.Instance.combatMainPage.teamSwitchButton.SwitchToCurrentCharacter();
CombatUIManager.Instance.combatMainPage.teamSwitchButton.button.interactable = false;
}
}));
commandGroup.AddCommand(new Cmd_WaitForUI(handCardSelector));
commandGroup.AddCommand(Cmd.Do(() =>
{
selectedCards = handCardSelector.selectedCards.ToList();
selectedCards.ForEach(selectEffect);
if (!includeTeam)
{
CombatUIManager.Instance.combatMainPage.teamSwitchButton.button.interactable = true;
}
}));
}
/// <summary>
/// 添加选择手牌的指令无UI直接选择符合条件的卡牌
/// </summary>
/// <param name="commandGroup">目标指令组</param>
public void AddSelectionCommands(ref CommandGroup commandGroup)
{
selectedCards = user.deckSubmodule.HandPile.Filtered(selectCondition).ToList();
commandGroup.AddCommand(new Cmd_Function(() =>
{
selectedCards.ForEach(selectEffect);
}));
}
}
}