I am creating a game in C #. Each level consists of several fragments. Each tile has a specific type, for example. grass floor, wooden wall, etc.
Ideally, I would like to have one base class "Tile" and inherit it to create classes for each type of tile. I would like to have the tile properties of a somehow static / const / etc subclass member, since each type of tile will only ever have the same properties. That is, I do not want 100 Tiles to have a property that has the same value, which seems rather inefficient.
The problem is that you cannot do this in C #. Are there any ways to achieve what I want?
My alternative idea was to split all of this into trees, only with the "Tile" class, which represents an instance and another "TileType", from which I created one object for each type and possibly accessed them through some kind of "TileTypeCollection". This seems strange, although I would prefer to do it first.
Are there any general guidelines for dealing with this situation?
Zeta two
source share