Hi,
Just created a shuffle action that goes with ArrayMaker:
http://hutonggames.com/playmakerforum/index.php?topic=835.msg6934#msg6934What is the "strenghts" of your cards?
I would strongly recommand you maintain an array per property, this might seem a lot of overhead, but I think it will pay back real quick as the system will grow.
so have perhaps, one gameObject, and in it three array, named "suit" "type " and "strength", and for a given index, you can get the card details by querying one of this array for that index.
so, the direct benefit is the following, if you want to have several hands, you create new arrays ( maybe as a child of your player game object), and in there you only have an array of 5 integers! easy, if you want to know which card they are, simply go through them 5 index, and get the type, or strengst on them array you created earlier. It simply becomes a convenient look up table ( here look up arrays
).
Hopefully that make sense.
So concrete possible process to get 5 cards:
-- have a prefab or (build that at runtime) with an array of int. let's call it "POOL" If you are playing with 56 cards, make an array of ints and 1,2,3,4,...,53,54
-- reset the "hand" array of your player ( so it has nothing in it)
-- generate a random number called "index" within the "POOL" array length
-- get the int at this index, and put that value in "hand"
-- DELETE that index in "POOL", cause you have taken it, that card doesn't exist anymore
-- generate again "index" within the "POOL" array lenght ( that is 53 now)
-- get the int at the index, and put the value in "hand"
-- DELETE that index in "POOL"
etc etc until you get 5 cards.
You might get confused at first, because you are dealing with ints everywhere, ints for the index of the card you pick, ints for the reference to the card in the set of "look up arrays"
I guess I could create convenient actions to do just that, ( take x random unique elements from an array, and other goodies)
Tell me, if what I explained is too much, if so, I'll do some actions to ease your work.
Bye,
Jean