]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/Map.cs
New property IEntity.IsCollidable so entities can let the collision code know whether...
[chaz/carfire] / CarFire / CarFire / CarFire / Map.cs
index ae49c8a8c3bc2f635329f3e57615de4069020cd5..0178e2ba7188884deceb6bc5a1432d323bebee3e 100644 (file)
@@ -134,13 +134,11 @@ namespace CarFire
         /// <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
+        /// like when it is drawn.  You will need to reset any map instances\r
+        /// after setting a new tilemap.  You should also set a tilemap before\r
+        /// instantiating any maps.\r
         /// </summary>\r
-        public Tilemap Tilemap\r
-        {\r
-            get { return mData.Tilemap; }\r
-            set { mData.Tilemap = value; }\r
-        }\r
+        public static Tilemap Tilemap;\r
 \r
         /// <summary>\r
         /// Get and set the zoom of the map view.  The default zoom is\r
@@ -355,7 +353,6 @@ namespace CarFire
             public List<RawEntity> Entities { get { return mEntities; } }\r
             public Point[] PlayerPositions { get { return mPlayerPositions; } }\r
             public bool[,] Grid { get { return mBooleanGrid; } }\r
-            public Tilemap Tilemap;\r
 \r
 \r
             public Model(Metadata metadata, char[,] grid, char defaultTile,\r
@@ -365,6 +362,7 @@ namespace CarFire
                 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
@@ -542,14 +540,14 @@ namespace CarFire
 \r
             public void Draw(SpriteBatch spriteBatch)\r
             {\r
-                if (mData.Tilemap == null) throw new Exception("Cannot draw map without first setting the tilemap.");\r
+                if (Tilemap == null) throw new Exception("Cannot draw map without first setting the tilemap.");\r
                 mViewport = spriteBatch.GraphicsDevice.Viewport;\r
 \r
                 for (int y = 0; y < mData.Metadata.GridHeight; y++)\r
                 {\r
                     for (int x = 0; x < mData.Metadata.GridWidth; x++)\r
                     {\r
-                        mData.Tilemap.Draw(spriteBatch, mData.GetCell(x, y), GetRectangleFromCoordinates(x, y));\r
+                        Tilemap.Draw(spriteBatch, mData.GetCell(x, y), GetRectangleFromCoordinates(x, y));\r
                     }\r
                 }\r
             }\r
This page took 0.024068 seconds and 4 git commands to generate.