From f6262481dc24da479c1a8fad82d5318ab7e473f3 Mon Sep 17 00:00:00 2001 From: xianyi Date: Wed, 6 Aug 2025 11:35:29 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8D=A1=E7=89=8C=E6=94=BB?= =?UTF-8?q?=E5=87=BB=20-=20=E5=9C=BA=E4=B8=8A=E5=AD=98=E5=9C=A8=E5=8D=A1?= =?UTF-8?q?=E7=89=8C=E6=97=B6=E6=97=A0=E6=B3=95=E7=9B=B4=E6=8E=A5=E6=94=BB?= =?UTF-8?q?=E5=87=BB=E6=95=8C=E6=96=B9=E7=8E=A9=E5=AE=B6=20-=20=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E5=8D=A1=E7=89=8C=E6=94=BB=E5=87=BB=E6=95=8C=E6=96=B9?= =?UTF-8?q?=E7=8E=A9=E5=AE=B6=E9=AB=98=E4=BA=AE=E6=98=BE=E7=A4=BA=20-=20?= =?UTF-8?q?=E4=B8=80=E5=9B=9E=E5=90=88=E5=8F=AA=E8=83=BD=E4=B8=8A=E5=9C=BA?= =?UTF-8?q?=E4=B8=80=E5=BC=A0=E8=A7=92=E8=89=B2=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TcgEngine/Scripts/GameClient/BoardSlot.cs | 8 ++++---- .../Scripts/GameClient/BoardSlotGroup.cs | 4 ++-- .../Scripts/GameClient/BoardSlotPlayer.cs | 19 ++++++++++--------- .../TcgEngine/Scripts/GameClient/HandCard.cs | 5 +++-- Assets/TcgEngine/Scripts/GameLogic/Game.cs | 4 ++++ .../Scripts/GameServer/GameServer.cs | 11 +++++++++++ Assets/TcgEngine/Scripts/UI/IconBar.cs | 12 +++++++++++- 7 files changed, 45 insertions(+), 18 deletions(-) diff --git a/Assets/TcgEngine/Scripts/GameClient/BoardSlot.cs b/Assets/TcgEngine/Scripts/GameClient/BoardSlot.cs index dc6e573..9ea583f 100644 --- a/Assets/TcgEngine/Scripts/GameClient/BoardSlot.cs +++ b/Assets/TcgEngine/Scripts/GameClient/BoardSlot.cs @@ -57,14 +57,14 @@ namespace TcgEngine.Client //Find target opacity value target_alpha = 0f; - if (your_turn && dcard != null && dcard.CardData.IsBoardCard() && gdata.CanPlayCard(dcard, slot)) + if (your_turn && dcard != null && dcard.CardData.IsBoardCard() && gdata.CanPlayCard(dcard, slot, true)) { - target_alpha = 1f; //hightlight when dragging a character or artifact + target_alpha = 1f; //hightlight when dragging a character or artifact (skip mana cost) } - if (your_turn && dcard != null && dcard.CardData.IsRequireTarget() && gdata.CanPlayCard(dcard, slot)) + if (your_turn && dcard != null && dcard.CardData.IsRequireTarget() && gdata.CanPlayCard(dcard, slot, true)) { - target_alpha = 1f; //Highlight when dragin a spell with target + target_alpha = 1f; //Highlight when dragin a spell with target (skip mana cost) } if (gdata.selector == SelectorType.SelectTarget && player.player_id == gdata.selector_player_id) diff --git a/Assets/TcgEngine/Scripts/GameClient/BoardSlotGroup.cs b/Assets/TcgEngine/Scripts/GameClient/BoardSlotGroup.cs index e455f04..ad3502c 100644 --- a/Assets/TcgEngine/Scripts/GameClient/BoardSlotGroup.cs +++ b/Assets/TcgEngine/Scripts/GameClient/BoardSlotGroup.cs @@ -77,8 +77,8 @@ namespace TcgEngine.Client { foreach (GroupSlot slot in group_slots) { - if(gdata.CanPlayCard(dcard, slot.slot)) - target_alpha = 1f; //hightlight when dragging a character or artifact + if(gdata.CanPlayCard(dcard, slot.slot, true)) + target_alpha = 1f; //hightlight when dragging a character or artifact (skip mana cost) } } diff --git a/Assets/TcgEngine/Scripts/GameClient/BoardSlotPlayer.cs b/Assets/TcgEngine/Scripts/GameClient/BoardSlotPlayer.cs index e2fca41..b1ac1dc 100644 --- a/Assets/TcgEngine/Scripts/GameClient/BoardSlotPlayer.cs +++ b/Assets/TcgEngine/Scripts/GameClient/BoardSlotPlayer.cs @@ -67,16 +67,17 @@ namespace TcgEngine.Client target_alpha = 0f; Card select_card = bcard_selected?.GetCard(); - if (select_card != null) - { - bool can_do_attack = gdata.IsPlayerActionTurn(player) && select_card.CanAttack(); - bool can_be_attacked = gdata.CanAttackTarget(select_card, oplayer); + // if (select_card != null) + // { + // bool can_do_attack = gdata.IsPlayerActionTurn(player) && select_card.CanAttack(); + // bool can_be_attacked = gdata.CanAttackTarget(select_card, oplayer); - if (can_do_attack && can_be_attacked) - { - target_alpha = 1f; - } - } + // 敌方可被攻击时高亮 + // if (can_do_attack && can_be_attacked) + // { + // target_alpha = 1f; + // } + //} if (your_turn && drag_card != null && drag_card.CardData.IsRequireTargetSpell() && gdata.IsPlayTargetValid(drag_card.GetCard(), GetPlayer())) { diff --git a/Assets/TcgEngine/Scripts/GameClient/HandCard.cs b/Assets/TcgEngine/Scripts/GameClient/HandCard.cs index cd3d871..985f2f3 100644 --- a/Assets/TcgEngine/Scripts/GameClient/HandCard.cs +++ b/Assets/TcgEngine/Scripts/GameClient/HandCard.cs @@ -231,9 +231,10 @@ namespace TcgEngine.Client return; } - if (!player.CanPayMana(card)) + // 检查本回合是否已经上场过场上卡牌(只有怪物牌等场上卡牌受限制) + if (card.CardData.IsBoardCard() && player.cards_played_this_turn >= 1) { - WarningText.ShowNoMana(); + Debug.Log("本回合只能上场一张场上卡牌"); return; } diff --git a/Assets/TcgEngine/Scripts/GameLogic/Game.cs b/Assets/TcgEngine/Scripts/GameLogic/Game.cs index fe1086e..940284d 100644 --- a/Assets/TcgEngine/Scripts/GameLogic/Game.cs +++ b/Assets/TcgEngine/Scripts/GameLogic/Game.cs @@ -186,6 +186,10 @@ namespace TcgEngine if (target.HasStatus(StatusType.Protected) && !attacker.HasStatus(StatusType.Flying)) return false; //Protected by taunt + // 检查目标玩家场上是否有卡牌,如有则无法直接攻击玩家 + if (target.cards_board.Count > 0) + return false; //Cannot attack player when they have cards on board + return true; } diff --git a/Assets/TcgEngine/Scripts/GameServer/GameServer.cs b/Assets/TcgEngine/Scripts/GameServer/GameServer.cs index 0ddc637..9798111 100644 --- a/Assets/TcgEngine/Scripts/GameServer/GameServer.cs +++ b/Assets/TcgEngine/Scripts/GameServer/GameServer.cs @@ -303,7 +303,18 @@ namespace TcgEngine.Server { Card card = player.GetCard(msg.card_uid); if (card != null && card.player_id == player.player_id) + { + // 检查本回合是否已经上场过场上卡牌(只有怪物牌等场上卡牌受限制) + if (card.CardData.IsBoardCard() && player.cards_played_this_turn >= 1) + return; // 已经上场过场上卡牌,不能再上场 + + // 手动上场卡牌:跳过mana消耗 + // gameplay.PlayCard(card, msg.slot, true); gameplay.PlayCard(card, msg.slot); + // 只有场上卡牌才增加计数 + if (card.CardData.IsBoardCard()) + player.cards_played_this_turn++; + } } } diff --git a/Assets/TcgEngine/Scripts/UI/IconBar.cs b/Assets/TcgEngine/Scripts/UI/IconBar.cs index afa4ea2..cf81c6c 100644 --- a/Assets/TcgEngine/Scripts/UI/IconBar.cs +++ b/Assets/TcgEngine/Scripts/UI/IconBar.cs @@ -33,9 +33,15 @@ namespace TcgEngine.UI public void Refresh() { + if (icons == null) + return; + int index = 0; foreach (Image icon in icons) { + if (icon == null) + continue; + icon.gameObject.SetActive(index < value || index < max_value); icon.sprite = (index < value) ? sprite_full : sprite_empty; index++; @@ -44,9 +50,13 @@ namespace TcgEngine.UI public void SetMat(Material mat) { + if (icons == null) + return; + foreach (Image icon in icons) { - icon.material = mat; + if (icon != null) + icon.material = mat; } } }