예제 #1
0
        public void AddCard(CardController card)
        {
            this.cards.Add(card);
            card.SetHand(this);

            LerpTo lt = card.GetComponent <LerpTo>();

            lt.enabled = false;
        }
예제 #2
0
        public void RemoveCard(CardController card)
        {
            this.cards.Remove(card);
            card.SetHand(null);

            LerpTo lt = card.GetComponent <LerpTo>();

            lt.Run(this.discardTransform, false);
        }
예제 #3
0
        public void Simplify()
        {
            Dictionary <CardValue, int> counts = new Dictionary <CardValue, int>();

            foreach (CardController cc in this.cards)
            {
                if (counts.ContainsKey(cc.cardType.Value))
                {
                    counts[cc.cardType.Value]++;
                }
                else
                {
                    counts[cc.cardType.Value] = 1;
                }
            }

            List <CardController> removed = new List <CardController>();

            foreach (CardValue vc in counts.Keys)
            {
                int count = counts[vc];

                if (count >= 4)
                {
                    Debug.Log("Found 4 matching cards in " + this + " of type " + vc.name + "!");

                    foreach (CardController cc in this.cards)
                    {
                        if (cc.cardType.Value == vc)
                        {
                            LerpTo lt = cc.GetComponent <LerpTo>();
                            lt.Run(this.discardTransform);

                            // Queue it up to remove it from the list.
                            removed.Add(cc);
                        }
                    }
                }
            }

            // Actually discard the cards.
            foreach (CardController toRemove in removed)
            {
                toRemove.Discard();
            }
        }
예제 #4
0
        public void Discard()
        {
            this.hand.RemoveCard(this);
            this.hand = null;

            // Go to the dealer.
            LerpTo lt = this.GetComponent <LerpTo>();

            lt.Run(this.dealer.transform, true);

            // Disable colliders.
            Collider[] cols = this.GetComponents <Collider>();
            foreach (Collider col in cols)
            {
                col.enabled = false;
            }

            this.StartCoroutine(this.DestroySelf());
        }