Some maintenance
This commit is contained in:
@@ -19,11 +19,9 @@ namespace DepthsBelow
|
|||||||
GraphicsDeviceManager graphics;
|
GraphicsDeviceManager graphics;
|
||||||
SpriteBatch spriteBatch;
|
SpriteBatch spriteBatch;
|
||||||
|
|
||||||
public static AStar.PathFinderFast PathFinder;
|
|
||||||
public Camera Camera;
|
public Camera Camera;
|
||||||
|
|
||||||
MouseInput mouseInput;
|
public static MouseInput MouseInput;
|
||||||
//public Soldier soldier;
|
|
||||||
public List<Soldier> Squad;
|
public List<Soldier> Squad;
|
||||||
public static Map Map;
|
public static Map Map;
|
||||||
|
|
||||||
@@ -68,26 +66,14 @@ namespace DepthsBelow
|
|||||||
spriteBatch = new SpriteBatch(GraphicsDevice);
|
spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||||
|
|
||||||
Map = Content.Load<Map>("maps/Cave.Level1");
|
Map = Content.Load<Map>("maps/Cave.Level1");
|
||||||
|
// Load map objects
|
||||||
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;
|
|
||||||
|
|
||||||
Map.ParseObjects(this);
|
Map.ParseObjects(this);
|
||||||
|
|
||||||
// TODO: use this.Content to load your game content here
|
// TODO: use this.Content to load your game content here
|
||||||
Soldier.LoadContent(this);
|
Soldier.LoadContent(this);
|
||||||
//soldier = new Soldier(this);
|
|
||||||
|
|
||||||
mouseInput = new MouseInput(this);
|
MouseInput = new MouseInput(this);
|
||||||
mouseInput.LoadContent();
|
MouseInput.LoadContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -111,10 +97,9 @@ namespace DepthsBelow
|
|||||||
this.Exit();
|
this.Exit();
|
||||||
|
|
||||||
Camera.Update(gameTime);
|
Camera.Update(gameTime);
|
||||||
mouseInput.Update(gameTime);
|
MouseInput.Update(gameTime);
|
||||||
|
|
||||||
// TODO: Add your update logic here
|
// Update soldiers in squad
|
||||||
//soldier.Update(gameTime);
|
|
||||||
foreach (var soldier in Squad)
|
foreach (var soldier in Squad)
|
||||||
soldier.Update(gameTime);
|
soldier.Update(gameTime);
|
||||||
|
|
||||||
@@ -135,8 +120,8 @@ namespace DepthsBelow
|
|||||||
|
|
||||||
// Draw the level
|
// Draw the level
|
||||||
Map.Draw(spriteBatch);
|
Map.Draw(spriteBatch);
|
||||||
|
|
||||||
// Draw units
|
// Draw units
|
||||||
// TODO: Foreach etc...
|
|
||||||
foreach (var soldier in Squad)
|
foreach (var soldier in Squad)
|
||||||
{
|
{
|
||||||
var sr = soldier.GetComponent<Component.SpriteRenderer>();
|
var sr = soldier.GetComponent<Component.SpriteRenderer>();
|
||||||
@@ -144,8 +129,8 @@ namespace DepthsBelow
|
|||||||
sr.Draw(spriteBatch);
|
sr.Draw(spriteBatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw mouse input visuals
|
// Draw mouse input visuals
|
||||||
mouseInput.Draw(spriteBatch);
|
MouseInput.Draw(spriteBatch);
|
||||||
|
|
||||||
spriteBatch.End();
|
spriteBatch.End();
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
|
||||||
@@ -121,13 +122,15 @@ namespace DepthsBelow
|
|||||||
|
|
||||||
public byte[,] GetCollisionMap()
|
public byte[,] GetCollisionMap()
|
||||||
{
|
{
|
||||||
byte[,] collisionMap = new byte[1024, 1024];
|
byte[,] collisionMap = null;
|
||||||
|
|
||||||
foreach (var layer in Layers)
|
foreach (var layer in Layers)
|
||||||
{
|
{
|
||||||
var tileLayer = layer as MapTileLayer;
|
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 y = 0; y < tileLayer.Height; y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < tileLayer.Width; x++)
|
for (int x = 0; x < tileLayer.Width; x++)
|
||||||
@@ -144,8 +147,8 @@ namespace DepthsBelow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (collisionMap == null)
|
if (collisionMap == null)
|
||||||
// throw new Exception("Map lacks a Collision layer!");
|
Debug.WriteLine("Map lacks a Collision layer! Pathfinding won't work.");
|
||||||
|
|
||||||
return collisionMap;
|
return collisionMap;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ using Microsoft.Xna.Framework.Media;
|
|||||||
|
|
||||||
namespace DepthsBelow
|
namespace DepthsBelow
|
||||||
{
|
{
|
||||||
class MouseInput
|
public class MouseInput
|
||||||
{
|
{
|
||||||
Core core;
|
Core core;
|
||||||
MouseState lastMouseState;
|
MouseState lastMouseState;
|
||||||
|
|||||||
Reference in New Issue
Block a user