Entities with collision components can now be solid to the pathfinder.

This commit is contained in:
Simon Holmberg
2012-10-30 22:02:22 +00:00
5 changed files with 222 additions and 204 deletions
@@ -19,6 +19,11 @@ namespace DepthsBelow.Component
/// </summary>
public Rectangle Rectangle;
/// <summary>
/// Whether the entity is solid to other entities.
/// </summary>
public bool Solid = false;
/// <summary>
/// Width of the collision rectangle.
/// </summary>
@@ -153,6 +153,18 @@ namespace DepthsBelow.Component
byte[,] mapCollisionMap = Core.Map.GetCollisionMap();
// Add solid collision component entities
foreach (var collision in EntityManager.GetComponents<Collision>())
{
if (collision.Solid && collision.Parent != this.Parent)
{
try
{
var pos = collision.Parent.Position;
mapCollisionMap[pos.X, pos.Y] = 0;
}
catch { }
}
}
if (appendCollisionMap != null)
foreach (var point in appendCollisionMap)
+2 -2
View File
@@ -171,7 +171,7 @@ namespace DepthsBelow
// TODO: OnClick events
// Tooltip stuff
var tooltip = core.Lua.GetObject<GUI.Frame>("ToolTip");
/*var tooltip = core.Lua.GetObject<GUI.Frame>("ToolTip");
if (tooltip != null)
{
tooltip.Visible = false;
@@ -189,7 +189,7 @@ namespace DepthsBelow
tooltip.X = ms.X + 10;
tooltip.Y = ms.Y + 15;
}
}
}*/
if (core.TurnManager.CurrentTurn == core.TurnManager["Player"])
{
+1
View File
@@ -46,6 +46,7 @@ namespace DepthsBelow
AddComponent(rc);
var cc = new Collision(this, 32, 32);
cc.Solid = true;
AddComponent(cc);
var pfc = new PathFinder(this);
+1 -1
View File
@@ -36,7 +36,7 @@ namespace DepthsBelow
}
public int MaxActionPoints = 10;
int actionPointsLeft = 0;
int actionPointsLeft = 10;
public int AP
{