X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fcarfire;a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FGame.cs;h=63ed26deed977cd5993c8844496f1f26dfac6852;hp=1486e6572a66eb31db5b6413620342eb58efe85b;hb=9fc306c489b446612f0fc1b363e490a5ff217d2c;hpb=60d05271b295d2ca94a0028059add525c1bbffb1
diff --git a/CarFire/CarFire/CarFire/Game.cs b/CarFire/CarFire/CarFire/Game.cs
index 1486e65..63ed26d 100644
--- a/CarFire/CarFire/CarFire/Game.cs
+++ b/CarFire/CarFire/CarFire/Game.cs
@@ -225,11 +225,17 @@ namespace CarFire
{
get
{
- bool[,] grid = State.Map.Grid;
+ bool[,] grid = (bool[,])State.Map.Grid.Clone();
foreach (IEntity entity in State.Entities)
{
Point coordinates = entity.Coordinates;
- if (State.Map.IsCellOpen(coordinates)) grid[coordinates.X, coordinates.Y] = false;
+ grid[coordinates.X, coordinates.Y] = false;
+ }
+ foreach (Player player in State.mCharacters)
+ {
+ if (player == null) continue;
+ Point coordinates = player.Coordinates;
+ grid[coordinates.X, coordinates.Y] = false;
}
return grid;
}
@@ -240,6 +246,11 @@ namespace CarFire
#region Public Methods
+ ///
+ /// Get an entity at a certain place on the map.
+ ///
+ /// The coordinates.
+ /// The entity, or null if none is at that location.
public IEntity GetEntityAtCoordinates(Point point)
{
foreach (IEntity entity in State.Entities)
@@ -249,6 +260,11 @@ namespace CarFire
return null;
}
+ ///
+ /// Get a player at a certain place on the map.
+ ///
+ /// The coordinates.
+ /// The player, or null if none is at that location.
public Player GetPlayerAtCoordinates(Point point)
{
foreach (Player player in State.mCharacters)
@@ -258,33 +274,66 @@ namespace CarFire
return null;
}
+ ///
+ /// Determine if a cell is open, depending on the static scenery
+ /// of the map and if there are any collidable entities.
+ ///
+ /// The coordinates.
+ /// True if the cell is open; false otherwise.
public bool IsCellOpen(Point point)
{
if (!State.Map.IsCellOpen(point)) return false;
IEntity entity = GetEntityAtCoordinates(point);
if (entity != null && entity.IsCollidable) return false;
+ Player player = GetPlayerAtCoordinates(point);
+ if (player != null) return false;
return true;
}
- public Game()
+ ///
+ /// Remove a specific entity from the game. The entity can still
+ /// be tracked some other way, but it won't included when the game is
+ /// updating and drawing stuff.
+ ///
+ /// The entity.
+ /// The entity that was removed, or null if no entity was removed.
+ public IEntity RemoveEntity(IEntity entity)
{
-
+ if (State.Entities.Remove(entity)) return entity;
+ return null;
}
+
///
- /// This method should be called whenever the players want to move to a new map.
- /// Not implemented yet. Need some way to get next map.
+ /// Move on to the next map, and advance the level.
///
- public void startNewMap()
+ public void AdvanceLevel()
{
+ // TODO: Load the next map, etc...
//TODO somehow get next map
State.Entities.Clear();
- //State.Map = State.Map.getNextMap();
+ String nextMap = State.Map.Next;
+ State.Map = mContentManager.Load