From 236d6c285944f21ff6183418370e1e10fc699563 Mon Sep 17 00:00:00 2001 From: Niklas Ulf Anders Cullberg Date: Mon, 29 Oct 2012 00:56:25 +0100 Subject: [PATCH] Enemies die when shot, also, rockets with R --- DepthsBelow/DepthsBelow/KeyboardInput.cs | 8 ++++++-- DepthsBelow/DepthsBelow/Shot.cs | 5 +++-- DepthsBelow/DepthsBelow/SmallEnemy.cs | 2 +- DepthsBelow/DepthsBelow/Utility.cs | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/DepthsBelow/DepthsBelow/KeyboardInput.cs b/DepthsBelow/DepthsBelow/KeyboardInput.cs index 8336949..c0ca262 100755 --- a/DepthsBelow/DepthsBelow/KeyboardInput.cs +++ b/DepthsBelow/DepthsBelow/KeyboardInput.cs @@ -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(), "Bullet")); + if (ks.IsKeyDown(Keys.S)) { + core.Volley.Add(new Shot(core.EntityManager, soldier.GetComponent(), "Bullet")); + } else if (ks.IsKeyDown(Keys.R)) { + core.Volley.Add(new Shot(core.EntityManager, soldier.GetComponent(), "Rocket")); + } soldier.Fired = true; foreach (var shot in core.Volley) { diff --git a/DepthsBelow/DepthsBelow/Shot.cs b/DepthsBelow/DepthsBelow/Shot.cs index ec7fe35..02adb7b 100755 --- a/DepthsBelow/DepthsBelow/Shot.cs +++ b/DepthsBelow/DepthsBelow/Shot.cs @@ -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().Rectangle.Intersects(entity.GetComponent().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; diff --git a/DepthsBelow/DepthsBelow/SmallEnemy.cs b/DepthsBelow/DepthsBelow/SmallEnemy.cs index ce8badc..1c95b0e 100755 --- a/DepthsBelow/DepthsBelow/SmallEnemy.cs +++ b/DepthsBelow/DepthsBelow/SmallEnemy.cs @@ -146,7 +146,7 @@ namespace DepthsBelow { if (entity.GetComponent().Rectangle.Intersects(this.GetComponent().Rectangle)) { - if (Utility.HitTest(this.GetComponent(), entity, Utility.CalculateHitChance(this.GetComponent(), this.Transform.World.Position, entity))) + if (Utility.AttackTest(this.GetComponent(), entity, Utility.CalculateHitChance(this.GetComponent(), this.Transform.World.Position, entity))) { return; } diff --git a/DepthsBelow/DepthsBelow/Utility.cs b/DepthsBelow/DepthsBelow/Utility.cs index 9529daa..faed897 100755 --- a/DepthsBelow/DepthsBelow/Utility.cs +++ b/DepthsBelow/DepthsBelow/Utility.cs @@ -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();