- Home /
Beginner need some help on Card Game
Hello everyone!
I recently started using Unity to try and learn it. It went pretty well at the start, i made a little sample on 2d platform game. But now i would like to try and make an own Card-based Game. And this i have no clue on how to do. I tried to search the web for info, but couldn't find much to help me (also i'm greatly visually handicapped, so searching can be very hard for me, and that's why i ask here).
I have a little clue on how to make the deck, but only the normal deck of cards where you have 52 cards, but i wanna make my own cards and have i.e 3 of the same card in the deck.
What i've managed to do myself so far is the Top-down view i want and i have 3 different prefab cards for my deck, (wanna try it small first, before adding all cards).
So what i need help with is something that would allow me to make a deck with the cards i put into the deck, shuffle it, and then draw the cards till the deck is empty. Would be nice if the card that i draw would go to the players "hand" instead off just to the "field"
If there's someone who has a clue on how this could be done, i would very much appriciate some help!
If there's anyother video or thread that has asked this, i would appriciate a link to it, since i can't seem to find the info i need.
Also i'm using c# not javascript.
Thanks in advance
Best Regards
Marcus
P.S. Sorry for bad sentences or misspellings, can be hard to be visually handicapped.
Answer by flaviusxvii · Sep 06, 2013 at 03:29 PM
This is actually a difficult question. It sounds like you have a good idea of which objects and components will be involved, and how they will interact.
It sounds like you might want a "Dealer" component.. with methods like shuffle(), and deal().
You probably want a "Player" component, with a List() to hold the cards in their hand.
If these terms aren't making sense, you might need some more foundational tutorial stuff, so you develop so intuition about how pieces interact, and what's possible.
Answer by TheBlindG · Sep 06, 2013 at 05:53 PM
I have a code that would let me add any size to the deck and a button that would let me deal 1 random card from the deck, but it doesn't work quite good. I don't really know how to implement thing into the scene that good in unity.
My script has the following methods:
ResetDeck() DealCard()
the deck is a public List deck = new List();
Don't know if that helps understading, but when i added my 3 prefabs to the deck, and tried deal out the cards just flat on a surface, only 1 card will show, but when i'm out of cards, the game restarts, but i always only see 1 card, eventhough there is 3 gameobject created when i press deal more then 1 time. It's only the first random card that will show inside the game view/scene view.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Pause Menu 5 Answers
Rotation help! 1 Answer
HighScore analytics 0 Answers
Unity3D Game Time 1 Answer