Skip to product information
Learning Game Design Patterns with Unity
Learning Game Design Patterns with Unity
Description
Book Introduction
If you want to develop games elegantly, learn design patterns.

This book is written for any game developer who is ready to start working with advanced programming techniques and design patterns in Unity.
Learn the core principles of software design patterns and learn how to build their components efficiently.
The second edition covers design patterns through practical examples, and includes explanations of Game Design Documents (GDD) and Unity programming.
By the end of this book, you'll be able to apply design patterns to Unity to create a systematic, scalable, and optimized process.
  • You can preview some of the book's contents.
    Preview

index
About the Author and Translator xi
Introduction to the Technical Reviewer xii
Translator's Preface xiii
Beta Reader Review xiv
Acknowledgments xvi
About this book xvii

PART 1 | BASICS
CHAPTER 1 | BEFORE YOU GET STARTED 3

1.1 Notes for the 2nd edition 3
1.2 Philosophy of the Book 4
1.3 What is a design pattern? 4
1.4 What topics are not covered in this book? 5
1.5 Game Project 5
1.6 Summary 6

CHAPTER 2 | GAME DESIGN 7
2.1 Planning Document 8
2.2 Summary 18
2.3 Reading 18

CHAPTER 3 | A Brief Introduction to Unity Programming 19
3.1 What You Should Already Know 19
3.2 C# Features 20
3.3 Unity Engine Features 24
3.4 Summary 26
3.5 Reading 26

PART 2 | CORE PATTERNS
CHAPTER 4 | Implementing a Game Manager with Singletons 29

4.1 Technical Requirements 30
4.2 Understanding the Singleton Pattern 30
4.3 Designing a Game Manager 31
4.4 Implementing a Game Manager 32
4.5 Summary 38

CHAPTER 5 | Managing Character State with State Patterns 39
5.1 Technical Requirements 39
5.2 Overview of the State Pattern 40
5.3 Defining Character States 41
5.4 Implementing the State Pattern 42
5.5 Pros and Cons of the State Pattern 49
5.6 Considering Alternatives 50
5.7 Summary 51

CHAPTER 6 | MANAGING GAME EVENTS WITH THE EVENT BUS 53
6.1 Technical Requirements 54
6.2 Understanding the Event Bus Pattern 54
6.3 Implementing a Race Event Bus 58
6.4 Considering Alternatives 65
6.5 Summary 65

CHAPTER 7 | Implementing a Replay System with the Command Pattern 67
7.1 Technical Requirements 68
7.2 Understanding Command Patterns 68
7.3 Designing a Replay System 71
7.4 Implementing a Replay System 72
7.5 Looking at Alternatives 81
7.6 Summary 81

CHAPTER 8 | Optimizing with the Object Pool Pattern 83
8.1 Technical Requirements 84
8.2 Understanding the Object Pool Pattern 84
8.3 Implementing the Object Pool Pattern 86
8.4 Looking at Alternatives 93
8.5 Summary 93

CHAPTER 9 | Decoupling Components with the Observer Pattern 95
9.1 Technical Requirements 95
9.2 Understanding the Observer Pattern 96
9.3 Separating Core Components with the Observer Pattern 98
9.4 Implementing the Observer Pattern 99
9.5 Alternatives 106
9.6 Summary 106

CHAPTER 10 | Implementing Power-Ups with the Visitor Pattern 107
10.1 Technical Requirements 108
10.2 Understanding Visitor Patterns 108
10.3 Designing a Power-Up Mechanism 110
10.4 Implementing the Power-Up Mechanism 111
10.5 Summary 119

CHAPTER 11 | Implementing Drones with Strategic Patterns 121
11.1 Technical Requirements 122
11.2 Understanding Strategy Patterns 122
11.3 Designing Enemy Drones 124
11.4 Implementing Enemy Drones 126
11.5 Alternatives 132
11.6 Summary 133

CHAPTER 12 | Implementing Weapon Systems Using Decorators 135
12.1 Technical Requirements 135
12.2 Understanding the Decorator Pattern 136
12.3 Designing Weapon Systems 138
12.4 Implementing Weapon Systems 139
12.5 Alternatives 149
12.6 Summary 149

CHAPTER 13 | Implementing a Level Editor with Spatial Division 151
13.1 Technical Requirements 152
13.2 Understanding Spatial Partitioning Patterns 152
13.3 Designing the Level Editor 154
13.4 Implementing a Level Editor 156
13.5 Alternatives 161
13.6 Summary 162

PART 3 | Alternative Patterns
CHAPTER 14 | Tune Your System with Adapters 165

