敌我卡牌数量比较
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: acf7b90eaf6054d2ebc6093003b274be, type: 3}
|
||||||
|
m_Name: has_board_card_more
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
comparison_target: 0
|
||||||
|
pile: 0
|
||||||
|
oper: 0
|
||||||
|
has_type: 0
|
||||||
|
has_team: {fileID: 0}
|
||||||
|
has_trait: {fileID: 0}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6836b69e4c9d2411593ab0deaaef4b98
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
104
Assets/TcgEngine/Scripts/Conditions/ConditionCountComparison.cs
Normal file
104
Assets/TcgEngine/Scripts/Conditions/ConditionCountComparison.cs
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace TcgEngine
|
||||||
|
{
|
||||||
|
public enum ComparisonTarget
|
||||||
|
{
|
||||||
|
SelfVsOpponent = 0, // 我方比较
|
||||||
|
OpponentVsSelf = 1, // 对方
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 比较敌我双方已上场卡牌的数量关系
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/CountComparison", order = 10)]
|
||||||
|
public class ConditionCountComparison : ConditionData
|
||||||
|
{
|
||||||
|
[Header("比较设置")]
|
||||||
|
public ComparisonTarget comparison_target;
|
||||||
|
public PileType pile; // 手牌/场上/装备/墓地/秘密/临时
|
||||||
|
public ConditionOperatorInt oper;
|
||||||
|
|
||||||
|
[Header("卡牌特征筛选")]
|
||||||
|
public CardType has_type;
|
||||||
|
public TeamData has_team;
|
||||||
|
public TraitData has_trait;
|
||||||
|
|
||||||
|
public override bool IsTriggerConditionMet(Game data, AbilityData ability, Card caster)
|
||||||
|
{
|
||||||
|
Player self_player = data.GetPlayer(caster.player_id);
|
||||||
|
Player opponent_player = data.GetOpponentPlayer(caster.player_id);
|
||||||
|
|
||||||
|
if (self_player == null || opponent_player == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int self_count = CountPile(self_player, pile);
|
||||||
|
int opponent_count = CountPile(opponent_player, pile);
|
||||||
|
|
||||||
|
if (comparison_target == ComparisonTarget.SelfVsOpponent)
|
||||||
|
{
|
||||||
|
return CompareInt(self_count, oper, opponent_count);
|
||||||
|
}
|
||||||
|
else // OpponentVsSelf
|
||||||
|
{
|
||||||
|
// 对手已上场卡牌与我方已上场卡牌比较
|
||||||
|
return CompareInt(opponent_count, oper, self_count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int CountPile(Player player, PileType pile)
|
||||||
|
{
|
||||||
|
if (player == null)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
List<Card> card_pile = null;
|
||||||
|
|
||||||
|
if (pile == PileType.Hand)
|
||||||
|
card_pile = player.cards_hand;
|
||||||
|
|
||||||
|
if (pile == PileType.Board)
|
||||||
|
card_pile = player.cards_board;
|
||||||
|
|
||||||
|
if (pile == PileType.Equipped)
|
||||||
|
card_pile = player.cards_equip;
|
||||||
|
|
||||||
|
if (pile == PileType.Deck)
|
||||||
|
card_pile = player.cards_deck;
|
||||||
|
|
||||||
|
if (pile == PileType.Discard)
|
||||||
|
card_pile = player.cards_discard;
|
||||||
|
|
||||||
|
if (pile == PileType.Secret)
|
||||||
|
card_pile = player.cards_secret;
|
||||||
|
|
||||||
|
if (pile == PileType.Temp)
|
||||||
|
card_pile = player.cards_temp;
|
||||||
|
|
||||||
|
if (card_pile != null)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
foreach (Card card in card_pile)
|
||||||
|
{
|
||||||
|
if (card != null && IsTrait(card))
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsTrait(Card card)
|
||||||
|
{
|
||||||
|
if (card?.CardData == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool is_type = card.CardData.type == has_type || has_type == CardType.None;
|
||||||
|
bool is_team = card.CardData.team == has_team || has_team == null;
|
||||||
|
bool is_trait = card.HasTrait(has_trait) || has_trait == null;
|
||||||
|
return (is_type && is_team && is_trait);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: acf7b90eaf6054d2ebc6093003b274be
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Reference in New Issue
Block a user