- Home /
Check if card cost (on this instance of clone, or child of parent) is <= Mana, add this card to a list for the Enemy AI to use
trying to trigger an event so when the enemy turn starts, each card in the enemy's had is added to a list if it's individual cost is equal to or less then the current mana level... trying it from the current objects script, for each or etc
if (getComponent<CardStats>().cardCost <= battleStats.ManaThisTurn)
{list.add(cardID);
or
foreach (transform child in transform)
if (GetComponent<CardsStats>();cards <= battleStats.ManathisTUrn()
{
{list.add(cardID);
}
Comment
Answer by ShadyProductions · Jun 02, 2017 at 08:02 AM
If each card is a gameobject then you can give them a tag called card, and do something like this:
var cards = GameObject.FindGameObjectsWithTag("card");
var useableCards = new List<GameObject>();
foreach (var card in cards) {
if (card.GetComponent<CardsStats>().cardCost <= battleStats.ManaThisTurn)
{
useableCards.Add(card);
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612123230im_/https://answers.unity.com/themes/thub/images/avi.jpg)