14.1 Technical Requirements 165
14.2 Understanding the Adapter Pattern 166
14.3 Implementing the Adapter Pattern 169
14.4 Summary 173

CHAPTER 15 | Hiding Complexity with the Facade Pattern 175
15.1 Technical Requirements 176
15.2 Understanding the Facade Pattern 176
15.3 Designing a Motorcycle Engine 178
15.4 Implementing a Motorcycle Engine 178
15.5 Looking at Alternatives 184
15.6 Summary 184

CHAPTER 16 | Managing Dependencies with the Service Locator Pattern 185
16.1 Technical Requirements 185
16.2 Understanding the Service Locator Pattern 186
16.3 Implementing the Service Locator Pattern 188
16.4 Looking at Alternatives 193
16.5 Summary 193

Search 195

Detailed image
Detailed Image 1

Into the book
Before you start typing any code, there are important steps you need to take in the game development process.
It's about writing a game plan.
A game plan is a blueprint for the entire project.
The primary purpose of a game plan is to document an overall vision of the game's core concepts and guide a multi-disciplinary team of developers throughout the lengthy development process.

--- p.7

For example, the Singleton pattern allows you to quickly create a simple code architecture that wraps and manages all of your game's core systems in individual manager classes.
You can also implement a manager that exposes a clean, intuitive interface that hides the complexity within the game, or you can implement a manager that is easily accessible and has only one instance at a time.
It's a very plausible approach.
However, singletons create strong coupling between core components, making unit testing very difficult.

--- p.29

The event bus pattern is closely related to messaging systems and the publish/subscribe pattern.
Calling it a publish/subscribe system is a more accurate term for what the event bus does.
The keyword for the event bus pattern is bus.
In computer terms, bus refers to a connection between components.
In Chapter 6, an object that can be an event publisher or receiver is a component.

--- p.54

The core purpose of the Observer pattern is to establish a one-to-many relationship between objects, where one object acts as a subject and the other objects act as observers.
An object that assumes the subject role is responsible for notifying observers when changes occur internally.
This is similar to the publisher-subscriber relationship, where objects subscribe to and receive notifications of specific events.
The key difference is that in the Observer pattern, the subject and the observer are aware of each other and are therefore lightly coupled.

--- p.96

One thing to note is that the facade pattern and the adapter can often be confused.
The main difference is that the Facade pattern sets up a simplified front interface as a complex system.
The Adapter pattern reconciles incompatible systems while maintaining a consistent interface to clients.
Both the Adapter pattern and the Facade pattern are structural patterns, but they are related because they have completely different purposes.
--- p.167

Publisher's Review
Taking game development to the next level using design patterns

You've read the introduction to Unity game development, but you're still unsure how to create a good one? Want to develop games in a more elegant way than others? Then here's the Unity Design Patterns Guide.

Design patterns are reusable methods for solving common software development problems.
The author of this book seeks to apply design patterns to Unity to develop games more efficiently.
Using a performance-sensitive racing game as an example, each chapter presents a recurring game programming problem and solves it using design patterns appropriate for the Unity API.

Game Prototype Planning Document, basic C# and Unity concepts are explained in Chapters 1-3.
Chapters 4 through 13 introduce core game development patterns.
Chapter 4 covers the Singleton pattern, Chapter 5 the State pattern, Chapter 6 the Event Bus pattern, Chapter 7 the Command pattern, Chapter 8 the Object Pool pattern, Chapter 9 the Observer pattern, Chapter 10 the Visitor pattern, Chapter 11 the Strategy pattern, Chapter 12 the Decorator pattern, and Chapter 13 the Space Partitioning pattern.
Chapters 14 through 16 describe the Adapter pattern, Facade pattern, and Service Locator pattern as alternative patterns to replace complex subsystems, respectively.

By following along with the 13 patterns applied using a racing game as an example, you'll get a feel for which design patterns to use in your own games.
I recommend this book to game developers who want to shed their beginner label and advance to the next level.

Key Contents
■ Professional Unity code design using industry-standard development patterns
■ Finding the right pattern to implement a specific game mechanic or feature
■ Core game mechanics and components that can be modified without writing a single line of code
■ Practical Object-Oriented Programming (OOP) Techniques and Their Use in Unity Projects
■ Establishment of a unique game development system including a level editor
■ How to apply existing design patterns that can be used with the Unity API
GOODS SPECIFICS
- Publication date: October 31, 2022
- Page count, weight, size: 216 pages | 188*245*20mm
- ISBN13: 9791192469508
- ISBN10: 119246950X

You may also like

카테고리