]> Dogcows Code - chaz/carfire/commitdiff
Began basic interface for Character, Player and Monster, Began Human Class
authorbrady <brady@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Thu, 15 Apr 2010 04:42:53 +0000 (04:42 +0000)
committerbrady <brady@92bb83a3-7c8f-8a45-bc97-515c4e399668>
Thu, 15 Apr 2010 04:42:53 +0000 (04:42 +0000)
git-svn-id: https://bd85.net/svn/cs3505_group@86 92bb83a3-7c8f-8a45-bc97-515c4e399668

CarFire/CarFire/CarFire/Human.cs [new file with mode: 0644]
CarFire/CarFire/CarFire/IPlayer.cs [new file with mode: 0644]

diff --git a/CarFire/CarFire/CarFire/Human.cs b/CarFire/CarFire/CarFire/Human.cs
new file mode 100644 (file)
index 0000000..e0f6cc5
--- /dev/null
@@ -0,0 +1,142 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using Microsoft.Xna.Framework;\r
+using Microsoft.Xna.Framework.Content;\r
+using Microsoft.Xna.Framework.Graphics;\r
+using Microsoft.Xna.Framework.Input;\r
+\r
+namespace CarFire\r
+{\r
+    public class Human : IPlayer\r
+    {\r
+        //Member Variables\r
+        String CharName;\r
+        Map theMap;\r
+        int movementSpeed;\r
+        int gridX;\r
+        int gridY;\r
+        Texture2D charModel;\r
+        int health;\r
+        int damage;\r
+        int range;\r
+        int score;\r
+        bool isMoving;\r
+        int pixelX;\r
+        int pixelY;\r
+        bool visible;\r
+\r
+        public Human(Map _theMap, String Name)\r
+        {\r
+            theMap = _theMap;\r
+            CharName = Name;\r
+\r
+            movementSpeed = 20; // randomly set now\r
+            health = 100;\r
+            score = 0;\r
+            visible = false;\r
+        }\r
+\r
+        public void LoadContent(ContentManager contentManager, GraphicsDeviceManager graphics)\r
+        {\r
+            charModel = contentManager.Load<Texture2D>("deselectBox"); //change to charModel when designed\r
+        }\r
+\r
+        public void UnloadContent()\r
+        {\r
+\r
+        }\r
+\r
+        public long Update(GameTime gameTime, NetworkManager networkGame)\r
+        {\r
+            return 0;\r
+\r
+        }\r
+\r
+        public long Draw(SpriteBatch spriteBatch)\r
+        {\r
+            return 0;\r
+        }\r
+\r
+        public int Health { get { return health; } }\r
+        public int Score { get { return score; } }\r
+        public bool alive { get { return health > 0; } }\r
+\r
+        public void causeDamageTo(int amount)\r
+        {\r
+            health -= amount;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Moves the current player being controlled based on a given set of key presses.\r
+        /// The player can only move one grid space per movePlayer call. Thus this method\r
+        /// is made to be called ever update. The player will only move if the grid space\r
+        /// that is being moved to is an open space.\r
+        /// </summary>\r
+        /// <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
+            {\r
+                gridX -= 1;\r
+            }\r
+            // move right\r
+            else if (keysPressed.Contains<Keys>(Keys.Right) && theMap.IsCellOpen(gridX + 1, gridY))\r
+            {\r
+                gridX += 1;\r
+            }\r
+        }\r
+\r
+\r
+        public void powerUp(int amount)\r
+        {\r
+            health += amount;\r
+        }\r
+\r
+        public void Spawn(Point mapPoint)\r
+        {\r
+            gridX = mapPoint.X;\r
+            gridY = mapPoint.Y;\r
+            visible = true;\r
+        }\r
+\r
+\r
+    }\r
+}
\ No newline at end of file
diff --git a/CarFire/CarFire/CarFire/IPlayer.cs b/CarFire/CarFire/CarFire/IPlayer.cs
new file mode 100644 (file)
index 0000000..7eb7611
--- /dev/null
@@ -0,0 +1,35 @@
+using System;\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+using Microsoft.Xna.Framework;\r
+using Microsoft.Xna.Framework.Content;\r
+using Microsoft.Xna.Framework.Graphics;\r
+using Microsoft.Xna.Framework.Input;\r
+\r
+namespace CarFire\r
+{\r
+    public interface ICharacter\r
+    {\r
+        void LoadContent(ContentManager contentManager, GraphicsDeviceManager graphics);\r
+        void UnloadContent();\r
+        long Update(GameTime gameTime, NetworkManager networkGame);\r
+        long Draw(SpriteBatch spriteBatch);\r
+        int Health { get; }\r
+        void causeDamageTo(int amount);\r
+    }\r
+\r
+    public interface IPlayer : ICharacter\r
+    {\r
+        void MovePlayer(List<Keys> keysPressed);\r
+        int Score { get; }\r
+        void powerUp(int amount);\r
+        void Spawn(Point mapPoint);\r
+        bool alive { get; }\r
+    }\r
+\r
+    public interface IMonster : ICharacter\r
+    {\r
+        bool visible { get; }\r
+    }\r
+}\r
This page took 0.032431 seconds and 4 git commands to generate.