]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/Melee.cs
git-svn-id: https://bd85.net/svn/cs3505_group@163 92bb83a3-7c8f-8a45-bc97-515c4e399668
[chaz/carfire] / CarFire / CarFire / CarFire / Melee.cs
index 4c053a6a8c26a7efd14b9786ed5bb56594a12334..cb25ac81514530f916b051bb7125892163575eb2 100644 (file)
@@ -18,8 +18,13 @@ namespace CarFire
         int coolDown;\r
         Texture2D charModel;\r
         Texture2D projectileModel;\r
+        int velocityX;\r
+        int velocityY;\r
         #endregion \r
 \r
+        //zac variable\r
+        AnimateMelee animateMelee;\r
+\r
         #region Public Methods\r
         public Melee(Game theGame, String Name, Point position, int playerIndex)\r
             : base(theGame, Name, position, playerIndex, baseHealth, baseDamage)\r
@@ -34,6 +39,10 @@ namespace CarFire
             charModel = contentManager.Load<Texture2D>("cs"); //change to charModel when designed\r
             projectileModel = contentManager.Load<Texture2D>("projectile"); //change to a projectile model later\r
 \r
+            /*Zac\r
+             */\r
+            animateMelee = new AnimateMelee(contentManager); \r
+\r
         }\r
         /// <summary>\r
         /// This method will draw a character to the screen.\r
@@ -42,7 +51,9 @@ namespace CarFire
         public override void Draw(SpriteBatch spriteBatch)\r
         {\r
             Rectangle position = Game.State.Map.GetRectangleFromCoordinates(Motion.Position);\r
-            spriteBatch.Draw(charModel, position, Color.White);\r
+            //spriteBatch.Draw(charModel, position, Color.White);\r
+            animateMelee.AttackLeft(spriteBatch);\r
+            \r
         }\r
 \r
         public override void Attack(List<Keys> keysPressed)\r
@@ -51,39 +62,49 @@ namespace CarFire
                 coolDown--;\r
             else if (coolDown == 0)\r
             {\r
+                \r
                 if (keysPressed.Contains<Keys>(Keys.Space))\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
-                        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.019505 seconds and 4 git commands to generate.