]> Dogcows Code - chaz/carfire/commitdiff
Map shouldn't keep a reference to the game as if it were a property, but it is needed...
authorCharles <Charles@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Fri, 23 Apr 2010 15:25:14 +0000 (15:25 +0000)
committerCharles <Charles@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Fri, 23 Apr 2010 15:25:14 +0000 (15:25 +0000)
git-svn-id: https://bd85.net/svn/cs3505_group@138 92bb83a3-7c8f-8a45-bc97-515c4e399668

CarFire/CarFire/CarFire/Game.cs
CarFire/CarFire/CarFire/Map.cs

index 937cd4d87a243d20a1cf6978eacc465b103a49cf..38088419c59db8bebb2c20f097cbe56102e11f4c 100644 (file)
@@ -260,7 +260,7 @@ namespace CarFire
             {\r
                 State.mCharacters[i].Coordinates = State.Map.GetStartingPositionForPlayer(i + 1);\r
             }\r
-            State.Entities = State.Map.GetAllEntities();\r
+            State.Entities = State.Map.GetAllEntities(this);\r
         }\r
         public void LoadContent(ContentManager contentManager)\r
         {\r
@@ -312,8 +312,7 @@ namespace CarFire
             State.mDisplay.LoadContent(mContentManager);\r
 \r
             State.Map = mContentManager.Load<Map>("Maps/stable");\r
-            State.Map.Game = this;\r
-            State.Entities = State.Map.GetAllEntities();\r
+            State.Entities = State.Map.GetAllEntities(this);\r
             Map.DefaultTile = mContentManager.Load<Texture2D>("default");\r
 \r
             /*\r
index 8c744bad3e8a96962288d966ea47c991911d099a..f4d7ea4fa61a2637b90abff61392efcf52d58ce1 100644 (file)
@@ -166,16 +166,6 @@ namespace CarFire
             set { mView.Zoom = value; }\r
         }\r
 \r
-\r
-        /// <summary>\r
-        /// Get and set the associated game object.\r
-        /// </summary>\r
-        public Game Game\r
-        {\r
-            get { return mData.Game; }\r
-            set { mData.Game = value; }\r
-        }\r
-\r
         #endregion\r
 \r
 \r
@@ -287,21 +277,23 @@ namespace CarFire
         /// Get all the entities loaded from the map file.  Exceptions could be\r
         /// thrown if there are entities without associated classes.\r
         /// </summary>\r
+        /// <param name="game">The game reference to be passed to entities.</param>\r
         /// <returns>List of entity objects loaded.</returns>\r
-        public List<IEntity> GetAllEntities()\r
+        public List<IEntity> GetAllEntities(Game game)\r
         {\r
-            return mData.GetAllEntities();\r
+            return mData.GetAllEntities(game);\r
         }\r
 \r
         /// <summary>\r
         /// Get the entities of a certain type loaded from the map file.  Exceptions\r
         /// could be thrown if there are entities without associated classes.\r
         /// </summary>\r
+        /// <param name="game">The game reference to be passed to entities.</param>\r
         /// <typeparam name="T">Type of the entity you want a list of.</typeparam>\r
         /// <returns>List of entity objects loaded.</returns>\r
-        public List<T> GetEntities<T>()\r
+        public List<T> GetEntities<T>(Game game)\r
         {\r
-            return mData.GetEntities<T>();\r
+            return mData.GetEntities<T>(game);\r
         }\r
 \r
 \r
@@ -368,8 +360,6 @@ namespace CarFire
             public Point[] PlayerPositions { get { return mPlayerPositions; } }\r
             public bool[,] Grid { get { return mBooleanGrid; } }\r
 \r
-            public Game Game;\r
-\r
 \r
             public Model(Metadata metadata, char[,] grid, char defaultTile,\r
                 List<RawEntity> entities, Point[] playerPositions)\r
@@ -438,7 +428,7 @@ namespace CarFire
             }\r
 \r
 \r
-            public List<IEntity> GetAllEntities()\r
+            public List<IEntity> GetAllEntities(Game game)\r
             {\r
                 List<IEntity> list = new List<IEntity>();\r
 \r
@@ -452,14 +442,14 @@ namespace CarFire
                         args[0] = raw.Id;\r
                         args[1] = raw.Position;\r
                         args[2] = raw.Attributes;\r
-                        args[3] = Game;\r
+                        args[3] = game;\r
 \r
                         try\r
                         {\r
                             IEntity entity = (IEntity)Activator.CreateInstance(System.Type.GetType("CarFire." + typename), args);\r
                             if (entity != null)\r
                             {\r
-                                entity.LoadContent(Game.ContentManager);\r
+                                entity.LoadContent(game.ContentManager);\r
                                 list.Add(entity);\r
                             }\r
                             else throw new RuntimeException();\r
@@ -480,7 +470,7 @@ namespace CarFire
                 return list;\r
             }\r
 \r
-            public List<T> GetEntities<T>()\r
+            public List<T> GetEntities<T>(Game game)\r
             {\r
                 System.Type type = typeof(T);\r
                 List<T> list = new List<T>();\r
@@ -494,12 +484,12 @@ namespace CarFire
                         args[0] = raw.Id;\r
                         args[1] = raw.Position;\r
                         args[2] = raw.Attributes;\r
-                        args[3] = Game;\r
+                        args[3] = game;\r
 \r
                         T entity = (T)Activator.CreateInstance(type, args);\r
                         if (entity != null)\r
                         {\r
-                            ((IEntity)entity).LoadContent(Game.ContentManager);\r
+                            ((IEntity)entity).LoadContent(game.ContentManager);\r
                             list.Add(entity);\r
                         }\r
                         else throw new RuntimeException("Entity of type " + typename + " not loaded because an entity class can't be found.");\r
This page took 0.028575 seconds and 4 git commands to generate.