/// </summary>\r
public class Map\r
{\r
- // DEBUG: Tilesets not implemented at all.\r
- public static Texture2D DefaultTile;\r
-\r
-\r
#region Public Constants\r
\r
public const float PixelsToUnitSquares = 64.0f;\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
+ /// <summary>\r
+ /// Get the name of the tileset.\r
+ /// </summary>\r
public string Tileset { get { return mData.Metadata.Tileset; } }\r
\r
/// <summary>\r
set { mView.CenterCell = value; }\r
}\r
\r
+ /// <summary>\r
+ /// Get and set the tilemap with its associated texture and tile\r
+ /// character to coordinate mappings. This effects what the map looks\r
+ /// like when it is drawn.\r
+ /// </summary>\r
+ public static Tilemap Tilemap;\r
+\r
/// <summary>\r
/// Get and set the zoom of the map view. The default zoom is\r
/// Map.PixelsToUnitSquares.\r
return mData.IsCellOpen(x, y);\r
}\r
\r
+ /// <summary>\r
+ /// created by Brady for AI precalculations\r
+ /// </summary>\r
+ /// <param name="x">X-coordinate.</param>\r
+ /// <param name="y">Y-coordinate.</param>\r
+ public bool IsWall(int x, int y)\r
+ {\r
+ return mData.IsWall(x, y);\r
+ }\r
+\r
/// <summary>\r
/// Determine whether or not a cell can be occupied by a game entity.\r
/// </summary>\r
Debug.Assert(grid != null);\r
Debug.Assert(entities != null);\r
Debug.Assert(metadata.GridWidth * metadata.GridHeight == grid.Length);\r
+ Debug.Assert(Tilemap != null);\r
\r
mMetadata = metadata;\r
mCleanGrid = grid;\r
\r
public bool IsCellOpen(int x, int y)\r
{\r
- // TODO: Still need to define characters for types of scenery.\r
- if (IsOnMap(x, y)) return mGrid[x, y] == ' ';\r
- return false;\r
+ if (!IsOnMap(x, y)) return false;\r
+ return (Tilemap.GetTileFlags(mGrid[x, y]) & TileFlags.Open) == TileFlags.Open;\r
+ }\r
+\r
+ //created by Brady for AI precalculations\r
+ public bool IsWall(int x, int y)\r
+ {\r
+ if (!IsOnMap(x, y)) return false;\r
+ return (Tilemap.GetTileFlags(mGrid[x, y]) & TileFlags.Wall) == TileFlags.Wall;\r
}\r
\r
public void SetCell(int x, int y, char tile)\r
}\r
}\r
\r
+ public char GetCell(int x, int y)\r
+ {\r
+ if (IsOnMap(x, y)) return mGrid[x, y];\r
+ return mDefaultTile;\r
+ }\r
+\r
public void ClearCell(int x, int y)\r
{\r
SetCell(x, y, mDefaultTile);\r
\r
public void Draw(SpriteBatch spriteBatch)\r
{\r
+ if (Tilemap == null) throw new Exception("Cannot draw map without first setting the tilemap.");\r
mViewport = spriteBatch.GraphicsDevice.Viewport;\r
\r
- // TODO: There is no culling yet, but it runs so fast that it probably won't ever need it.\r
for (int y = 0; y < mData.Metadata.GridHeight; y++)\r
{\r
for (int x = 0; x < mData.Metadata.GridWidth; x++)\r
{\r
- if (mData.IsCellOpen(x, y))\r
- {\r
- spriteBatch.Draw(Map.DefaultTile, GetRectangleFromCoordinates(x, y), Color.White);\r
- }\r
- else\r
- {\r
- spriteBatch.Draw(Map.DefaultTile, GetRectangleFromCoordinates(x, y), Color.DarkBlue);\r
- }\r
+ Tilemap.Draw(spriteBatch, mData.GetCell(x, y), GetRectangleFromCoordinates(x, y));\r
}\r
}\r
}\r