Files
tcg-client/Assets/TcgEngine/Scripts/Conditions/ConditionSlotRange.cs
2025-09-28 16:22:32 +08:00

36 lines
1.4 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.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace TcgEngine
{
/// <summary>
/// SlotRange check each axis variable individualy for range between the caster and target
/// If you want to check the travel distance instead (all at once) use SlotDist
/// SlotRange 检查每个轴变量在施法者和目标之间的范围1
/// 如果你想一次性检查所有轴的行程距离请使用SlotDist
/// </summary>
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/SlotRange", order = 11)]
public class ConditionSlotRange : ConditionData
{
[Header("Slot Range")]
public int range_x = 1;
public int range_y = 1;
public int range_p = 0;
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
{
return IsTargetConditionMet(data, ability, caster, target.slot);
}
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Slot target)
{
Slot cslot = caster.slot;
int dist_x = Mathf.Abs(cslot.x - target.x);
int dist_y = Mathf.Abs(cslot.y - target.y);
int dist_p = Mathf.Abs(cslot.p - target.p);
return dist_x <= range_x && dist_y <= range_y && dist_p <= range_p;
}
}
}