From f694b0969c184ba156c82e38f6bc32f3b3c1267d Mon Sep 17 00:00:00 2001 From: Simon Holmberg Date: Sat, 29 Sep 2012 00:52:55 +0200 Subject: [PATCH] fixup! Merge branch 'master' into astar --- DepthsBelow/DepthsBelow/Core.cs | 6 +++--- DepthsBelow/DepthsBelow/Map.cs | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/DepthsBelow/DepthsBelow/Core.cs b/DepthsBelow/DepthsBelow/Core.cs index 257f514..0b4f558 100755 --- a/DepthsBelow/DepthsBelow/Core.cs +++ b/DepthsBelow/DepthsBelow/Core.cs @@ -68,8 +68,7 @@ namespace DepthsBelow spriteBatch = new SpriteBatch(GraphicsDevice); map = Content.Load("maps/Cave.Level1"); - map.ParseObjects(this); - + PathFinder = new AStar.PathFinderFast(map.GetCollisionMap()); PathFinder.Formula = AStar.HeuristicFormula.Manhattan; PathFinder.Diagonals = false; @@ -81,6 +80,8 @@ namespace DepthsBelow PathFinder.DebugProgress = false; PathFinder.DebugFoundPath = false; + map.ParseObjects(this); + // TODO: use this.Content to load your game content here Soldier.LoadContent(this); //soldier = new Soldier(this); @@ -139,7 +140,6 @@ namespace DepthsBelow foreach (var soldier in Squad) { var sr = soldier.GetComponent(); - Console.WriteLine("Drawing soldier at: " + soldier.pixelTransform.X + "," + soldier.pixelTransform.Y); if (sr != null) sr.Draw(spriteBatch); } diff --git a/DepthsBelow/DepthsBelow/Map.cs b/DepthsBelow/DepthsBelow/Map.cs index ca04e54..62ae2d4 100755 --- a/DepthsBelow/DepthsBelow/Map.cs +++ b/DepthsBelow/DepthsBelow/Map.cs @@ -126,13 +126,15 @@ namespace DepthsBelow byte[,] collisionMap = new byte[1024, 1024]; foreach (var layer in Layers) { - if (layer.Name == "Collision") + var tileLayer = layer as MapTileLayer; + + if (tileLayer.Name == "Collision") { - for (int y = 0; y < layer.Height; y++) + for (int y = 0; y < tileLayer.Height; y++) { - for (int x = 0; x < layer.Width; x++) + for (int x = 0; x < tileLayer.Width; x++) { - Tile tile = layer.Tiles[y*layer.Width + x]; + MapTile tile = tileLayer.Tiles[y * layer.Width + x]; if (tile == null || tile.LocalId == 0) collisionMap[x, y] = 1; else