Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Power-up System: Implementation #32

Open
antfarmar opened this issue Dec 16, 2015 · 1 comment
Open

Power-up System: Implementation #32

antfarmar opened this issue Dec 16, 2015 · 1 comment

Comments

@antfarmar
Copy link
Owner

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.
@antfarmar
Copy link
Owner Author

Fire Powerup Stacking

Could stack firing powerups using a delegate multicast on the Shoot() methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant