Ejemplo n.º 1
0
        // --------------------------------------------------------------------------------------------
        private void OnPlayerDrewCard(object sender, Card.CardEventArgs e)
        {
            int numLoadCalls          = 0;
            int numLoadCallsCompleted = 0;

            foreach (Card card in _player.Hand.Cards)
            {
                if (!_cardToUICard.ContainsKey(card))
                {
                    numLoadCalls++;
                    UICard.LoadRequiredAssets(card.cardData, () =>
                    {
                        numLoadCallsCompleted++;

                        UICard uiCard = new UICard(card.cardData);
                        _cardToUICard.Add(card, uiCard);
                        _uiCardToCard.Add(uiCard, card);
                        MainPanel.AddChild(uiCard);

                        uiCard.SubscribeToEvent(EEventType.PointerEnter, (object eSender, EventSystemEventArgs eventArgs) =>
                        {
                            UICard_OnPointerEnter(uiCard, eventArgs.eventData as PointerEventData);
                        });
                        uiCard.SubscribeToEvent(EEventType.PointerExit, (object eSender, EventSystemEventArgs eventArgs) =>
                        {
                            UICard_OnPointerExit(uiCard);
                        });
                        uiCard.SubscribeToEvent(EEventType.PointerDown, (object eSender, EventSystemEventArgs eventArgs) =>
                        {
                            UICard_OnPointerDown(uiCard, eventArgs.eventData as PointerEventData);
                        });
                        uiCard.SubscribeToEvent(EEventType.Drag, (object eSender, EventSystemEventArgs eventArgs) =>
                        {
                            UICard_OnDrag(uiCard, eventArgs.eventData as PointerEventData);
                        });
                        uiCard.SubscribeToEvent(EEventType.PointerUp, (object eSender, EventSystemEventArgs eventArgs) =>
                        {
                            UICard_OnPointerUp(uiCard, eventArgs.eventData as PointerEventData);
                        });

                        if (numLoadCalls == numLoadCallsCompleted)
                        {
                            PositionCards(true);
                        }
                    });
                }
            }
        }