Two Cat Games


Perang: 3 Card Battle

Choose a class below to learn about

The Level Database Actor

Picture of the Data Table in Unreal Engine

This is where I keep my deck, in a data table. A .csv to be precise. By using a .csv file to manage the Perang cards, I can add, subtract or modify cards and their values outside of Unreal Engine, then simply re-import the file. There's a button for it. It is very convenient.

The Level Database Actor, or LDA for short, is used to make the data table accessible. The way I use this actor is similar to how others would use a 'Game Instance' blueprint. In fact, in a later edition, I'm going to attempt transferring some or all of the LDA's functionality over to a 'Game Instance' as I believe it may be more efficient.

In Java, the Deck, along with all other Game Data constants is stored in a single Java class called 'Game Data'. Click the link below to see the full class.

Java Game Data Class

Construction Script

Level Database Actor's Construction script.

The construction script is run, as stated, when the actor is constructed. It first calls the Set Deck Names event, as seen below, then uses the resulting array to set the 'Deck Size' variable and 'Deck Ids' array. These get used by several other blueprints.

Set Deck Names

Set Deck Names event.

Using the data table, sets the 'Deck Names' array.

Event Begin Play

Level Database Actor's Event Begin Play.

An single LDA, is placed in each level. On event begin play, a level check is done which sets the 'Level Switch' variable which determines what set of events gets fired off.

Per Level Events

Per level events for the Level Database Actor.

There are three levels in the game and the LDA performs tasks based on the current level. Currenlty, the LDA has no functions in the main menu. That may change in the future, hence the reason it is still in the blueprint. On the 'Pick Cards' level, the 'New Game Check' and 'Pick Cards' state machine is started. On the 'Battle Board' level, saved choices get loaded and the 'New Game' boolean is set to false.

New Game Check

New game check for the Level Database Actor.

The 'New Game Check' does as it says, checks the 'New Game' status. If there is a previously saved game, it gets loaded and the 'New Game' boolean is branched off. From there, either the 'New Game Save Event' or 'Load Game Event' is fired off.

New Game Save Event

New game save event for the Level Database Actor.

The 'New Game Save Event' initiates three helper events: Delete Old Save, Create and Set Game Save, and Save Starter Deck.

Load Game Event

Load game event for the Level Database Actor.

The 'Load Game Event' is quite simple and makes the assumption a check for a previous game save has already been performed, which it has, then sets three variables: Player Choices, Player Deck by ID, and the New Game boolean.

Set Deck Names

Build Deck Names event.

The short event above sets the 'Deck Names' array using the data table of cards. That array is used by the three card data functions below.

Card Data Functions

Level Database Actor functions for manipulating card data.

These three functions get used by other blueprints to pull informtion from the data table.

Choose a class below to learn about

Card Card Slot Deck Board State Machines
Project Outline Button Widgets Level Database