A toolkit designed for Unity developers to create and manage card decks, demonstrating the power of scriptable objects. Developed as a personal learning project.
- Create and manage card decks in Unity projects.
- Demonstrates the usage of scriptable objects for data management.
- Includes functionality for shuffling decks, drawing cards, and adding cards to decks.
-
Setup:
- Import the
CardDeckLogicnamespace in your scripts to access the card deck functionality. - Create
DeckDatascriptable objects to define your card decks. - Create
CardDatascriptable objects to define individual cards.
- Import the
-
Create Decks:
- Define your card decks by creating instances of
DeckDatascriptable objects. - Customize the deck name, description, cover artwork, and list of cards.
- Define your card decks by creating instances of
-
Manage Decks:
- Use the
CardDeckclass to manage your card decks within your Unity project. - Shuffle decks, draw cards, add cards to decks, and manage a discard pile.
- Use the
- CardDeck.cs: Defines the
CardDeckclass for managing card decks. Includes functionality for shuffling decks, drawing cards, and adding cards. - DeckData.cs: Defines the
DeckDatascriptable object class for defining card decks. Includes properties for deck name, description, cover artwork, and list of cards. - CardData.cs: Defines the
CardDatascriptable object class for defining individual cards. Includes properties for card name, description, artwork, mana cost, power, defense, and health. - DiscardPile.cs: Defines the
DiscardPileclass for managing a discard pile in Unity card games. Provides methods to add cards to the discard pile and clear the discard pile.
- Clone or download this repository.
- Copy the
DeckOfCardsfolder into your Unity project'sAssetsdirectory. - Use the provided classes and scriptable objects in your Unity project as needed.
using UnityEngine;
using CardDeckLogic.Scriptables;
using CardDeckLogic;
public class ExampleUsage : MonoBehaviour
{
public DeckData exampleDeck;
private CardDeck cardDeck;
private void Start()
{
cardDeck = GetComponent<CardDeck>();
if (cardDeck != null && exampleDeck != null)
{
// Shuffle the example deck
cardDeck.Data = exampleDeck;
cardDeck.ShuffleDeck();
}
}
}This project is licensed under the MIT License.