9

Completing the Adventure Game

In Chapter 8, we started by creating a flexible health system that can be added to any object to give it health, take damage, and heal. The system is extensible, meaning the things that can deal with damage and apply healing can be anything without the need to modify the HealthSystem class because we used interfaces to implement the behavior (not concrete class types). With objects now able to take damage, we continued by updating Player and enemy objects to use health – so, we have the semblance of a real game in the making.

We continued by creating a wave spawner that instantiates new enemies on a fixed time interval and integrates with the existing patrol behavior. This allows us to add more complex enemy behavior, ...

Get Unity 2022 by Example 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.