/// <summary> /// Create Deck list from SolitaireDataList /// </summary> /// <param name="toDeckList"></param> /// <param name="allCards"></param> public void ReadDeckDataToList(ref List <Deck> toDeckList, ref List <Card> allCards) { Deck userDeck1 = null; Deck userDeck2 = null; Deck userDeck3 = null; Deck userDeck4 = null; Deck userDeck5 = null; Deck userDeck6 = null; Deck userDeck7 = null; TargetDeck targetDeck1 = null; TargetDeck targetDeck2 = null; TargetDeck targetDeck3 = null; TargetDeck targetDeck4 = null; SourceDeck sourceDeck = null; WasteDeck wasteDeck = null; // Find right decks, have to use internal deck id for matching for (int i = 0; i < toDeckList.Count(); i++) { Deck deck = toDeckList[i]; if (deck.InternalDeckId() == 10) { userDeck1 = deck; } else if (deck.InternalDeckId() == 20) { userDeck2 = deck; } else if (deck.InternalDeckId() == 30) { userDeck3 = deck; } else if (deck.InternalDeckId() == 40) { userDeck4 = deck; } else if (deck.InternalDeckId() == 50) { userDeck5 = deck; } else if (deck.InternalDeckId() == 60) { userDeck6 = deck; } else if (deck.InternalDeckId() == 70) { userDeck7 = deck; } else if (deck.InternalDeckId() == 100) { targetDeck1 = (TargetDeck)deck; } else if (deck.InternalDeckId() == 200) { targetDeck2 = (TargetDeck)deck; } else if (deck.InternalDeckId() == 300) { targetDeck3 = (TargetDeck)deck; } else if (deck.InternalDeckId() == 400) { targetDeck4 = (TargetDeck)deck; } else if (deck.InternalDeckId() == 1000) { sourceDeck = (SourceDeck)deck; } else if (deck.InternalDeckId() == 2000) { wasteDeck = (WasteDeck)deck; } } // Add cards into right decks for (int i = 0; i < m_list.Count(); i++) { // Tombstoned card data list SolitaireData data = m_list[i]; // Find card class Card c = findCard(ref allCards, data.m_land, data.m_id); if (c == null) { break; } c.setTurned(data.m_isTurned); // Set card into right deck switch (data.m_internalDeckId) { case 10: { userDeck1.AddCard(c); break; } case 20: { userDeck2.AddCard(c); break; } case 30: { userDeck3.AddCard(c); break; } case 40: { userDeck4.AddCard(c); break; } case 50: { userDeck5.AddCard(c); break; } case 60: { userDeck6.AddCard(c); break; } case 70: { userDeck7.AddCard(c); break; } case 100: { targetDeck1.AddCard(c); break; } case 200: { targetDeck2.AddCard(c); break; } case 300: { targetDeck3.AddCard(c); break; } case 400: { targetDeck4.AddCard(c); break; } case 1000: { sourceDeck.AddCard(c); break; } case 2000: { wasteDeck.AddCard(c); break; } } } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { System.Diagnostics.Debug.WriteLine("LoadContent"); // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); m_background = this.Content.Load <Texture2D>("background"); // Create all cards for (int i = 1; i < 14; i++) { m_allCards.Add(new Card(Card.CardLandEnum.EClubs, i, nextZ(), this.Content)); } for (int i = 1; i < 14; i++) { m_allCards.Add(new Card(Card.CardLandEnum.EDiamond, i, nextZ(), this.Content)); } for (int i = 1; i < 14; i++) { m_allCards.Add(new Card(Card.CardLandEnum.ESpade, i, nextZ(), this.Content)); } for (int i = 1; i < 14; i++) { m_allCards.Add(new Card(Card.CardLandEnum.EHeart, i, nextZ(), this.Content)); } m_deck.LoadBackground(this.Content); m_deck2.LoadBackground(this.Content); m_deck3.LoadBackground(this.Content); m_deck4.LoadBackground(this.Content); m_deck5.LoadBackground(this.Content); m_deck6.LoadBackground(this.Content); m_deck7.LoadBackground(this.Content); m_targetdeck.LoadBackground(this.Content); m_targetdeck2.LoadBackground(this.Content); m_targetdeck3.LoadBackground(this.Content); m_targetdeck4.LoadBackground(this.Content); m_sourceDeck.LoadBackground(this.Content); m_wasteDeck.LoadBackground(this.Content); if (!m_fromTombstoned) { // Create random decks Card tmpC = null; // Deck 1 tmpC = GetRandomCard(); tmpC.setTurned(true); m_deck.AddCard(tmpC); // Deck 2 m_deck2.AddCard(GetRandomCard()); tmpC = GetRandomCard(); tmpC.setTurned(true); m_deck2.AddCard(tmpC); // Deck 3 m_deck3.AddCard(GetRandomCard()); m_deck3.AddCard(GetRandomCard()); tmpC = GetRandomCard(); tmpC.setTurned(true); m_deck3.AddCard(tmpC); // Deck 4 m_deck4.AddCard(GetRandomCard()); m_deck4.AddCard(GetRandomCard()); m_deck4.AddCard(GetRandomCard()); tmpC = GetRandomCard(); tmpC.setTurned(true); m_deck4.AddCard(tmpC); // Deck 5 m_deck5.AddCard(GetRandomCard()); m_deck5.AddCard(GetRandomCard()); m_deck5.AddCard(GetRandomCard()); m_deck5.AddCard(GetRandomCard()); tmpC = GetRandomCard(); tmpC.setTurned(true); m_deck5.AddCard(tmpC); // Deck 6 m_deck6.AddCard(GetRandomCard()); m_deck6.AddCard(GetRandomCard()); m_deck6.AddCard(GetRandomCard()); m_deck6.AddCard(GetRandomCard()); m_deck6.AddCard(GetRandomCard()); tmpC = GetRandomCard(); tmpC.setTurned(true); m_deck6.AddCard(tmpC); // Deck 7 m_deck7.AddCard(GetRandomCard()); m_deck7.AddCard(GetRandomCard()); m_deck7.AddCard(GetRandomCard()); m_deck7.AddCard(GetRandomCard()); m_deck7.AddCard(GetRandomCard()); m_deck7.AddCard(GetRandomCard()); tmpC = GetRandomCard(); tmpC.setTurned(true); m_deck7.AddCard(tmpC); // Source decks for (int i = 0; i < m_allCards.Count(); i++) { m_sourceDeck.AddCard(GetRandomCard()); i--; } } }