コード例 #1
0
    public void ClearTable(CardCollections destination)
    {
        switch (destination)
        {
        case CardCollections.Pot:
            // move cards to pot, clear table list, and remove card GOs
            foreach (Card card in cardsOnTable)
            {
                pot.PlaceInPot(card);
            }

            cardsOnTable.Clear();
            foreach (Transform child in transform)
            {
                Destroy(child.gameObject);
            }
            break;

        case CardCollections.Graveyard:
            // move cards to graveyard, clear table list, and remove card GOs
            foreach (Card card in cardsOnTable)
            {
                deck.PlaceInGraveyard(card);
            }

            cardsOnTable.Clear();
            foreach (Transform child in transform)
            {
                Destroy(child.gameObject);
            }
            break;

        default:
            Debug.LogError("Clearing table to wrong destination. Please set destination to either Pot or Graveyard.");
            break;
        }
    }