I made class for my cards. And in card script i said gmCard gameCard = new gmCard(); // gmCard is name of class
.
Also in class of cards i made void for attack.
public void gCard(string n)
{
Name = n;
}
public void Attack(gmCard c)
{
Debug.Log(Name + "attacked" + c.Name + "!");
}
}
So my attack function should look like:
void Attack()
{
gameCard.Attack(otherCard);
}
But problem is all cards use same script wich have this same variable gmCard gameCard = new gmCard();
Does anyone have idea how should i build my attack (dmg) function.
you lose me towards the end…
what is your problem?
When i want to attack other cards with :
gameCard.Attack(otherCard);
i dont have anyother cards to choose except “gameCard”;
so basicly card can only attack her self.
If i want to have other cards in options to attack , i must decalare new cards.
For example:
gmCard DragonCard= new gmCard(); // gmCard is name of class
gmCard PokemonCard= new gmCard(); // gmCard is name of class
But i dont want to to this , this mean i will have to make for every card unique script.
My problem is i dont know how can i attack other cards?
So you have 2 classes, one is a collection of cards, the other is a card that can be in said collection.
let’s call them:
CardCollection
Card
CardCollection can take any 2 cards and call attack on one, and pass in the reference of the other.
The card collection should store the references of all the available cards to said collection.