X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=CarFire%2FCarFire%2FCarFire%2FGame.cs;h=56507110fac10ba1c10502be051f1cf11545dc1f;hb=122c062297acac44673e947b666c1d72cd23fb1b;hp=8b9b0759e9bacb46f6756aef25afe6e3075d41c9;hpb=f41d1413bdee1a69450ca6c2bca9932a4c61a6d9;p=chaz%2Fcarfire
diff --git a/CarFire/CarFire/CarFire/Game.cs b/CarFire/CarFire/CarFire/Game.cs
index 8b9b075..5650711 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,13 +274,53 @@ 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;
- if (GetEntityAtCoordinates(point) != null) return false;
+ IEntity entity = GetEntityAtCoordinates(point);
+ if (entity != null && entity.IsCollidable) return false;
+ Player player = GetPlayerAtCoordinates(point);
+ if (player != null) return false;
return true;
}
+ ///
+ /// 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;
+ }
+
+ ///
+ /// Move on to the next map, and advance the level.
+ ///
+ public void AdvanceLevel()
+ {
+ // TODO: Load the next map, etc...
+ }
+
+ ///
+ /// Restart the current level.
+ ///
+ public void Reset()
+ {
+ State.Map.Reset();
+ // TODO: Do other stuff to reset everything.
+ }
+
+
public Game()
{
@@ -333,47 +389,49 @@ namespace CarFire
State.mDisplay = new Display(this);
State.mDisplay.LoadContent(mContentManager);
+ // Load the tilemap.
Texture2D mapTiles = mContentManager.Load("graphics/wallAndFloorTilesNoEdgeScale");
Tilemap tilemap = new Tilemap(mapTiles, 10, 7);
- tilemap.SetTile(' ', new Point(4, 5));
- tilemap.SetTile('`', new Point(0, 1));
- tilemap.SetTile('~', new Point(1, 1));
- tilemap.SetTile('!', new Point(3, 1));
- tilemap.SetTile('@', new Point(4, 1));
- tilemap.SetTile('#', new Point(5, 1));
- tilemap.SetTile('$', new Point(6, 1));
- tilemap.SetTile('%', new Point(8, 1));
- tilemap.SetTile('^', new Point(9, 1));
- tilemap.SetTile('&', new Point(0, 2));
- tilemap.SetTile('=', new Point(1, 2));
- tilemap.SetTile('*', new Point(2, 2));
- tilemap.SetTile('(', new Point(4, 2));
- tilemap.SetTile(')', new Point(0, 3));
- tilemap.SetTile('_', new Point(2, 3));
- tilemap.SetTile('-', new Point(9, 3));
- tilemap.SetTile(',', new Point(1, 4));
- tilemap.SetTile('+', new Point(2, 4));
- tilemap.SetTile('[', new Point(3, 4));
- tilemap.SetTile(']', new Point(4, 4));
- tilemap.SetTile('{', new Point(5, 4));
- tilemap.SetTile('}', new Point(6, 4));
- tilemap.SetTile('\\', new Point(8, 4));
- tilemap.SetTile('|', new Point(9, 4));
- tilemap.SetTile(';', new Point(0, 5));
- tilemap.SetTile(':', new Point(1, 5));
- tilemap.SetTile('\'', new Point(2, 5));
- tilemap.SetTile('"', new Point(3, 5));
- tilemap.SetTile('.', new Point(5, 5));
- tilemap.SetTile('<', new Point(6, 5));
- tilemap.SetTile('>', new Point(7, 5));
- tilemap.SetTile('/', new Point(8, 5));
- tilemap.SetTile('?', new Point(9, 5));
-
- State.Map = mContentManager.Load