From: Charles Date: Mon, 26 Apr 2010 18:40:34 +0000 (+0000) Subject: New property IEntity.IsCollidable so entities can let the collision code know whether... X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=60d05271b295d2ca94a0028059add525c1bbffb1;p=chaz%2Fcarfire New property IEntity.IsCollidable so entities can let the collision code know whether or not they are collidable. Entities that are not collidable can exist in the same cells with other entities, but of course only one collidable entity can exist in a cell. git-svn-id: https://bd85.net/svn/cs3505_group@153 92bb83a3-7c8f-8a45-bc97-515c4e399668 --- diff --git a/CarFire/CarFire/CarFire/Game.cs b/CarFire/CarFire/CarFire/Game.cs index 7a1971c..1486e65 100644 --- a/CarFire/CarFire/CarFire/Game.cs +++ b/CarFire/CarFire/CarFire/Game.cs @@ -261,7 +261,8 @@ namespace CarFire public bool IsCellOpen(Point point) { if (!State.Map.IsCellOpen(point)) return false; - if (GetEntityAtCoordinates(point) != null) return false; + IEntity entity = GetEntityAtCoordinates(point); + if (entity != null && entity.IsCollidable) return false; return true; } diff --git a/CarFire/CarFire/CarFire/IEntity.cs b/CarFire/CarFire/CarFire/IEntity.cs index b812171..e916f2a 100644 --- a/CarFire/CarFire/CarFire/IEntity.cs +++ b/CarFire/CarFire/CarFire/IEntity.cs @@ -32,6 +32,11 @@ namespace CarFire /// The widget. void Draw(SpriteBatch spriteBatch); + /// + /// Get whether or not the entity is collidable. + /// + bool IsCollidable { get; } + /// /// Get the actual position. /// diff --git a/CarFire/CarFire/CarFire/Map.cs b/CarFire/CarFire/CarFire/Map.cs index bc3fbbf..0178e2b 100644 --- a/CarFire/CarFire/CarFire/Map.cs +++ b/CarFire/CarFire/CarFire/Map.cs @@ -134,7 +134,9 @@ namespace CarFire /// /// Get and set the tilemap with its associated texture and tile /// character to coordinate mappings. This effects what the map looks - /// like when it is drawn. + /// like when it is drawn. You will need to reset any map instances + /// after setting a new tilemap. You should also set a tilemap before + /// instantiating any maps. /// public static Tilemap Tilemap; diff --git a/CarFire/CarFire/CarFire/Player.cs b/CarFire/CarFire/CarFire/Player.cs index 02d6eec..9d6c6b4 100644 --- a/CarFire/CarFire/CarFire/Player.cs +++ b/CarFire/CarFire/CarFire/Player.cs @@ -33,6 +33,7 @@ namespace CarFire public Game Game { get { return game; } } public MovementManager Motion { get { return mMotion; } } public int PlayerIndex { get { return mPlayerIndex; } } + public bool IsCollidable { get { return true; } } public Vector2 Position { get { return mMotion.Position; } } public Point Coordinates { get { return mMotion.Coordinates; } set diff --git a/CarFire/CarFire/CarFire/SaberMonster.cs b/CarFire/CarFire/CarFire/SaberMonster.cs index 2d711a4..a3507c8 100644 --- a/CarFire/CarFire/CarFire/SaberMonster.cs +++ b/CarFire/CarFire/CarFire/SaberMonster.cs @@ -211,6 +211,8 @@ namespace CarFire this.health -= amount; } + public bool IsCollidable { get { return true; } } + /// /// Get the smoothed position. /// diff --git a/CarFire/CarFire/CarFire/Trigger.cs b/CarFire/CarFire/CarFire/Trigger.cs index 6d639d8..e405aa9 100644 --- a/CarFire/CarFire/CarFire/Trigger.cs +++ b/CarFire/CarFire/CarFire/Trigger.cs @@ -87,6 +87,11 @@ namespace CarFire // No implementation needed. } + public bool IsCollidable + { + get { return false; } + } + public Vector2 Position { get { return Vector2.Zero; } @@ -94,7 +99,7 @@ namespace CarFire public Point Coordinates { - get { return new Point(-1, -1); } + get { return mCoordinates; } } #endregion