]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/Melee.cs
Scoring implemented, melee attack implemented.
[chaz/carfire] / CarFire / CarFire / CarFire / Melee.cs
index f52301219c667184ef107a0d4f1e3cc366329288..38be3038a5ae2e231affcf3ac3b9a29890173a65 100644 (file)
@@ -59,33 +59,41 @@ namespace CarFire
                     int startY = Coordinates.Y;\r
                     if (Motion.Direction == Direction.Down || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.LowerRight)\r
                     {\r
-                        velocityY = 1;\r
                         startY = Coordinates.Y + 1;\r
                     }\r
                     else if (Motion.Direction == Direction.Up || Motion.Direction == Direction.UpperLeft || Motion.Direction == Direction.UpperRight)\r
                     {\r
-                        velocityY = -1;\r
                         startY = Coordinates.Y - 1;\r
                     }\r
                     if (Motion.Direction == Direction.Right || Motion.Direction == Direction.LowerRight || Motion.Direction == Direction.UpperRight)\r
                     {\r
-                        velocityX = 1;\r
                         startX = Coordinates.X + 1;\r
                     }\r
                     else if (Motion.Direction == Direction.Left || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.UpperLeft)\r
                     {\r
-                        velocityX = -1;\r
                         startX = Coordinates.X - 1;\r
                     }\r
                     //Attack a monster\r
                     if (!Game.IsCellOpen(new Point(startX, startY)))\r
                     {\r
-                        foreach (IEntity entity in Game.State.Entities)\r
+                        IEntity toKill = Game.GetEntityAtCoordinates(new Point(startX, startY));\r
+                        //See if it is a monster\r
+                        if (toKill is IMonster)\r
                         {\r
-                            //See if it is a monster\r
-\r
-                            //Damage the monster\r
-\r
+                            IMonster hitMonster = (IMonster)toKill;\r
+                            hitMonster.causeDamageTo(this.Damage);\r
+                            if (hitMonster.Health > 0)\r
+                            {\r
+                                this.Score += Game.State.HitMonsterScore;\r
+                                Console.WriteLine(this.Score);\r
+                            }\r
+                            else\r
+                            {\r
+                                this.Score += Game.State.KillMonsterScore;\r
+                                Console.WriteLine(this.Score);\r
+                                //Remove dead monsters\r
+                                Game.State.Entities.Remove(toKill);\r
+                            }\r
                         }\r
                     }\r
                 }\r
This page took 0.019447 seconds and 4 git commands to generate.