From: Charles Date: Fri, 23 Apr 2010 15:48:17 +0000 (+0000) Subject: Player inventory. X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=3ca5852a7df47d4129743ed449816c7c7347b699;p=chaz%2Fcarfire Player inventory. git-svn-id: https://bd85.net/svn/cs3505_group@139 92bb83a3-7c8f-8a45-bc97-515c4e399668 --- diff --git a/CarFire/CarFire/CarFire/IEntity.cs b/CarFire/CarFire/CarFire/IEntity.cs index cfa72c2..b812171 100644 --- a/CarFire/CarFire/CarFire/IEntity.cs +++ b/CarFire/CarFire/CarFire/IEntity.cs @@ -9,7 +9,7 @@ using Microsoft.Xna.Framework.Graphics; namespace CarFire { /// - /// A class to represent any object that can exist as an + /// An interface to represent any object that can exist as an /// independent piece of the game. /// public interface IEntity diff --git a/CarFire/CarFire/CarFire/Map.cs b/CarFire/CarFire/CarFire/Map.cs index f4d7ea4..0e66b13 100644 --- a/CarFire/CarFire/CarFire/Map.cs +++ b/CarFire/CarFire/CarFire/Map.cs @@ -22,29 +22,6 @@ namespace CarFire // DEBUG: Tilesets not implemented at all. public static Texture2D DefaultTile; - #region Public Exceptions - - /// - /// This exception is thrown during the loading of a map if any - /// part of the map file is inconsistent with the expected format - /// and order. - /// - public class RuntimeException : System.ApplicationException - { - public RuntimeException() { } - - public RuntimeException(string message) : - base(message) { } - - public RuntimeException(string message, System.Exception inner) : - base(message, inner) { } - - protected RuntimeException(SerializationInfo info, StreamingContext context) : - base(info, context) { } - } - - #endregion - #region Public Constants @@ -452,13 +429,13 @@ namespace CarFire entity.LoadContent(game.ContentManager); list.Add(entity); } - else throw new RuntimeException(); + else throw new Exception(); } #pragma warning disable 0168 catch (System.Exception ex) #pragma warning restore 0168 { - throw new RuntimeException("Entity of type " + typename + " not loaded because an entity class can't be found."); + throw new Exception("Entity of type " + typename + " not loaded because an entity class can't be found."); } } else @@ -492,7 +469,7 @@ namespace CarFire ((IEntity)entity).LoadContent(game.ContentManager); list.Add(entity); } - else throw new RuntimeException("Entity of type " + typename + " not loaded because an entity class can't be found."); + else throw new Exception("Entity of type " + typename + " not loaded because an entity class can't be found."); } } diff --git a/CarFire/CarFire/CarFire/MapReader.cs b/CarFire/CarFire/CarFire/MapReader.cs index ae03ff9..9c58cb3 100644 --- a/CarFire/CarFire/CarFire/MapReader.cs +++ b/CarFire/CarFire/CarFire/MapReader.cs @@ -15,30 +15,6 @@ namespace CarFire /// public class MapReader : ContentTypeReader { - #region Public Exceptions - - /// - /// This exception is thrown during the loading of a map if any - /// part of the map file is inconsistent with the expected format - /// and order. - /// - public class ParserException : System.ApplicationException - { - public ParserException() {} - - public ParserException(string message) : - base(message) {} - - public ParserException(string message, System.Exception inner) : - base(message, inner) {} - - protected ParserException(SerializationInfo info, StreamingContext context) : - base(info, context) {} - } - - #endregion - - #region Protected Methods protected override Map Read(ContentReader input, Map existingInstance) @@ -129,12 +105,12 @@ namespace CarFire } else { - throw new ParserException("Unexpected section on line " + mInput.LineNumber + ": " + section); + throw new Exception("Unexpected section on line " + mInput.LineNumber + ": " + section); } } else { - throw new ParserException("Unexpected text on line " + mInput.LineNumber + ": " + line); + throw new Exception("Unexpected text on line " + mInput.LineNumber + ": " + line); } } } @@ -161,7 +137,7 @@ namespace CarFire catch (System.MissingMethodException ex) #pragma warning restore 0168 { - throw new ParserException("Unexpected key on line " + mInput.LineNumber + ": " + pair[0]); + throw new Exception("Unexpected key on line " + mInput.LineNumber + ": " + pair[0]); } } else @@ -177,7 +153,7 @@ namespace CarFire { if (mMetadata == null || mMetadata.GridWidth == 0 || mMetadata.GridHeight == 0) { - throw new ParserException("Unexpected section on line " + mInput.LineNumber + + throw new Exception("Unexpected section on line " + mInput.LineNumber + ": You must define the map dimensions before this section."); } @@ -190,7 +166,7 @@ namespace CarFire if (line.Length < mMetadata.GridWidth) { - throw new ParserException("Unexpected EOL on line " + mInput.LineNumber + + throw new Exception("Unexpected EOL on line " + mInput.LineNumber + ": The number of characters should match the width dimension (" + mMetadata.GridWidth + ")."); } @@ -202,7 +178,7 @@ namespace CarFire if (y < mMetadata.GridHeight) { - throw new ParserException("Unexpected EOF on line " + mInput.LineNumber + + throw new Exception("Unexpected EOF on line " + mInput.LineNumber + ": The number of lines in this section should match the height dimension (" + mMetadata.GridHeight + ")."); } @@ -237,7 +213,7 @@ namespace CarFire { if (mMetadata == null || mGrid == null) { - throw new ParserException("Missing a required section. Make sure the metadata and grid are there."); + throw new Exception("Missing a required section. Make sure the metadata and grid are there."); } mEntities = new List(); @@ -263,7 +239,7 @@ namespace CarFire } else { - throw new ParserException("Unexpected value of key `create' defined for entity " + identifier + "."); + throw new Exception("Unexpected value of key `create' defined for entity " + identifier + "."); } } pairs.Remove("create"); @@ -289,7 +265,7 @@ namespace CarFire } else { - throw new ParserException("Unexpected entity (" + identifier + + throw new Exception("Unexpected entity (" + identifier + ") placed on the grid at [" + x + "," + y + "] but not defined."); } mGrid[x, y] = mDefaultTile; @@ -311,7 +287,7 @@ namespace CarFire { if (mPlayerPositions[i] == default(Point)) { - throw new ParserException("Not enough player positions were defined on the grid; " + + throw new Exception("Not enough player positions were defined on the grid; " + "you are missing a spot for player " + i + "."); } } @@ -335,21 +311,21 @@ namespace CarFire { string value = Parse.String(atom); if (value != null) mMetadata.Author = value; - else throw new ParserException("Unexpected value on line " + mInput.LineNumber + ": " + atom); + else throw new Exception("Unexpected value on line " + mInput.LineNumber + ": " + atom); } public void set_levelname(string atom) { string value = Parse.String(atom); if (value != null) mMetadata.Name = value; - else throw new ParserException("Unexpected value on line " + mInput.LineNumber + ": " + atom); + else throw new Exception("Unexpected value on line " + mInput.LineNumber + ": " + atom); } public void set_type(string atom) { Map.Mode value = Parse.Constant(atom); if (value != default(Map.Mode)) mMetadata.Type = value; - else throw new ParserException("Unexpected type on line " + mInput.LineNumber + ": " + atom); + else throw new Exception("Unexpected type on line " + mInput.LineNumber + ": " + atom); } public void set_dimensions(string atom) @@ -361,12 +337,12 @@ namespace CarFire mMetadata.GridHeight = dimensions.Value.Y; if (mMetadata.GridWidth <= 0 || mMetadata.GridHeight <= 0) { - throw new ParserException("Invalid dimensions on line " + mInput.LineNumber + ": " + atom); + throw new Exception("Invalid dimensions on line " + mInput.LineNumber + ": " + atom); } } else { - throw new ParserException("Unexpected value on line " + mInput.LineNumber + ": " + atom); + throw new Exception("Unexpected value on line " + mInput.LineNumber + ": " + atom); } } @@ -374,14 +350,14 @@ namespace CarFire { string value = Parse.String(atom); if (value != null) mMetadata.Tileset = value; - else throw new ParserException("Unexpected tileset on line " + mInput.LineNumber + ": " + atom); + else throw new Exception("Unexpected tileset on line " + mInput.LineNumber + ": " + atom); } public void set_defaulttile(string atom) { char? value = Parse.Char(atom); if (value != null) mDefaultTile = value.Value; - else throw new ParserException("Unexpected tile value on line " + mInput.LineNumber + ": " + atom); + else throw new Exception("Unexpected tile value on line " + mInput.LineNumber + ": " + atom); } public void set_numplayers(string atom) @@ -407,16 +383,16 @@ namespace CarFire continue; } - throw new ParserException("Unexpected atom on line " + mInput.LineNumber + ": " + item); + throw new Exception("Unexpected atom on line " + mInput.LineNumber + ": " + item); } if (mMetadata.NumPlayers.Count == 0) { - throw new ParserException("No numbers given on line " + mInput.LineNumber + ": " + atom); + throw new Exception("No numbers given on line " + mInput.LineNumber + ": " + atom); } } else { - throw new ParserException("Unexpected value on line " + mInput.LineNumber + ": " + atom); + throw new Exception("Unexpected value on line " + mInput.LineNumber + ": " + atom); } } diff --git a/CarFire/CarFire/CarFire/Player.cs b/CarFire/CarFire/CarFire/Player.cs index 6af9f19..da1af4e 100644 --- a/CarFire/CarFire/CarFire/Player.cs +++ b/CarFire/CarFire/CarFire/Player.cs @@ -22,6 +22,7 @@ namespace CarFire int playerDamage; int score; MovementManager mMotion; + List mInventory = new List(4); int mPlayerIndex; #endregion @@ -40,6 +41,7 @@ namespace CarFire mMotion = new MovementManager(value, basePlayerSpeed); } } public int Damage { get { return playerDamage; } set { playerDamage = value; } } + public List Inventory { get { return mInventory; } } #endregion #region Public Methods