]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/Melee.cs
colosseum is now crowded with monsters; made the SaberMonster moving code more robust...
[chaz/carfire] / CarFire / CarFire / CarFire / Melee.cs
index f461aa69e8110b8b855e342a7638dcfc5c5badd8..f113824b4b250ba3119bebf2714a4f38dea65faa 100644 (file)
@@ -18,6 +18,8 @@ namespace CarFire
         int coolDown;\r
         Texture2D charModel;\r
         Texture2D projectileModel;\r
+        int velocityX;\r
+        int velocityY;\r
         #endregion \r
 \r
         #region Public Methods\r
@@ -51,9 +53,51 @@ namespace CarFire
                 coolDown--;\r
             else if (coolDown == 0)\r
             {\r
+                \r
                 if (keysPressed.Contains<Keys>(Keys.Space))\r
                 {\r
-                    \r
+                    coolDown = hitCoolDown;\r
+                    int startX = Coordinates.X;\r
+                    int startY = Coordinates.Y;\r
+                    if (Motion.Direction == Direction.Down || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.LowerRight)\r
+                    {\r
+                        startY = Coordinates.Y + 1;\r
+                    }\r
+                    else if (Motion.Direction == Direction.Up || Motion.Direction == Direction.UpperLeft || Motion.Direction == Direction.UpperRight)\r
+                    {\r
+                        startY = Coordinates.Y - 1;\r
+                    }\r
+                    if (Motion.Direction == Direction.Right || Motion.Direction == Direction.LowerRight || Motion.Direction == Direction.UpperRight)\r
+                    {\r
+                        startX = Coordinates.X + 1;\r
+                    }\r
+                    else if (Motion.Direction == Direction.Left || Motion.Direction == Direction.LowerLeft || Motion.Direction == Direction.UpperLeft)\r
+                    {\r
+                        startX = Coordinates.X - 1;\r
+                    }\r
+                    //Attack a monster\r
+                    if (!Game.IsCellOpen(new Point(startX, startY)))\r
+                    {\r
+                        IEntity toKill = Game.GetEntityAtCoordinates(new Point(startX, startY));\r
+                        //See if it is a monster\r
+                        if (toKill is IMonster)\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
             }\r
 \r
This page took 0.020943 seconds and 4 git commands to generate.