Ejemplo n.º 1
0
        private void GetfirstCard()
        {
            cards firstcard = new cards(Suit, Number);

            firstcard = MyDeck.cardstack.Peek();
            string message = string.Format("The card is: {0} of  {1} ", firstcard.Number, firstcard.Suit);

            Debug.Log(message);
        }
Ejemplo n.º 2
0
        public static Stack <cards> Shuffle(this Stack <cards> cards)
        {
            cards[] arrayDeck = new cards[cards.Count];
            cards.CopyTo(arrayDeck, 0);



            // Knuth shuffle algorithm :: courtesy of Wikipedia :)
            for (int t = 0; t < arrayDeck.Length; t++)
            {
                cards tmp = arrayDeck[t];
                int   r   = UnityEngine.Random.Range(t, arrayDeck.Length);
                arrayDeck[t] = arrayDeck[r];
                arrayDeck[r] = tmp;
            }

            Stack <cards> stack3 = new Stack <cards>(arrayDeck);


            return(stack3);
        }