13

Making Monsters with the Type Object Pattern

In the last chapter, we worked on a system of interchangeable algorithms (strategies) that could be assigned at runtime or during gameplay without the client knowing the nitty-gritty details. In this chapter, we’re going to take a step back from behavior and put our sights on data and the Type Object pattern, which lets you create different configurations of the same object with the least number of classes (because all the cool kids use flat hierarchies).

Specifically, we’ll try to find common data that all related objects share, separate it out into its own class, and inject it back into the object we want to configure. You can create infinite combinations of the same object by giving them different ...

Get Learning Design Patterns with Unity now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.