]> Dogcows Code - chaz/carfire/commitdiff
Added a few member fariables and parameter to constructor
authorKyle <Kyle@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Mon, 19 Apr 2010 02:12:20 +0000 (02:12 +0000)
committerKyle <Kyle@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Mon, 19 Apr 2010 02:12:20 +0000 (02:12 +0000)
git-svn-id: https://bd85.net/svn/cs3505_group@100 92bb83a3-7c8f-8a45-bc97-515c4e399668

CarFire/CarFire/CarFire/Human.cs

index acb0d3b8cd92cca04d68ca30fe11027aecbc3e44..7a926a6cafc0c6936178cb61551e3946ec7b41fc 100644 (file)
@@ -11,13 +11,22 @@ namespace CarFire
 {\r
     public class Human : IPlayer\r
     {\r
+        public enum State\r
+        {\r
+            left,\r
+            right,\r
+            up,\r
+            down\r
+        };\r
         //Member Variables\r
+        State state;\r
         String CharName;\r
         Map theMap;\r
         int movementSpeed;\r
         int gridX;\r
         int gridY;\r
         Texture2D charModel;\r
+        Texture2D projectileModel;\r
         int health;\r
         int damage;\r
         int range;\r
@@ -26,21 +35,28 @@ namespace CarFire
         int pixelX;\r
         int pixelY;\r
         bool visible;\r
+        int movementCoolDown;\r
 \r
-        public Human(Map _theMap, String Name)\r
+        public Human(Map _theMap, String Name, Texture2D model)\r
         {\r
             theMap = _theMap;\r
             CharName = Name;\r
 \r
-            movementSpeed = 20; // randomly set now\r
+            movementSpeed = 12; // randomly set now\r
             health = 100;\r
             score = 0;\r
             visible = false;\r
+            //default state\r
+            state = State.up;\r
+            charModel = model;\r
+            movementCoolDown = movementSpeed;\r
         }\r
 \r
         public void LoadContent(ContentManager contentManager)\r
         {\r
             charModel = contentManager.Load<Texture2D>("deselectBox"); //change to charModel when designed\r
+            projectileModel = contentManager.Load<Texture2D>("emptySelectBox"); //change to a projectile model later\r
+\r
         }\r
 \r
         public void UnloadContent()\r
@@ -80,50 +96,71 @@ namespace CarFire
         /// <param name="keysPressed">A general list of keys that are pressed. Other keys can be included but only direction keys will be used</param>\r
         public void MovePlayer(List<Keys> keysPressed)\r
         {\r
-            // move upleft\r
-            keysPressed.Contains<Keys>(Keys.Left);\r
-            if (keysPressed.Contains<Keys>(Keys.Up) && keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY - 1))\r
-            {\r
-                gridX -= 1;\r
-                gridY -= 1;\r
-            }\r
-            // move upright\r
-            else if (keysPressed.Contains<Keys>(Keys.Up) && keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY - 1))\r
-            {\r
-                gridX += 1;\r
-                gridY -= 1;\r
-            }\r
-            // move downleft\r
-            else if (keysPressed.Contains<Keys>(Keys.Down) && keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY + 1))\r
-            {\r
-                gridX -= 1;\r
-                gridY += 1;\r
-            }\r
-            // move downright\r
-            else if (keysPressed.Contains<Keys>(Keys.Down) && keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY + 1))\r
-            {\r
-                gridX += 1;\r
-                gridY += 1;\r
-            }\r
-            // move up\r
-            else if (keysPressed.Contains<Keys>(Keys.Up) && theMap.IsCellOpen(gridX, gridY - 1))\r
-            {\r
-                gridY -= 1;\r
-            }\r
-            // move down\r
-            else if (keysPressed.Contains<Keys>(Keys.Down) && theMap.IsCellOpen(gridX, gridY + 1))\r
-            {\r
-                gridY += 1;\r
-            }\r
-            // move left\r
-            else if (keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY))\r
+            if(movementCoolDown > 0)\r
+                movementCoolDown--;\r
+            else if (movementCoolDown == 0)\r
             {\r
-                gridX -= 1;\r
+                // move upleft\r
+                keysPressed.Contains<Keys>(Keys.Left);\r
+                if (keysPressed.Contains<Keys>(Keys.Up) && keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY - 1))\r
+                {\r
+                    gridX -= 1;\r
+                    gridY -= 1;\r
+                    movementCoolDown = movementSpeed;\r
+                }\r
+                // move upright\r
+                else if (keysPressed.Contains<Keys>(Keys.Up) && keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY - 1))\r
+                {\r
+                    gridX += 1;\r
+                    gridY -= 1;\r
+                    movementCoolDown = movementSpeed;\r
+                }\r
+                // move downleft\r
+                else if (keysPressed.Contains<Keys>(Keys.Down) && keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY + 1))\r
+                {\r
+                    gridX -= 1;\r
+                    gridY += 1;\r
+                    movementCoolDown = movementSpeed;\r
+                }\r
+                // move downright\r
+                else if (keysPressed.Contains<Keys>(Keys.Down) && keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY + 1))\r
+                {\r
+                    gridX += 1;\r
+                    gridY += 1;\r
+                    movementCoolDown = movementSpeed;\r
+                }\r
+                // move up\r
+                else if (keysPressed.Contains<Keys>(Keys.Up) && theMap.IsCellOpen(gridX, gridY - 1))\r
+                {\r
+                    gridY -= 1;\r
+                    movementCoolDown = movementSpeed;\r
+                }\r
+                // move down\r
+                else if (keysPressed.Contains<Keys>(Keys.Down) && theMap.IsCellOpen(gridX, gridY + 1))\r
+                {\r
+                    gridY += 1;\r
+                    movementCoolDown = movementSpeed;\r
+                }\r
+                // move left\r
+                else if (keysPressed.Contains<Keys>(Keys.Left) && theMap.IsCellOpen(gridX - 1, gridY))\r
+                {\r
+                    gridX -= 1;\r
+                    movementCoolDown = movementSpeed;\r
+                }\r
+                // move right\r
+                else if (keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY))\r
+                {\r
+                    gridX += 1;\r
+                    movementCoolDown = movementSpeed;\r
+                }\r
             }\r
-            // move right\r
-            else if (keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY))\r
+            if (keysPressed.Contains<Keys>(Keys.Space))\r
             {\r
-                gridX += 1;\r
+                //TODO spawn projectile... needs to be added to display though\r
+                if (state == State.up)\r
+                {\r
+                    \r
+                }\r
             }\r
         }\r
 \r
This page took 0.026058 seconds and 4 git commands to generate.