title: How to Deal Cards to 4 players in Unity?
body: <p>I'm new to Unity and component-based programming and have a little problem.  With so many card games, you'd think there would be some instruction on how to deal the cards, but there aren't...So, here I am.</p>
  <p>I created a Card class, a card database, and a deck class.  I created a GameObject in the Hierarchy that uses the deck class.  Here's the deck class:</p>
  <pre><code>public class PlayerDeck : MonoBehaviour
  {
      public int d;
     
      public List&lt;Card&gt; deck;
      public List&lt;Card&gt; container;
      public List&lt;Card&gt; distributed;
      public List&lt;Card&gt; discarded;
      public int decksize;
  
      void Start()
      {
          
          LoadVariables();
          LoadDeck();
          ShuffleDeck()   
          
          
      }
  
      public void LoadVariables()
      {
          d = 0;
          decksize = 64;
      }
  
      public void LoadDeck()
      {
         
  
          for (int i = 0; i &lt; 64; i++)
          {
              d = i;
              deck[d] = CardDatabase.cardList[i];
          }
      }
  
      public void ShuffleDeck()
      {
  
   
         for (int i=0; i&lt;decksize; i++)
          {
              container[0] = deck[i];
              int rnd = Random.Range(i, decksize);
              deck[i] = deck[rnd];
              deck[rnd] = container[0];
  
          }
  
  
      }
  
      public void DealCards()
      {
      }
  
  }
  </code></pre>
  <p>When I run this in debug, I can see the cards are shuffled.  Now I need the deck to initially deal each player 7 cards like in UNO.  This is where I don't understand component-based programming.  If I have a GameObject called Deck, and 4 other GameObject for players, how can the 4 player gameobjects receive the cards the Deck deals them?</p>
  <p>Any coding help would be appreciated.</p>