2026-04-01 12:23:27 -04:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using Continentis.MainGame;
|
|
|
|
|
|
using Continentis.MainGame.Card;
|
|
|
|
|
|
using Continentis.MainGame.Character;
|
|
|
|
|
|
using Continentis.MainGame.Combat;
|
|
|
|
|
|
using Continentis.MainGame.Commands;
|
2026-04-17 12:01:50 -04:00
|
|
|
|
using SLSUtilities.General;
|
2026-04-01 12:23:27 -04:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Continentis.Mods.Basic.Cards
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2026-04-08 04:48:35 -04:00
|
|
|
|
/// 命令术:根据使用者与目标的等级差产生不同效果:
|
|
|
|
|
|
/// <para>对敌人:等级差达到 High 门槛时随机移除一个意图;达到 Low 门槛时随机改变一个意图。</para>
|
|
|
|
|
|
/// <para>对玩家英雄:等级差达到 High 门槛时将"扼制"卡牌放入目标抽牌堆;达到 Low 门槛时将"干扰"卡牌放入目标抽牌堆。</para>
|
2026-04-01 12:23:27 -04:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class Command : CardLogicBase
|
|
|
|
|
|
{
|
2026-04-08 04:48:35 -04:00
|
|
|
|
private const string LEVEL_GAP_LOW = "LevelGap_Low";
|
|
|
|
|
|
private const string LEVEL_GAP_HIGH = "LevelGap_High";
|
|
|
|
|
|
|
2026-04-01 12:23:27 -04:00
|
|
|
|
private static readonly Color HintGreen = new Color(0.2f, 0.85f, 0.3f);
|
|
|
|
|
|
private static readonly Color HintRed = new Color(0.9f, 0.2f, 0.2f);
|
|
|
|
|
|
|
|
|
|
|
|
public override void Initialize(CardInstance cardInstance)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Initialize(cardInstance);
|
|
|
|
|
|
|
|
|
|
|
|
// 战场角色变化时刷新 hintShadow,托管机制自动取消订阅
|
|
|
|
|
|
CombatEventCollection events = CombatMainManager.Instance.eventCollection;
|
|
|
|
|
|
SubscribeCombatEvent(events.onCharacterDeath, new PrioritizedAction<CharacterBase>(_ => InvalidateHint()));
|
|
|
|
|
|
SubscribeCombatEvent(events.onCharacterJoin, new PrioritizedAction<CharacterBase>(_ => InvalidateHint()));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>抽到此牌时刷新 hintShadow。</summary>
|
|
|
|
|
|
protected override void OnDraw() => InvalidateHint();
|
|
|
|
|
|
|
|
|
|
|
|
public override CommandGroup PlayEffect(List<CharacterBase> targetList)
|
|
|
|
|
|
{
|
|
|
|
|
|
return ForEachTarget(targetList, target => Cmd.Parallel(
|
|
|
|
|
|
new Cmd_PlayAnimation(user.characterView, "Action"),
|
|
|
|
|
|
Cmd.Do(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (target is PlayerHero)
|
|
|
|
|
|
PlayEffectOnPlayer(target);
|
|
|
|
|
|
else
|
|
|
|
|
|
PlayEffectOnEnemy(target);
|
|
|
|
|
|
})
|
|
|
|
|
|
));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2026-04-08 04:48:35 -04:00
|
|
|
|
/// 检查场上是否存在等级差达到 Low 门槛的可用目标。
|
2026-04-01 12:23:27 -04:00
|
|
|
|
/// 有可用目标时返回绿色,无可用目标时返回红色。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public override Color? GetHintColor()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (user == null || card.handCardView == null) return null;
|
|
|
|
|
|
|
|
|
|
|
|
card.DetectTargetsValidity(out List<CharacterBase> valid, out _, out _);
|
|
|
|
|
|
if (valid.Count == 0) return HintRed;
|
|
|
|
|
|
|
2026-04-08 04:48:35 -04:00
|
|
|
|
int userLevel = user.GetAttribute(CharacterAttributes.Level);
|
|
|
|
|
|
int gapLow = GetAttribute(LEVEL_GAP_LOW);
|
2026-04-01 12:23:27 -04:00
|
|
|
|
bool hasEffectiveTarget = valid.Any(t =>
|
2026-04-08 04:48:35 -04:00
|
|
|
|
userLevel - t.GetAttribute(CharacterAttributes.Level) >= gapLow);
|
2026-04-01 12:23:27 -04:00
|
|
|
|
|
|
|
|
|
|
return hasEffectiveTarget ? HintGreen : HintRed;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-08 04:48:35 -04:00
|
|
|
|
/// <summary>计算使用者与目标的等级差。</summary>
|
|
|
|
|
|
private int GetLevelGap(CharacterBase target)
|
|
|
|
|
|
{
|
|
|
|
|
|
return user.GetAttribute(CharacterAttributes.Level) - target.GetAttribute(CharacterAttributes.Level);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>对敌方目标:等级差达到 High 时移除意图,达到 Low 时改变意图。</summary>
|
2026-04-01 12:23:27 -04:00
|
|
|
|
private void PlayEffectOnEnemy(CharacterBase target)
|
|
|
|
|
|
{
|
2026-04-08 04:48:35 -04:00
|
|
|
|
int levelGap = GetLevelGap(target);
|
|
|
|
|
|
int gapHigh = GetAttribute(LEVEL_GAP_HIGH);
|
|
|
|
|
|
int gapLow = GetAttribute(LEVEL_GAP_LOW);
|
2026-04-01 12:23:27 -04:00
|
|
|
|
|
2026-04-08 04:48:35 -04:00
|
|
|
|
if (levelGap >= gapHigh)
|
2026-04-01 12:23:27 -04:00
|
|
|
|
target.intentionSubmodule.RemoveRandomIntendedCard();
|
2026-04-08 04:48:35 -04:00
|
|
|
|
else if (levelGap >= gapLow)
|
2026-04-01 12:23:27 -04:00
|
|
|
|
target.intentionSubmodule.ChangeRandomIntendedCard();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-08 04:48:35 -04:00
|
|
|
|
/// <summary>对玩家英雄:等级差达到 High 时塞入扼制,达到 Low 时塞入干扰。</summary>
|
2026-04-01 12:23:27 -04:00
|
|
|
|
private void PlayEffectOnPlayer(CharacterBase target)
|
|
|
|
|
|
{
|
2026-04-08 04:48:35 -04:00
|
|
|
|
int levelGap = GetLevelGap(target);
|
|
|
|
|
|
int gapHigh = GetAttribute(LEVEL_GAP_HIGH);
|
|
|
|
|
|
int gapLow = GetAttribute(LEVEL_GAP_LOW);
|
2026-04-01 12:23:27 -04:00
|
|
|
|
|
2026-04-08 04:48:35 -04:00
|
|
|
|
if (levelGap >= gapHigh)
|
2026-04-01 12:23:27 -04:00
|
|
|
|
CardInstance.GenerateCardInstance(GetDerivativeCardData(0), target, Piles.Draw);
|
2026-04-08 04:48:35 -04:00
|
|
|
|
else if (levelGap >= gapLow)
|
2026-04-01 12:23:27 -04:00
|
|
|
|
CardInstance.GenerateCardInstance(GetDerivativeCardData(1), target, Piles.Draw);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|