What you can do is just have a Tile array:
class Grid { Tile[,] grid; }
... and this Tile class has a List<Sprite> in it:
class Tile { List<Sprite> sprites; }
... and that the Sprite class will have your texture and offset:
class Sprite { Vector2 offset; Texture2D texture; }
Complete all this using drawing methods:
class Grid { Tile[,] grid; void Draw(GraphicsDevice graphics) { // call your tiles Draw() } } class Tile { List<Sprite> sprites; void Draw(GraphicsDevice graphics, int x, int y) { // call your sprites Draw() } } class Sprite { Vector2 offset; Texture2D texture; // or texture and rectangle, or whatever void Draw(GraphicsDevice graphics, int x, int y) { // draw the sprite to graphics using x, y, offset and texture } }
Of course, it gets a lot harder, but you should get this idea.
Separating all your problems into different classes, you easily add a new fonctionnality function that will not conflict with existing code. Trying to crush all your data in one object, such as List <Tile> [,], is bad form and will eventually bite you when you try to expand.
source share