/// <param name="metadata">The metadata.</param>\r
/// <param name="grid">The grid.</param>\r
/// <param name="entities">The entities.</param>\r
/// <param name="metadata">The metadata.</param>\r
/// <param name="grid">The grid.</param>\r
/// <param name="entities">The entities.</param>\r
- public Map(Metadata metadata, char[,] grid, List<RawEntity> entities)\r
+ public Map(Metadata metadata, char[,] grid, List<RawEntity> entities, Point[] playerPositions)\r
- mData = new Modal(metadata, grid, entities);\r
+ mData = new Modal(metadata, grid, entities, playerPositions);\r
mView = new View(mData);\r
}\r
\r
mView = new View(mData);\r
}\r
\r
+ /// <summary>\r
+ /// Get the starting position of a player.\r
+ /// </summary>\r
+ /// <param name="playerNumber">The number of the player (i.e. 1-4).\r
+ /// This number must be a valid player number.</param>\r
+ /// <returns>The starting position of the player.</returns>\r
+ public Point GetStartingPositionForPlayer(int playerNumber)\r
+ {\r
+ Debug.Assert(1 <= playerNumber && playerNumber <= NumPlayers.Max());\r
+ return mData.PlayerPositions[playerNumber];\r
+ }\r
+\r
+\r
/// <summary>\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
/// Get all the entities loaded from the map file. Exceptions could be\r
/// thrown if there are entities without associated classes.\r
Metadata mMetadata;\r
char[,] mGrid;\r
List<RawEntity> mEntities;\r
Metadata mMetadata;\r
char[,] mGrid;\r
List<RawEntity> mEntities;\r
+ Point[] mPlayerPositions;\r
- public Modal(Metadata metadata, char[,] grid, List<RawEntity> entities)\r
+ public Modal(Metadata metadata, char[,] grid, List<RawEntity> entities, Point[] playerPositions)\r
{\r
Debug.Assert(metadata != null);\r
Debug.Assert(grid != null);\r
{\r
Debug.Assert(metadata != null);\r
Debug.Assert(grid != null);\r
mMetadata = metadata;\r
mGrid = grid;\r
mEntities = entities;\r
mMetadata = metadata;\r
mGrid = grid;\r
mEntities = entities;\r
+ mPlayerPositions = playerPositions;\r
\r
#if DEBUG\r
Console.WriteLine("Loaded map {0} of type {1} written by {2}.",\r
\r
#if DEBUG\r
Console.WriteLine("Loaded map {0} of type {1} written by {2}.",\r
\r
public Metadata Metadata { get { return mMetadata; } }\r
public List<RawEntity> Entities { get { return mEntities; } }\r
\r
public Metadata Metadata { get { return mMetadata; } }\r
public List<RawEntity> Entities { get { return mEntities; } }\r
+ public Point[] PlayerPositions { get { return mPlayerPositions; } }\r
\r
\r
public bool IsCellOpen(int x, int y)\r
\r
\r
public bool IsCellOpen(int x, int y)\r
\r
public Map GetMap()\r
{\r
\r
public Map GetMap()\r
{\r
- return new Map(mMetadata, mGrid, mEntities);\r
+ return new Map(mMetadata, mGrid, mEntities, mPlayerPositions);\r
/// <summary>\r
/// Class with handy static methods taking strings and returning objects\r
/// parsed from those strings. For all of these functions, white space is\r
/// <summary>\r
/// Class with handy static methods taking strings and returning objects\r
/// parsed from those strings. For all of these functions, white space is\r
- /// generally ignored, but any superfluous characters will make the parse fail.\r
+ /// generally ignored, but superfluous characters are not allowed.\r
/// </summary>\r
public class Parse\r
{\r
/// </summary>\r
public class Parse\r
{\r
/// Parses a comment of an INI file.\r
/// </summary>\r
/// <param name="line">Text.</param>\r
/// Parses a comment of an INI file.\r
/// </summary>\r
/// <param name="line">Text.</param>\r
- /// <returns>The comment.</returns>\r
+ /// <returns>The comment, or null if parsing failed.</returns>\r
public static string IniComment(string line)\r
{\r
Match match = Regex.Match(line, @"^;\s*(.*)\s*$");\r
public static string IniComment(string line)\r
{\r
Match match = Regex.Match(line, @"^;\s*(.*)\s*$");\r