/// <summary> /// Create SolitaireData from Card /// </summary> /// <param name="card"></param> /// <param name="internalDeckId"></param> public void AddCardData(Card card, int internalDeckId) { m_land = (int)card.CardLand(); m_id = card.CardId(); m_isBlack = card.IsBlack(); m_isTurned = card.IsTurned(); m_internalDeckId = internalDeckId; m_z = card.m_z; }
/// <summary> /// Handle user touch events: Pressed, Moved, Released /// </summary> private void handleTouch() { // Handle all touch here TouchCollection touchCollection = TouchPanel.GetState(); if (touchCollection.Count() > 0) { TouchLocation tl = touchCollection.First(); if (tl.State == TouchLocationState.Pressed) { // Handle deck touch and find active card Card ret = null; for (int di = 0; di < m_deckList.Count; di++) { ret = m_deckList[di].HandleTouch(tl); if (ret != null) { break; } } // Accept to select cards? if (ret != null && ret.OwnerDeck.Type() != Deck.DeckType.ESourceDeck) { // Turn card and activate if (!ret.IsTurned()) { if (ret.ParentCard == null) { ret.setTurned(true); p_activeCard = ret; } } // Car is turned // Set active card under move else { p_activeCard = ret; } } } else if (tl.State == TouchLocationState.Moved) { // If active card, move it if (p_activeCard != null) { p_activeCard.handleTouch(tl); } } else if (tl.State == TouchLocationState.Released) { // Where active card was released? if (p_activeCard != null) { // Accept moving cards only from target and source decks Deck fromDeck = p_activeCard.OwnerDeck; if (fromDeck != null && (fromDeck.Type() == Deck.DeckType.EUserDeck || fromDeck.Type() == Deck.DeckType.EWasteDeck)) { // Find deck where card was released, accept target and source decks only Deck toDeck = GetDeckUnderTouch(tl); if (toDeck != null && (toDeck.Type() == Deck.DeckType.EUserDeck || toDeck.Type() == Deck.DeckType.ETargetDeck)) { if (toDeck == fromDeck) { // cancel move p_activeCard.cancelMove(); } else { // Check is this card move acceptable if (isAcceptedMove(p_activeCard, toDeck)) { // Accept move fromDeck.RemoveCard(p_activeCard); toDeck.AddCard(p_activeCard); } else { // Cancel move p_activeCard.cancelMove(); } } } else { // Trying to move card between not acceptable decks p_activeCard.cancelMove(); } } else { // Trying to move card between not acceptable decks p_activeCard.cancelMove(); } // Reset active card, no moving ongoing p_activeCard = null; } int count = 0; for (int i = 0; i < m_deckList.Count(); i++) { count += m_deckList[i].CardCount(); } } } }