root/src/BRAINSFramework/World.cs
| 13 | 20 | ||
|---|---|---|---|
20 | // | 20 | // |
21 | //privates | 21 | //privates |
22 | // | 22 | // |
23 | private List<Agent> _agentsToRemove = new List<Agent>(); | ||
23 | private Texture2D _mapTexture; | 24 | private Texture2D _mapTexture; |
24 | private WorldMap _map; | 25 | private WorldMap _map; |
25 | // | 26 | // |
... | ... | ||
35 | /// </summary> | 36 | /// </summary> |
36 | public List<Agent> Actors = new List<Agent>(); | 37 | public List<Agent> Actors = new List<Agent>(); |
37 | 38 | ||
39 | /// <summary> | ||
40 | /// Gets the world map | ||
41 | /// </summary> | ||
38 | public WorldMap Map { get { return _map; } } | 42 | public WorldMap Map { get { return _map; } } |
39 | 43 | ||
40 | // | 44 | // |
... | ... | ||
60 | } | 64 | } |
61 | } | 65 | } |
62 | 66 | ||
67 | /// <summary> | ||
68 | /// Initializes a new world map with the provides parameters | ||
69 | /// </summary> | ||
70 | /// <param name="width">The width of the map in pixels</param> | ||
71 | /// <param name="height">The height of the map in pixels</param> | ||
72 | /// <param name="cellsize">The size of a cells width or height</param> | ||
63 | public void SetupMap(int width, int height, int cellsize) | 73 | public void SetupMap(int width, int height, int cellsize) |
64 | { | 74 | { |
65 | SetupMap(width, height, cellsize, width / cellsize, height / cellsize,typeof(Grid)); | 75 | SetupMap(width, height, cellsize, width / cellsize, height / cellsize,typeof(Grid)); |
... | ... | ||
287 | actor.ParentWorld = this; | 297 | actor.ParentWorld = this; |
288 | Actors.Add(actor); | 298 | Actors.Add(actor); |
289 | } | 299 | } |
300 | /// <summary> | ||
301 | /// Loads Map data from a texture | ||
302 | /// </summary> | ||
303 | /// <param name="texture">The texture to use</param> | ||
304 | /// <param name="cellSize">The size of a cells width or height</param> | ||
305 | /// <param name="grid">The type of grid to create</param> | ||
290 | public void LoadMapDataFromTexture(Texture2D texture, int cellSize,Type grid) | 306 | public void LoadMapDataFromTexture(Texture2D texture, int cellSize,Type grid) |
291 | { | 307 | { |
292 | LoadMapDataFromTexture(texture, 1, 1, cellSize, grid); | 308 | LoadMapDataFromTexture(texture, 1, 1, cellSize, grid); |
293 | } | 309 | } |
310 | /// <summary> | ||
311 | /// Loads Map data from a texture | ||
312 | /// </summary> | ||
313 | /// <param name="texture">The texture to use</param> | ||
314 | /// <param name="cellSize">The size of a cells width or height</param> | ||
294 | public void LoadMapDataFromTexture(Texture2D texture, int cellSize) | 315 | public void LoadMapDataFromTexture(Texture2D texture, int cellSize) |
295 | { | 316 | { |
296 | LoadMapDataFromTexture(texture, 1, 1, cellSize, typeof(Grid)); | 317 | LoadMapDataFromTexture(texture, 1, 1, cellSize, typeof(Grid)); |
297 | } | 318 | } |
319 | /// <summary> | ||
320 | /// Loads Map data from a texture | ||
321 | /// </summary> | ||
322 | /// <param name="texture">The texture to use</param> | ||
323 | /// <param name="cellSize">The size of a cells width or height</param> | ||
324 | /// <param name="cols">The number of cols to split the map into</param> | ||
325 | /// <param name="rows">The number of rows to split the map into</param> | ||
326 | /// <param name="gridType">The type of grid to create</param> | ||
298 | public void LoadMapDataFromTexture(Texture2D texture, int cols, int rows, int cellSize, Type gridType) | 327 | public void LoadMapDataFromTexture(Texture2D texture, int cols, int rows, int cellSize, Type gridType) |
299 | { | 328 | { |
300 | _mapTexture = texture; | 329 | _mapTexture = texture; |
... | ... | ||
370 | AddActor(_actor); | 399 | AddActor(_actor); |
371 | return _actor; | 400 | return _actor; |
372 | } | 401 | } |
373 | List<Agent> _agentsToRemove = new List<Agent>(); | 402 | |
403 | /// <summary> | ||
404 | /// Removes an Agent from the world | ||
405 | /// </summary> | ||
406 | /// <param name="agent"></param> | ||
374 | public void RemoveAgent(Agent agent) | 407 | public void RemoveAgent(Agent agent) |
375 | { | 408 | { |
376 | _agentsToRemove.Add(agent); | 409 | _agentsToRemove.Add(agent); |
Download diff