diff --git a/DepthsBelow/DepthsBelow/Core.cs b/DepthsBelow/DepthsBelow/Core.cs index 4773f88..415469c 100755 --- a/DepthsBelow/DepthsBelow/Core.cs +++ b/DepthsBelow/DepthsBelow/Core.cs @@ -19,11 +19,9 @@ namespace DepthsBelow GraphicsDeviceManager graphics; SpriteBatch spriteBatch; - public static AStar.PathFinderFast PathFinder; public Camera Camera; - MouseInput mouseInput; - //public Soldier soldier; + public static MouseInput MouseInput; public List Squad; public static Map Map; @@ -68,26 +66,14 @@ namespace DepthsBelow spriteBatch = new SpriteBatch(GraphicsDevice); Map = Content.Load("maps/Cave.Level1"); - - PathFinder = new AStar.PathFinderFast(Map.GetCollisionMap()); - PathFinder.Formula = AStar.HeuristicFormula.Manhattan; - PathFinder.Diagonals = false; - PathFinder.HeavyDiagonals = false; - PathFinder.HeuristicEstimate = 2; - PathFinder.PunishChangeDirection = true; - PathFinder.TieBreaker = false; - PathFinder.SearchLimit = 50000; - PathFinder.DebugProgress = false; - PathFinder.DebugFoundPath = false; - + // Load map objects Map.ParseObjects(this); // TODO: use this.Content to load your game content here Soldier.LoadContent(this); - //soldier = new Soldier(this); - mouseInput = new MouseInput(this); - mouseInput.LoadContent(); + MouseInput = new MouseInput(this); + MouseInput.LoadContent(); } /// @@ -111,10 +97,9 @@ namespace DepthsBelow this.Exit(); Camera.Update(gameTime); - mouseInput.Update(gameTime); + MouseInput.Update(gameTime); - // TODO: Add your update logic here - //soldier.Update(gameTime); + // Update soldiers in squad foreach (var soldier in Squad) soldier.Update(gameTime); @@ -135,8 +120,8 @@ namespace DepthsBelow // Draw the level Map.Draw(spriteBatch); + // Draw units - // TODO: Foreach etc... foreach (var soldier in Squad) { var sr = soldier.GetComponent(); @@ -144,8 +129,8 @@ namespace DepthsBelow sr.Draw(spriteBatch); } - // Draw mouse input visuals - mouseInput.Draw(spriteBatch); + // Draw mouse input visuals + MouseInput.Draw(spriteBatch); spriteBatch.End(); diff --git a/DepthsBelow/DepthsBelow/Map.cs b/DepthsBelow/DepthsBelow/Map.cs index 1103769..d410a77 100755 --- a/DepthsBelow/DepthsBelow/Map.cs +++ b/DepthsBelow/DepthsBelow/Map.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -121,13 +122,15 @@ namespace DepthsBelow public byte[,] GetCollisionMap() { - byte[,] collisionMap = new byte[1024, 1024]; + byte[,] collisionMap = null; + foreach (var layer in Layers) { var tileLayer = layer as MapTileLayer; - if (tileLayer.Name == "Collision") + if (tileLayer != null && tileLayer.Name == "Collision") { + collisionMap = new byte[1024,1024]; for (int y = 0; y < tileLayer.Height; y++) { for (int x = 0; x < tileLayer.Width; x++) @@ -144,8 +147,8 @@ namespace DepthsBelow } } - //if (collisionMap == null) - // throw new Exception("Map lacks a Collision layer!"); + if (collisionMap == null) + Debug.WriteLine("Map lacks a Collision layer! Pathfinding won't work."); return collisionMap; } diff --git a/DepthsBelow/DepthsBelow/MouseInput.cs b/DepthsBelow/DepthsBelow/MouseInput.cs index db5ef78..b57cb28 100755 --- a/DepthsBelow/DepthsBelow/MouseInput.cs +++ b/DepthsBelow/DepthsBelow/MouseInput.cs @@ -10,7 +10,7 @@ using Microsoft.Xna.Framework.Media; namespace DepthsBelow { - class MouseInput + public class MouseInput { Core core; MouseState lastMouseState;