You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 likeinactive
.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.
The text was updated successfully, but these errors were encountered: