All Monsters now move

This commit is contained in:
Niklas Ulf Anders Cullberg
2012-10-28 22:48:06 +01:00
parent 5c59a2277b
commit 4a60e4e2d5
5 changed files with 492 additions and 458 deletions
+1 -1
View File
@@ -89,7 +89,7 @@ namespace DepthsBelow.Component
public int Penalty(int distance) public int Penalty(int distance)
{ {
return panic + GetPenalty(stepsTaken) + (int)(GetPenalty(distance) / 2); return panic/* + GetPenalty(stepsTaken)*/ + (int)(GetPenalty(distance));
} }
public Stat(Entity parent) public Stat(Entity parent)
+3 -3
View File
@@ -85,9 +85,9 @@ namespace DepthsBelow
/// <param name="gameTime"></param> /// <param name="gameTime"></param>
public void Update(GameTime gameTime) public void Update(GameTime gameTime)
{ {
foreach (var entity in Entities.ToList()) foreach (var entity in Entities.ToList())
entity.Update(gameTime); entity.Update(gameTime);
} }
/// <summary> /// <summary>
/// Draw all entities handled by the entity manager. /// Draw all entities handled by the entity manager.
+30 -7
View File
@@ -146,9 +146,32 @@ namespace DepthsBelow
if (core.TurnManager.CurrentTurn == core.TurnManager["Computer"]) if (core.TurnManager.CurrentTurn == core.TurnManager["Computer"])
{ {
foreach (var enemy in core.Swarm)
{
enemy.step = 0;
Point target = Point.Zero;
float distance = 7000;
foreach (var unit in core.Squad)
{
Vector2 soldier = new Vector2(unit.Transform.Grid.X, unit.Transform.Grid.Y);
Vector2 monster = new Vector2(enemy.Transform.Grid.X, enemy.Transform.Grid.Y);
float newDistance = Vector2.Distance(soldier, monster);
if (newDistance < distance)
{
target = unit.Transform.Grid;
distance = newDistance;
}
}
enemy.GetComponent<Component.PathFinder>().Goal = target;
distance = 7000;
}
core.TestMonster.step = 0; core.TestMonster.step = 0;
Point target = Point.Zero; Point testTarget = Point.Zero;
float distance = 7000; float testDistance = 7000;
foreach (var unit in core.Squad) foreach (var unit in core.Squad)
{ {
Vector2 soldier = new Vector2(unit.Transform.Grid.X, unit.Transform.Grid.Y); Vector2 soldier = new Vector2(unit.Transform.Grid.X, unit.Transform.Grid.Y);
@@ -156,14 +179,14 @@ namespace DepthsBelow
float newDistance = Vector2.Distance(soldier, monster); float newDistance = Vector2.Distance(soldier, monster);
if (newDistance < distance) if (newDistance < testDistance)
{ {
target = unit.Transform.Grid; testTarget = unit.Transform.Grid;
distance = newDistance; testDistance = newDistance;
} }
} }
core.TestMonster.GetComponent<Component.PathFinder>().Goal = target; core.TestMonster.GetComponent<Component.PathFinder>().Goal = testTarget;
distance = 7000; testDistance = 7000;
core.TurnManager.EndTurn(); core.TurnManager.EndTurn();
} }
+11
View File
@@ -69,6 +69,17 @@ namespace DepthsBelow
// HACK: Make this work properly with other speeds... // HACK: Make this work properly with other speeds...
float speed = 4f; float speed = 4f;
Transform.World.Position += speed * direction; Transform.World.Position += speed * direction;
foreach (var entity in entityManager.Entities)
{
if (entity is SmallEnemy)
{
if (this.GetComponent<Component.Collision>().Rectangle.Intersects(entity.GetComponent<Component.Collision>().Rectangle))
{
}
}
}
} }
} }
} }
+2 -2
View File
@@ -36,7 +36,7 @@ namespace DepthsBelow
//Console.WriteLine(chanceToHit); //Console.WriteLine(chanceToHit);
return chanceToHit; return chanceToHit;
} }
/*public static bool HitTest(Entity attacker, Entity defender, int chanceToHit) public static bool HitTest(Entity attacker, Entity defender, int chanceToHit)
{ {
Component.Stat shooting = attacker.GetComponent<Component.Stat>(); Component.Stat shooting = attacker.GetComponent<Component.Stat>();
Component.Stat dodging = defender.GetComponent<Component.Stat>(); Component.Stat dodging = defender.GetComponent<Component.Stat>();
@@ -47,7 +47,7 @@ namespace DepthsBelow
return true; return true;
} }
return false; return false;
}*/ }
private static Texture2D blank; private static Texture2D blank;
public static void DrawLine(SpriteBatch batch, Color color, float width, Vector2 start, Vector2 end) public static void DrawLine(SpriteBatch batch, Color color, float width, Vector2 start, Vector2 end)