Unity :: Warlords CCG

Warlords is a strategic CCG set in medical Europe. Play cards to build a castle and raise an army, then crush your enemies.

The player builds a deck by collecting units, buildings, and ploys, which they take into a match. Buildings are placed adjacent to each other to build a castle that provides resources. These resources are then used to recruit unit cards into the player’s army. Armies are then sent against an opponents castle to destroy their buildings and break through to the fort to bring the opposing warlord down.

Building placement adds the first strategic element, do you place buildings in front of your fort to protect it, or to the side where they can avoid damage. The second strategic element is in unit attack groups, which units do you assign to which part of the opposing castle during an attack. Do you spread them evenly, do you go all out for one target, or do you focus your best units on one area and then spread the weaker ones amongst other targets.

Combat takes place in a separate mini-game. If an attacking group has a defender sent against it they square off in an arena. Each player takes turns to play units and ploys until either player runs out of units, or flees the arena.

Key Features

  • Faction-based Strategies: Culture and religion based factions with cards tailored towards different strategies.
  • Unit Cards: A variety of different Medieval units from rampaging Knights to filthy Peasants.
  • Mercenary Cards: Grizzled veterans and exotic units from far off lands add rich depth to armies.
  • Building Cards: Generate resources to raise troops by tailoring your castle towards your strategic plan.
  • Ploy Cards: Cunning tactics to out wit and out manoeuvre your opponents in battle.
  • Rich Deck Building: Create different decks to execute different strategies via the deck manager.
  • Multiple Match Types: Engage in a 1v1 duels. Form an alliance for a epic 2v2 battle. Throw cation to the wind in a 4 player free-for-all.

Game Loop

Acquiring a fresh new hand

Image 1 of 12

During play, the turn alternates between players and they complete four phases in sequence.

  • Acquire: Draw from the deck to increase your hand and claim resources from your buildings
  • Build: Use your resources to play a building card and improve your castle
  • Attack: If you have units available and you see a weakness in your enemy, you can strike
  • Recruit: Use your resources to add units to your army.

AI Opponent

The prototype has a complete game loop that includes a simple Ai implementation. This Ai makes decisions and performs actions based on the current phase. These decision routines are triggered by the game manager at the beginning of an Ai phase.

During the acquire phase the Ai draws a new card then evaluates their deck, castle, and army. It determines which cards it has the resources to play then examines the player’s castle and army to determine its priorities. If the player can threaten its castle, it will focus on deploying troops to ensure it at least maintains parity with the player.

During the build and recruitment phases, whichever is prioritised, the Ai will examine the cards in its hand and determine which it has the resources to play. It will also engage with the trader if it lacks the correct combination of resources to play its desired card.

During the attack phase, the Ai will determine if it can damage the player and will target the most valuable buildings for attack, but it plays conservatively and will not risk attack if the player has a superior number.

Unity3D Construction

Unit card prefab

Image 1 of 2

A match in Warlords is run by the ‘battlemanager’ script, which controls the triggering of phases and the UI transitions. This manager keeps track of which deck’s turn it is and which phase they are in, prompting their state change and triggering their process. It has no awareness of the owner of the deck, it simply controls permissions.

The decks themselves are a control interface that provides hookup methods and data definitions, such as the SelectCard() method. This method allows any controlling script to access the deck and perform actions on a card. As with the battle manager, a deck has no awareness of who is controlling them they are just a puppet with a lot of strings to be pulled.

Control scripts are attached to decks to complete the system. They access a deck’s methods and allow the players, human or Ai, to play the game.

Revisions and Improvements

Revised card prefab

Image 3 of 3

The prototype has areas for improvement, most notably the card prefab. It uses three worldspace canvases in a layer, which may be the wrong approach as the Ui profiler reveals performance spikes each time a card is spawned. Additionally, the number of canvases in play may cause problems later when there are dozens of cards rendering three canvases each.

The card requires a canvas to render its data, such as name and image, to ensure that one gameobject can be used for an infinite number of cards. The three-layer approach was necessary as the sorting layer prevented the front and back of the card from displaying correctly when on the same canvas. However, a sprite rendered could be a better approach.

By layering the cards back, image, and face frame, with sprite renders the same effect can be achieved. Only a single canvas is required to overlay the card’s data, which only needs to be activated when the card is selected for viewing.

Enhancing Strategic Elements

There are areas of the prototype where the strategic elements can be improved upon. Firstly, a greater variety of resources types will provide strategy when planning and deck building. If a player cannot feasibly add buildings of every resource type to their deck, they will need to pick and choose, they will need to tailor their it towards a strategy.

Currently, there are only four resources and they are not adequate. Wood is used to provide higher tier buildings. Iron and horse provide higher tier units. Coin is a mostly generic resource that can also be used for mercenary units. This doesn’t offer much scope for strategy. A player can favour buildings that generate coins and then focus on using mercenaries, or they can take several stable to ensure their army is cavalry heavy.

Additional resources and a better balance in their use will provide better strategic gameplay. Some examples:

  • Engineers: People that can create siege engines
  • Oppression: Good for conscripting peasants and militia to your cause
  • Stone: Useful for building better fortifications.
  • Faith: Exploit the religious beliefs of the plebs to recruit bands of fanatics, crusaders, and other unhinged sociopaths.