-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Labels
Description
Current Implementation
The current implementation of the power-up system is fairly basic. It's design (or lack thereof) was mostly an experiment in inheritance, abstract/virtual methods, and faking GameObject states like inactive.
- uses basic OOP principles of inheritance and overriding methods.
- each power-up script controls granting/denying ship components its respective power in custom overridden methods.
- this requires that each power-up remains active in the scene and gets/has component references.
- power-up objects are never inactive, but are simply disabled/invisible.
- i.e. only Colliders & Renderers are disabled.
- this behaviour eliminates multiple instantiations/destroys, and can work with other designs.
A Better Implementation: Use Events
A better design would make use of more advanced techniques like _Events_. The power-up system is a perfect use case.
- Colliding with a power-up would fire off a respective power-up event.
- Ship script components that the power-up affects would be listeners/subscribers to the event.
- implemented using either delegate events or Unity's event system.
Reactions are currently unavailable