I'm currently making a game that requires item system, where each item will have one or more (up to 12) effects. Some example effect would be: increase damage, increase armour, increase movement speed.
What I want to achieve is, when the item gets equipped by a player, apply the effects of this item to the player.
I have two opinions in my mind:
- use hashmap to store the effect (enum), and having a huge switch case inside the player class, checking for which effect does the item has and apply the corresponding effect.
- use 12 different classes implement the same interface (Effect maybe), where each of these classes only affects one attribute of the player. Every item then has a list of effects. When equipped, apply the effect straight away. (by calling the function in Effect class)
At the moment, I'm stuck on the design choice for implementing it. Any suggestions?
Aucun commentaire:
Enregistrer un commentaire