Setting up the StateManager controller
Now, look at line 6 of the
StateManager class in the following screenshot. We have a big problem right off the bat:
activeState variable needs to be able to store all of the State types. Right now it can only store a reference to a
BeginState type of object. This looks like a huge problem! What about the classes
LostState? What if we had 50 different States that needed to be referenced in
The following diagram is our dilemma:
Studying an example of inheritance
Let's look ...
Get Learning C# by Developing Games with Unity 3D Beginner's Guide 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.