Enemies die when shot, also, rockets with R

This commit is contained in:
Niklas Ulf Anders Cullberg
2012-10-29 00:56:25 +01:00
parent 9a0ff658b4
commit 236d6c2859
4 changed files with 11 additions and 6 deletions
+6 -2
View File
@@ -205,13 +205,17 @@ namespace DepthsBelow
{
}
if (ks.IsKeyDown(Keys.S))
if (ks.IsKeyDown(Keys.S) || ks.IsKeyDown(Keys.R))
{
foreach (var soldier in core.Squad)
{
if (soldier.Selected == true && soldier.Fired == false)
{
core.Volley.Add(new Shot(core.EntityManager, soldier.GetComponent<Component.Stat>(), "Bullet"));
if (ks.IsKeyDown(Keys.S)) {
core.Volley.Add(new Shot(core.EntityManager, soldier.GetComponent<Component.Stat>(), "Bullet"));
} else if (ks.IsKeyDown(Keys.R)) {
core.Volley.Add(new Shot(core.EntityManager, soldier.GetComponent<Component.Stat>(), "Rocket"));
}
soldier.Fired = true;
foreach (var shot in core.Volley)
{
+3 -2
View File
@@ -41,13 +41,14 @@ namespace DepthsBelow
public Shot(EntityManager entityManager, Stat _soldierStat, string _type)
: base(entityManager)
{
type = _type;
if (Texture == null)
LoadContent();
Transform.World.Origin = new Vector2(16, 16);
Stat = _soldierStat;
type = _type;
this.Color = Color.White;
var rc = new SpriteRenderer(this) { Texture = Texture, Color = Color.White };
@@ -85,7 +86,7 @@ namespace DepthsBelow
{
if (this.GetComponent<Component.Collision>().Rectangle.Intersects(entity.GetComponent<Component.Collision>().Rectangle))
{
if (Utility.HitTest(Stat, entity, Utility.CalculateHitChance(Stat, this.Stat.Remember, entity)))
if (Utility.AttackTest(Stat, entity, Utility.CalculateHitChance(Stat, this.Stat.Remember, entity)))
{
this.Remove();
return;
+1 -1
View File
@@ -146,7 +146,7 @@ namespace DepthsBelow
{
if (entity.GetComponent<Component.Collision>().Rectangle.Intersects(this.GetComponent<Component.Collision>().Rectangle))
{
if (Utility.HitTest(this.GetComponent<Component.Stat>(), entity, Utility.CalculateHitChance(this.GetComponent<Component.Stat>(), this.Transform.World.Position, entity)))
if (Utility.AttackTest(this.GetComponent<Component.Stat>(), entity, Utility.CalculateHitChance(this.GetComponent<Component.Stat>(), this.Transform.World.Position, entity)))
{
return;
}
+1 -1
View File
@@ -36,7 +36,7 @@ namespace DepthsBelow
//Console.WriteLine(chanceToHit);
return chanceToHit;
}
public static bool HitTest(Stat attacker, Entity defender, int chanceToHit)
public static bool AttackTest(Stat attacker, Entity defender, int chanceToHit)
{
Component.Stat shooting = attacker;
Component.Stat dodging = defender.GetComponent<Component.Stat>();