The original, UNET-based version of CCG Kit included a single-player mode against a bot that was built using UNET's couch multiplayer feature. This was extremely convenient, as it made it possible to have a single-player mode working within the existing multiplayer architecture of the kit (with no separate codebase). Unfortunately, with the migration of the kit to Mirror, the same approach is not technically feasible anymore due to Mirror's removal of couch multiplayer. This means there are two options for having a single-player feature in the Mirror-based version of the kit:
- Re-architecting the kit's entire networking architecture to support bots, which essentially means keeping a separate single-player codebase.
- Make single-player mode be based around having a separate background process that acts as an offline client and therefore uses the exact same networking architecture used for multiplayer.
As of update 2.1.0 of the kit, we include a single-player mode based on the latter option. While having a separate Unity process in the background for the bot sounds like a bit of a "hacky" approach to the matter, it enables us to keep the same codebase for both single-player and multiplayer modes and circumvents the need for a complete rewrite of the kit's battle-tested networking architecture.
How to use the single-player mode
You first need to build the bot binary. Only two scenes, Bot and Game, are needed for this. We recommend using the 'Dedicated Server' build option for the bot, because this binary does not require a visual representation.
With the bot binary built, you can now play normally and select the 'Single-player' option in the Lobby screen:
Once the loading popup appears, you just need to launch the bot binary and it will automatically join the player in a 1v1 match.
Extending the single-player mode
The built-in single-player mode is mainly intended to showcase how you can build a bot that seamlessly integrates with the existing networking architecture of the kit and as a convenient way to test your game without needing two players. It is not intended to showcase an extremely advanced artificial intelligence or story mode. Please note the bot's logic is exactly the same that we used in the original, UNET-based version of the kit.
If you want to use the included bot as the starting point for building your own single-player/story mode in your game, the first thing you will want to do is to make the launching of the bot binary happen automatically and transparently on the background. We do not do this by default because we cannot assume how you will ultimately deploy your game to your players. The easiest way to launch an external process from within a Unity application is via Process.Start, so you could deploy two binaries with your game and have the main game client automatically launch the bot process at the appropriate times (i.e., when the player selects the single-player/story mode).