The Card Slot Class
See the full Java Card Slot Class by clicking the button below.
Java Card Slot ClassThe Java Card Slot class has variables to define it's position on the board, an array to indicate valid attack directions, a Card, a Player and a Face Up boolean.
Card Slot Methods
Build Attack Buttons or in Java buildCanAttack()
As you can see from the image, the Blueprints to build attack buttons is long, while the equivelant Java class is just 15 lines. In case it is hard to see, there is a small window in the upper right corner of the blueprints image with the 'buildCanAttack()' method.
Of course there are couple more variables which have to be set for spawning the buttons in 3D. There is also a seperate Blueprint Class for the attack buttons themselves and those variables have to be set as well. This build function takes care of all that for both player and AI for every card slot that gets created.
The opening branch splits between player and AI then a switch determines which buttons will get created and where. The outer slots only need two buttons and the center slot gets all three. I'll talk about the buttons more during the Button Blueprint Class expo.
Set Attack Button IDs
As part of building the attack buttons, this helper function is called. It uses the SlotID to set the button's Attack and Slot ID variables.
Destroy Card Event
The name of this event is a little deceiving. It does not destroy the card, it destroys the card slot and its buttons. A particle explosion effect is activated along with an accompanying sound effect. Before attempting to destroy the buttons, their existence is validated. It's important to do this check because buttons can be individually destroyed while leaving the card slot. The card inside the slot is destroyed with the Dissolve Card event attached to the Card Blueprint.
Spawn Card Events
There are two spawn card events, one of the player and one for the AI. It first spawns the card inside of the slot then uses the Player's Choices array to set the card data. The Player Choice's array is pulled out of the Level Database, which is looked at in depth on it's own page. Once the card data is set, the attack buttons get their attack render values set with a helper function.
Display Button Value Event
The Display Button Value event is a helper event when spawning the card in each slot. It handles the details for setting the button values. If you look closely, there is an option to set the defend button values depending on a boolean input. I had originally wanted to have defend buttons show up, but deemed it unnecessary. The ability still remains should I decide to add it back in.