- Home /
General and OOD advice,General and OOD advice based
Hi, I'm relatively new to objected oriented programming and design, and I have a few questions I'm looking for advice on. I'll also take any side-advice you can offer even if it's not related directly to the question but is related to something I said. Thanks!
1. I'm trying to work with a tile-based system. I've decided that it would be wise to keep track of all these tiles(for pathfinding and other things), and decided a static List is the way to go about it rather than FindAllObjectsWithTag(). Should a static list containing a reference to every created and destroyed tile exist in the Tile script, or should it exist in a secondary 'TileHelper' script that I've written for other purposes?
2. I've created a 'TileHelper' script. The intent was to be used to grab 'shapes' of tiles based off of the origin tile and other inputs. For example, a 3x3 square where the origin is in the center or a 5x5 cross where the origin is in the center. Is this bad design?
3. For several of the shapes in this TileHelper script, I use OverlapBox() to get the areas that will be hit. This works pretty well for most shapes (3x3 square), but for others it is not good (a cross that goes diagonal). I've been considering switching to the case where instead I just do math on the vector of the origin tile to get the location of the other tiles. Is there a quick and efficient way to get an object if you know it's exact location, or would it be better to store a Dict where the key is the Vector position and the value is Tile?
4. Using these helper functions, I want to be able to make very specific areas that can be targeted by certain spells, and areas that will be impacted by the spell based off of the spell and the targeted tile. I feel like creating a class Spell and then a bunch of descendants that are spells (SpellFireball, SpellIcewall, etc) is the wrong way to do this, but I'm not sure how each spell can have different ranges and areas that aren't just numbers but instead are sets of tiles relative to the origin tile passed in. I've been learning about delegate functions and feel like this is the direction I need to head in. Is this a good idea?
Thanks for reading and for any insight you can offer!