DemoProductions / shmup

3 stars 2 forks source link

How to implement new weapons #90

Closed flip40 closed 7 years ago

flip40 commented 8 years ago

If we want to add features to weapons, should we either:

A: Use separate scripts for each weapon type (using inheritance to avoid copy-pasta).

Pros

Cons

B: Use a single script with options (similar to how EnemyMovement works).

Pros

Cons

ghost commented 7 years ago

Both options seems reasonable at the moment, but in the longer term option A sounds more convenient. If we start having a larger list of weapons, I imagine the Weapon script would get convoluted and so would the editor configurations. The GetComponent con may not be too bad, we would have our weapon scripts named appropriately (ex: [replaceWithWeaponName]Weapon). I think the same for EnemyMovement, except it seems more difficult to separate out chunks of code for different movement types. Maybe we can though, the EnemyMovement class we have now can be a base, but say we want certain enemies to do so something like teleport or move in some unique shape.

flip40 commented 7 years ago

Yeah, lets do A. I was concerned for a second as I had just realized I don't actually know how we would get a weapon by GetComponent without using the super class... And according to Google, wherever it was that I heard that you couldn't GetComponent is completely wrong! So A is in fact the superior option, and GetComponent will work as expected. I updated the original post to cross off the mistaken pros / cons in regards to that.