How to implement tokenization of game characters?

So I’m a beginner dev working on a turn based dungeon crawler/RPG. At the beginning of each mission, the player will select what characters they want in their party from a roster/pool of available characters (à la X-Com). Not sure if it’s relevant but characters will be generated at runtime.

At the beginning of the project I got some good advice from the forums on how to structure things etc, and one of the bits of advice I got was:

“You’ll also want to tokenise the
characters, because you’ll be
referring to them a lot. A naive
approach is to simply hold an array of
all the characters and pass around
indexes to this array. Don’t do this.
It leads to a nightmare of indexing
hell. It also couples everything to
the class with the array. Instead pass
around tokens that contain the key
references you will need.”

While I understand the concept of tokenisation in broad terms, I have no idea how to implement it and my normally strong Google-fu has failed to turn up anything I can really use.

So there’s really two parts to this question:

First: Can someone explain (or point me towards an explanation) the basic principles of how to implement tokenisation in Unity?

Second: Can someone recommend a suitable approach (or point me towards a tutorial) for implementing tokenisation of my characters?


I guess you could use a Dictionary! It’s in the System.Collections.Generic namespace. Instead of an index you can refer to an object in the dictionary with a key which can be a string and thus a token.

Good luck!