I’ve been thinking for a couple of days now about how to implement weapon enchantments through Unity.
For example:
- Iron Sword (10 damage on hit, 1 attack per second)
- Swift Iron Sword (10 damage on hit, 2 attacks per second)
- Iron Sword of Fire (20 damage on hit, 1 attacks per second, target burns for 5 seconds)
- Swift Iron Sword of Fire (20 damage on hit, 2 attacks per second, target burns for 5 seconds)
I would like to be able to achieve this without having a unique prefab for every single possible combination, primarily as doing so is both time consuming and could eat up a lot of space.
The way I would do this in a “regular” Object Oriented architecture would be decorators.
(Read: The way I WOULD do it, not the way I HAVE done it, this could still be entirely wrong!)
ie,
Weapon sword = new SwiftEnchant( new FireEnchant( new IronMaterial( new Sword() ) ) );
However, I can’t see how a decorator model could exist within the component based architecture of Unity.
Can anyone help me out by pointing me in the right direction here? It would be much appreciated.