// DEBUG: Tilesets not implemented at all.\r
public static Texture2D DefaultTile;\r
\r
- #region Public Exceptions\r
-\r
- /// <summary>\r
- /// This exception is thrown during the loading of a map if any\r
- /// part of the map file is inconsistent with the expected format\r
- /// and order.\r
- /// </summary>\r
- public class RuntimeException : System.ApplicationException\r
- {\r
- public RuntimeException() { }\r
-\r
- public RuntimeException(string message) :\r
- base(message) { }\r
-\r
- public RuntimeException(string message, System.Exception inner) :\r
- base(message, inner) { }\r
-\r
- protected RuntimeException(SerializationInfo info, StreamingContext context) :\r
- base(info, context) { }\r
- }\r
-\r
- #endregion\r
-\r
\r
#region Public Constants\r
\r
entity.LoadContent(game.ContentManager);\r
list.Add(entity);\r
}\r
- else throw new RuntimeException();\r
+ else throw new Exception();\r
}\r
#pragma warning disable 0168\r
catch (System.Exception ex)\r
#pragma warning restore 0168\r
{\r
- throw new RuntimeException("Entity of type " + typename + " not loaded because an entity class can't be found.");\r
+ throw new Exception("Entity of type " + typename + " not loaded because an entity class can't be found.");\r
}\r
}\r
else\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
+ else throw new Exception("Entity of type " + typename + " not loaded because an entity class can't be found.");\r
}\r
}\r
\r
/// </summary>\r
public class MapReader : ContentTypeReader<Map>\r
{\r
- #region Public Exceptions\r
-\r
- /// <summary>\r
- /// This exception is thrown during the loading of a map if any\r
- /// part of the map file is inconsistent with the expected format\r
- /// and order.\r
- /// </summary>\r
- public class ParserException : System.ApplicationException\r
- {\r
- public ParserException() {}\r
-\r
- public ParserException(string message) :\r
- base(message) {}\r
-\r
- public ParserException(string message, System.Exception inner) :\r
- base(message, inner) {}\r
-\r
- protected ParserException(SerializationInfo info, StreamingContext context) :\r
- base(info, context) {}\r
- }\r
-\r
- #endregion\r
-\r
-\r
#region Protected Methods\r
\r
protected override Map Read(ContentReader input, Map existingInstance)\r
}\r
else\r
{\r
- throw new ParserException("Unexpected section on line " + mInput.LineNumber + ": " + section);\r
+ throw new Exception("Unexpected section on line " + mInput.LineNumber + ": " + section);\r
}\r
}\r
else\r
{\r
- throw new ParserException("Unexpected text on line " + mInput.LineNumber + ": " + line);\r
+ throw new Exception("Unexpected text on line " + mInput.LineNumber + ": " + line);\r
}\r
}\r
}\r
catch (System.MissingMethodException ex)\r
#pragma warning restore 0168\r
{\r
- throw new ParserException("Unexpected key on line " + mInput.LineNumber + ": " + pair[0]);\r
+ throw new Exception("Unexpected key on line " + mInput.LineNumber + ": " + pair[0]);\r
}\r
}\r
else\r
{\r
if (mMetadata == null || mMetadata.GridWidth == 0 || mMetadata.GridHeight == 0)\r
{\r
- throw new ParserException("Unexpected section on line " + mInput.LineNumber +\r
+ throw new Exception("Unexpected section on line " + mInput.LineNumber +\r
": You must define the map dimensions before this section.");\r
}\r
\r
\r
if (line.Length < mMetadata.GridWidth)\r
{\r
- throw new ParserException("Unexpected EOL on line " + mInput.LineNumber +\r
+ throw new Exception("Unexpected EOL on line " + mInput.LineNumber +\r
": The number of characters should match the width dimension (" + mMetadata.GridWidth + ").");\r
}\r
\r
\r
if (y < mMetadata.GridHeight)\r
{\r
- throw new ParserException("Unexpected EOF on line " + mInput.LineNumber +\r
+ throw new Exception("Unexpected EOF on line " + mInput.LineNumber +\r
": The number of lines in this section should match the height dimension (" + mMetadata.GridHeight + ").");\r
}\r
\r
{\r
if (mMetadata == null || mGrid == null)\r
{\r
- throw new ParserException("Missing a required section. Make sure the metadata and grid are there.");\r
+ throw new Exception("Missing a required section. Make sure the metadata and grid are there.");\r
}\r
\r
mEntities = new List<Map.RawEntity>();\r
}\r
else\r
{\r
- throw new ParserException("Unexpected value of key `create' defined for entity " + identifier + ".");\r
+ throw new Exception("Unexpected value of key `create' defined for entity " + identifier + ".");\r
}\r
}\r
pairs.Remove("create");\r
}\r
else\r
{\r
- throw new ParserException("Unexpected entity (" + identifier +\r
+ throw new Exception("Unexpected entity (" + identifier +\r
") placed on the grid at [" + x + "," + y + "] but not defined.");\r
}\r
mGrid[x, y] = mDefaultTile;\r
{\r
if (mPlayerPositions[i] == default(Point))\r
{\r
- throw new ParserException("Not enough player positions were defined on the grid; " +\r
+ throw new Exception("Not enough player positions were defined on the grid; " +\r
"you are missing a spot for player " + i + ".");\r
}\r
}\r
{\r
string value = Parse.String(atom);\r
if (value != null) mMetadata.Author = value;\r
- else throw new ParserException("Unexpected value on line " + mInput.LineNumber + ": " + atom);\r
+ else throw new Exception("Unexpected value on line " + mInput.LineNumber + ": " + atom);\r
}\r
\r
public void set_levelname(string atom)\r
{\r
string value = Parse.String(atom);\r
if (value != null) mMetadata.Name = value;\r
- else throw new ParserException("Unexpected value on line " + mInput.LineNumber + ": " + atom);\r
+ else throw new Exception("Unexpected value on line " + mInput.LineNumber + ": " + atom);\r
}\r
\r
public void set_type(string atom)\r
{\r
Map.Mode value = Parse.Constant<Map.Mode>(atom);\r
if (value != default(Map.Mode)) mMetadata.Type = value;\r
- else throw new ParserException("Unexpected type on line " + mInput.LineNumber + ": " + atom);\r
+ else throw new Exception("Unexpected type on line " + mInput.LineNumber + ": " + atom);\r
}\r
\r
public void set_dimensions(string atom)\r
mMetadata.GridHeight = dimensions.Value.Y;\r
if (mMetadata.GridWidth <= 0 || mMetadata.GridHeight <= 0)\r
{\r
- throw new ParserException("Invalid dimensions on line " + mInput.LineNumber + ": " + atom);\r
+ throw new Exception("Invalid dimensions on line " + mInput.LineNumber + ": " + atom);\r
}\r
}\r
else\r
{\r
- throw new ParserException("Unexpected value on line " + mInput.LineNumber + ": " + atom);\r
+ throw new Exception("Unexpected value on line " + mInput.LineNumber + ": " + atom);\r
}\r
}\r
\r
{\r
string value = Parse.String(atom);\r
if (value != null) mMetadata.Tileset = value;\r
- else throw new ParserException("Unexpected tileset on line " + mInput.LineNumber + ": " + atom);\r
+ else throw new Exception("Unexpected tileset on line " + mInput.LineNumber + ": " + atom);\r
}\r
\r
public void set_defaulttile(string atom)\r
{\r
char? value = Parse.Char(atom);\r
if (value != null) mDefaultTile = value.Value;\r
- else throw new ParserException("Unexpected tile value on line " + mInput.LineNumber + ": " + atom);\r
+ else throw new Exception("Unexpected tile value on line " + mInput.LineNumber + ": " + atom);\r
}\r
\r
public void set_numplayers(string atom)\r
continue;\r
}\r
\r
- throw new ParserException("Unexpected atom on line " + mInput.LineNumber + ": " + item);\r
+ throw new Exception("Unexpected atom on line " + mInput.LineNumber + ": " + item);\r
}\r
if (mMetadata.NumPlayers.Count == 0)\r
{\r
- throw new ParserException("No numbers given on line " + mInput.LineNumber + ": " + atom);\r
+ throw new Exception("No numbers given on line " + mInput.LineNumber + ": " + atom);\r
}\r
}\r
else\r
{\r
- throw new ParserException("Unexpected value on line " + mInput.LineNumber + ": " + atom);\r
+ throw new Exception("Unexpected value on line " + mInput.LineNumber + ": " + atom);\r
}\r
}\r
\r