Пример #1
0
        public void PlaceCard(GameObject _card)
        {
            CardDisplay card     = _card.GetComponentInChildren <CardDisplay>();
            DragDrop    dragDrop = _card.GetComponent <DragDrop>();

            if (card.card.owner == Card.Owner.My && MyMana - card.card.manaCost >= 0 && MyTableCards.Count < 10)
            {
                //Move the Card
                _card.transform.SetParent(playerTable.transform, false);

                MyHandCards.Remove(_card);
                MyTableCards.Add(_card);

                card.currentState = CardDisplay.State.board;
                //PlaySound(cardDrop);

                if (card.card.cardType == Card.CardType.Magic)///Apply Magic Effect
                {
                    card.card.canPlay = true;
                    if (card.card.cardeffect == Card.CardEffect.ToAll)
                    {
                        card.card.AddToAll(card.card, true, delegate { card.Destroy(card.card); });
                    }
                    else if (card.card.cardeffect == Card.CardEffect.ToEnemies)
                    {
                        card.card.AddToEnemies(card.card, AITableCards, true, delegate { card.Destroy(card.card); });
                    }
                }

                MyMana -= card.card.manaCost;
            }
            else if (card.card.owner == Card.Owner.My)
            {
                _card.transform.position = dragDrop.startPosition;
                _card.transform.SetParent(dragDrop.startParent.transform, false);
            }
            else if (card.card.owner == Card.Owner.AI && AIMana - card.card.manaCost >= 0 && AITableCards.Count < 10)
            {
                //Move the Card
                _card.transform.SetParent(AITable.transform, false);

                AIHandCards.Remove(_card);
                AITableCards.Add(_card);

                //card.SetCardStatus(Card.CardStatus.OnTable);
                card.currentState = CardDisplay.State.board;
                //PlaySound(cardDrop);

                if (card.card.cardType == Card.CardType.Magic)///Apply Magic Effect
                {
                    card.canPlay = true;
                    if (card.card.cardeffect == Card.CardEffect.ToAll)
                    {
                        card.card.AddToAll(card.card, true, delegate { card.Destroy(card.card); });
                    }
                    else if (card.card.cardeffect == Card.CardEffect.ToEnemies)
                    {
                        card.card.AddToEnemies(card.card, MyTableCards, true, delegate { card.Destroy(card.card); });
                    }
                }

                AIMana -= card.card.manaCost;
            }

            UpdateGame();
        }