]> Dogcows Code - chaz/carfire/commitdiff
Player inventory.
authorCharles <Charles@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Fri, 23 Apr 2010 15:48:17 +0000 (15:48 +0000)
committerCharles <Charles@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Fri, 23 Apr 2010 15:48:17 +0000 (15:48 +0000)
git-svn-id: https://bd85.net/svn/cs3505_group@139 92bb83a3-7c8f-8a45-bc97-515c4e399668

CarFire/CarFire/CarFire/IEntity.cs
CarFire/CarFire/CarFire/Map.cs
CarFire/CarFire/CarFire/MapReader.cs
CarFire/CarFire/CarFire/Player.cs

index cfa72c2cce0d60a06643743ab8f6121f61a47545..b8121719f1aef7614764591981af146b55be8a44 100644 (file)
@@ -9,7 +9,7 @@ using Microsoft.Xna.Framework.Graphics;
 namespace CarFire\r
 {\r
     /// <summary>\r
-    /// A class to represent any object that can exist as an\r
+    /// An interface to represent any object that can exist as an\r
     /// independent piece of the game.\r
     /// </summary>\r
     public interface IEntity\r
index f4d7ea4fa61a2637b90abff61392efcf52d58ce1..0e66b139221bf27d1206517e32461d3993fa879c 100644 (file)
@@ -22,29 +22,6 @@ namespace CarFire
         // 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
@@ -452,13 +429,13 @@ namespace CarFire
                                 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
@@ -492,7 +469,7 @@ namespace CarFire
                             ((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
index ae03ff9ea7b607aa7055cf411c86fa35031d25d5..9c58cb34d72caebf290563ff8a9ce406c3903eff 100644 (file)
@@ -15,30 +15,6 @@ namespace CarFire
     /// </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
@@ -129,12 +105,12 @@ namespace CarFire
                             }\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
@@ -161,7 +137,7 @@ namespace CarFire
                         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
@@ -177,7 +153,7 @@ namespace CarFire
             {\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
@@ -190,7 +166,7 @@ namespace CarFire
 \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
@@ -202,7 +178,7 @@ namespace CarFire
 \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
@@ -237,7 +213,7 @@ namespace CarFire
             {\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
@@ -263,7 +239,7 @@ namespace CarFire
                             }\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
@@ -289,7 +265,7 @@ namespace CarFire
                             }\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
@@ -311,7 +287,7 @@ namespace CarFire
                 {\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
@@ -335,21 +311,21 @@ namespace CarFire
             {\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
@@ -361,12 +337,12 @@ namespace CarFire
                     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
@@ -374,14 +350,14 @@ namespace CarFire
             {\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
@@ -407,16 +383,16 @@ namespace CarFire
                             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
index 6af9f194508ece7e82bf106675fff3370edba670..da1af4ecc02a385cef816c1d5a2ca97d1326337b 100644 (file)
@@ -22,6 +22,7 @@ namespace CarFire
         int playerDamage;\r
         int score;\r
         MovementManager mMotion;\r
+        List<IEntity> mInventory = new List<IEntity>(4);\r
         int mPlayerIndex;\r
         #endregion\r
 \r
@@ -40,6 +41,7 @@ namespace CarFire
                 mMotion = new MovementManager(value, basePlayerSpeed);\r
             } }\r
         public int Damage { get { return playerDamage; } set { playerDamage = value; } }\r
+        public List<IEntity> Inventory { get { return mInventory; } }\r
         #endregion\r
 \r
         #region Public Methods\r
This page took 0.036599 seconds and 4 git commands to generate.