Hi guys,
I’m not sure if this is where I should be putting this post because it’s not really a debugging question as such, but here goes anyway
What’s the best practise for something like this situation:
We’re looking at a tile-based game working around collecting resources to use to build things.
I have a ResourceManager class that maintains tiles on the map that are either Trees or Stone. It keeps the level of resource left on a particular tile (a tree is a finite resource, after all) and will de-spawn said resource if it runs out.
I have an entity class that now needs to find these resources.
The Level class doesn’t give a fig what the map looks like, it just keep a huge list of numbers in an array. Similarly the main Game class that everyone is descended from doesn’t care what the map looks like either, he just holds a GUI and requests that each entity draws itself every now and then.
Should the entity that is looking have the information built-in to know what a Tree is or what Stones look like? Or should it have some interaction with the ResourceManager in order to ask whether a given tile has a resource on it?
If the latter is the answer should the entity store a link to the Game’s instance of the ResourceManager or should the Game provide a public method to allow the entity to call it to request the information?
So far the way everything is set up is that every class has a Game field that they can use to get back to the main Game class but that Game is getting rather busy with methods like canWeMoveOverThisTile() or isThereAnEntityOnThisTile() and soon isThisTileAResource() !!
note, these aren’t actually the method names, I just made them up as examples.
Or maybe I should be moving these tile checking routines to a new class somewhere else?
Thanks for reading my load of rubbish, I hope you understand it and are able to offer me any pointers