{\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
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
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
/// 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
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
}\r
\r
\r
- public List<IEntity> GetAllEntities()\r
+ public List<IEntity> GetAllEntities(Game game)\r
{\r
List<IEntity> list = new List<IEntity>();\r
\r
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
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
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