+ /// <summary>\r
+ /// The container class for map metadata.\r
+ /// </summary>\r
+ public class Metadata\r
+ {\r
+ public string Name;\r
+ public Type Type;\r
+ public string Author;\r
+ public HashSet<int> NumPlayers = new HashSet<int>();\r
+ public string Tileset;\r
+ public int GridWidth;\r
+ public int GridHeight;\r
+ }\r
+\r
+ #endregion\r
+\r
+\r
+ #region Public Attributes\r
+\r
+ /// <summary>\r
+ /// Get the name of the map.\r
+ /// </summary>\r
+ public string Name { get { return mData.Metadata.Name; } }\r
+\r
+ /// <summary>\r
+ /// Get the type of the map.\r
+ /// </summary>\r
+ //public Type Type { get { return mData.mMetadata.Type; } }\r
+\r
+ /// <summary>\r
+ /// Get the author of the map.\r
+ /// </summary>\r
+ public string Author { get { return mData.Metadata.Author; } }\r
+\r
+ /// <summary>\r
+ /// Get a set of integers containing each allowable number of players.\r
+ /// </summary>\r
+ public HashSet<int> NumPlayers { get { return mData.Metadata.NumPlayers; } }\r
+\r
+ /// <summary>\r
+ /// Get the width of the map, in grid units.\r
+ /// </summary>\r
+ public int Width { get { return mData.Metadata.GridWidth; } }\r
+\r
+ /// <summary>\r
+ /// Get the height of the map, in grid units.\r
+ /// </summary>\r
+ public int Height { get { return mData.Metadata.GridHeight; } }\r
+\r
+ // TODO: This should return whatever object we end up using for tilesets.\r
+ public string Tileset { get { return mData.Metadata.Tileset; } }\r
+\r
+\r
+ public Vector2 CenterCell\r
+ {\r
+ get { return mView.CenterCell; }\r
+ set { mView.CenterCell = value; }\r
+ }\r
+\r
+ #endregion\r
+\r
+\r
+ #region Public Methods\r
+\r
+ /// <summary>\r
+ /// Construct a map with the provided map data.\r
+ /// </summary>\r
+ /// <param name="data">Map data.</param>\r
+ public Map(Metadata metadata, char[,] grid, Dictionary<char, Dictionary<string, string>> entities)\r
+ {\r
+ mData = new Modal(metadata, grid, entities);\r
+ mView = new View(mData);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Draw a representation of the map to the screen.\r
+ /// </summary>\r
+ /// <param name="spriteBatch">The jeewiz.</param>\r
+ public void Draw(SpriteBatch spriteBatch)\r
+ {\r
+ mView.Draw(spriteBatch);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Get a point in screen-space from a coordinate in gridspace.\r
+ /// </summary>\r
+ /// <param name="x">X-coordinate.</param>\r
+ /// <param name="y">Y-coordinate.</param>\r
+ /// <returns>Transformed point.</returns>\r
+ public Point GetPointFromCoordinates(float x, float y)\r
+ {\r
+ return mView.GetPointFromCoordinates(x, y);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Get a point in screen-space from a coordinate in gridspace.\r
+ /// </summary>\r
+ /// <param name="point">X,Y-coordinates.</param>\r
+ /// <returns>Transformed point.</returns>\r
+ public Point GetPointFromCoordinates(Vector2 point)\r
+ {\r
+ return mView.GetPointFromCoordinates(point.X, point.Y);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Get a rectangle in screen-space centered around a coordinate in gridspace.\r
+ /// </summary>\r
+ /// <param name="x">X-coordinate.</param>\r
+ /// <param name="y">Y-coordinate.</param>\r
+ /// <returns>Transformed rectangle.</returns>\r
+ public Rectangle GetRectangleFromCoordinates(float x, float y)\r
+ {\r
+ return mView.GetRectangleFromCoordinates(x, y);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Get a rectangle in screen-space centered around a coordinate in gridspace.\r
+ /// </summary>\r
+ /// <param name="point">X,Y-coordinates.</param>\r
+ /// <returns>Transformed rectangle.</returns>\r
+ public Rectangle GetRectangleFromCoordinates(Vector2 point)\r
+ {\r
+ return mView.GetRectangleFromCoordinates(point.X, point.Y);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Determine whether or not a cell can be occupied by a game entity.\r
+ /// </summary>\r
+ /// <param name="x">X-coordinate.</param>\r
+ /// <param name="y">Y-coordinate.</param>\r
+ /// <returns>True if cell can be occupied, false otherwise.</returns>\r
+ public bool IsCellOpen(int x, int y)\r
+ {\r
+ return mData.IsCellOpen(x, y);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Determine whether or not a cell can be occupied by a game entity.\r
+ /// </summary>\r
+ /// <param name="x">X,Y-coordinates.</param>\r
+ /// <returns>True if cell can be occupied, false otherwise.</returns>\r
+ public bool IsCellOpen(Point point)\r
+ {\r
+ return mData.IsCellOpen(point.X, point.Y);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Get the entities loaded from the map file.\r
+ /// </summary>\r
+ /// <returns>Dictionary of entities. The keys are the entity\r
+ /// identifiers and the value is a dictionary of key-value pairs\r
+ /// associated with that entity.</returns>\r
+ public Dictionary<char, Dictionary<string, string>> GetEntities()\r
+ {\r
+ return mData.Entities;\r
+ }\r
+\r