November 2019
Intermediate to advanced
404 pages
12h 9m
English
We've created the messaging system, but an example of how to use it would help us to wrap our heads around the concept. Let's start by defining a pair of simple classes that derive from Message, which we can use to create a new enemy, as well as to notify other parts of our code base that an enemy was created:
public class CreateEnemyMessage : Message {}public class EnemyCreatedMessage : Message { public readonly GameObject enemyObject; public readonly string enemyName; public EnemyCreatedMessage(GameObject enemyObject, string enemyName) { this.enemyObject = enemyObject; this.enemyName = enemyName; }}
CreateEnemyMessage is the simplest form of message that contains no special data, while EnemyCreatedMessage will ...
Read now
Unlock full access