0

For now I have a list of basic data class like position in game world, dimensions, type and stuff like that, but since I am starting to implement their functionality it seems kind of a bad pattern, I need each zone to have totally different data and behaviour, use different UIs etc, is there a pattern to realize that other that just making one totally different class for each zone?

1 Answers1

1

You can use something like a component based, inheritance or composition architecture. You have plenty of options here, and it really boils down to your own style and the requirements of your game.

For a quick implementation, I would probably a simple form of component based architecture. Probably making the components and systems using inheritance. This would allow me to create systems and components that share some functionality, like modifying the attributes of the unit inside their bounds, or creating new units, or whatever's needed. Then when making the zones, I can mix and match components to build whatever kind of zone I want.

Zones would then be defined with the list of components you want them to have. For example adding a "Modify health" component and an "Every X seconds" component would provide your heal-over-time functionality. Or adding a "Modify health" component (with a negative value) and a "Single use" component would create something like a landmine.

I think this will give a good mixture of the two architectures and be flexible enough to provide a lot of options for zones.

House
  • 73,224
  • 17
  • 184
  • 273