]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/Player.cs
colosseum is now crowded with monsters; made the SaberMonster moving code more robust...
[chaz/carfire] / CarFire / CarFire / CarFire / Player.cs
index f1d121c1907a0395ddeb2cab037a5b202bf4ad3f..e89b28473e1143abdaf37fc453f181f2042d7a03 100644 (file)
@@ -10,10 +10,11 @@ using Microsoft.Xna.Framework.Input;
 \r
 namespace CarFire\r
 {\r
-    public class Player : ICharacter\r
+    public abstract class Player : ICharacter\r
     {\r
         #region Member variables\r
         //The number of frames between each projectile is spawned.\r
+        const float basePlayerSpeed = 4.0f;\r
         const int shootCoolDown = 18;\r
         String CharName;\r
         Game game;\r
@@ -21,10 +22,31 @@ namespace CarFire
         int playerDamage;\r
         int score;\r
         MovementManager mMotion;\r
+        List<IEntity> mInventory = new List<IEntity>(4);\r
         int mPlayerIndex;\r
         #endregion\r
 \r
+        #region Public Properties\r
+        public int Health { get { return playerHealth; } set{playerHealth = value;} }\r
+        public int Score { get { return score; } set { score = value; } }\r
+        public bool alive { get { return playerHealth > 0; } }\r
+        public Game Game { get { return game; } }\r
+        public MovementManager Motion { get { return mMotion; } }\r
+        public int PlayerIndex { get { return mPlayerIndex; } }\r
+        public bool IsCollidable { get { return true; } }\r
+        public Vector2 Position { get { return mMotion.Position; } }\r
+        public Point Coordinates { get { return mMotion.Coordinates; }\r
+            set\r
+            {\r
+                Coordinates = value;\r
+                mMotion = new MovementManager(value, basePlayerSpeed);\r
+            } }\r
+        public char Identifier { get { return mPlayerIndex.ToString()[0]; } }\r
+        public int Damage { get { return playerDamage; } set { playerDamage = value; } }\r
+        public List<IEntity> Inventory { get { return mInventory; } }\r
+        #endregion\r
 \r
+        #region Public Methods\r
         public Player(Game theGame, String Name, Point position, int playerIndex, int health, int damage)\r
         {\r
             game = theGame;\r
@@ -35,31 +57,8 @@ namespace CarFire
             mPlayerIndex = playerIndex;\r
 \r
             // Speed is the number of grid cells you can move through per second.\r
-            mMotion = new MovementManager(position, 4.0f);\r
-        }\r
-\r
-        public virtual void LoadContent(ContentManager contentManager)\r
-        {\r
-\r
+            mMotion = new MovementManager(position, 25.0f);\r
         }\r
-        /// <summary>\r
-        /// This method will draw a character to the screen.\r
-        /// </summary>\r
-        /// <param name="spriteBatch"></param>\r
-        public virtual void Draw(SpriteBatch spriteBatch)\r
-        {\r
-        }\r
-\r
-        public int Health { get { return playerHealth; } }\r
-        public int Score { get { return score; } }\r
-        public bool alive { get { return playerHealth > 0; } }\r
-        public Game Game { get { return game; } }\r
-        public MovementManager Motion { get { return mMotion; } }\r
-        public int PlayerIndex { get { return mPlayerIndex; } }\r
-        public Vector2 Position { get { return mMotion.Position; } }\r
-        public Point Coordinates { get { return mMotion.Coordinates; } }\r
-        public int Damage { get { return playerDamage; } }\r
-\r
         public void causeDamageTo(int amount)\r
         {\r
             playerHealth -= amount;\r
@@ -89,27 +88,25 @@ namespace CarFire
             bool moveRight = keysPressed.Contains(Keys.Right);\r
             bool moveUp = keysPressed.Contains(Keys.Up);\r
             bool moveDown = keysPressed.Contains(Keys.Down);\r
-            Point destination = MovementManager.GetNeighborCell(mMotion.Coordinates, moveLeft, moveRight, moveUp, moveDown);\r
-            if (!keysPressed.Contains(Keys.LeftControl))\r
+\r
+            List<Point> possibleDestinations = new List<Point>(3);\r
+            possibleDestinations.Add(MovementManager.GetNeighbor(mMotion.Coordinates, moveLeft, moveRight, moveUp, moveDown));\r
+            possibleDestinations.AddRange(MovementManager.GetNeighbors(mMotion.Coordinates, possibleDestinations[0]));\r
+\r
+            Direction direction = Direction.None;\r
+            foreach (Point destination in possibleDestinations)\r
             {\r
                 if (game.IsCellOpen(destination))\r
                 {\r
-                    mMotion.Update(timeSpan, moveLeft, moveRight, moveUp, moveDown);\r
+                    direction = MovementManager.GetDirection(mMotion.Coordinates, destination);\r
+                    break;\r
                 }\r
-                else\r
-                {\r
-                    mMotion.Update(timeSpan);\r
-                }\r
-            }\r
-            else\r
-            {\r
-                mMotion.LockUpdate(timeSpan, moveLeft, moveRight, moveUp, moveDown);\r
             }\r
+\r
+            if (direction != Direction.None && !keysPressed.Contains(Keys.LeftControl)) mMotion.Update(timeSpan, direction);\r
+            else mMotion.LockUpdate(timeSpan, moveLeft, moveRight, moveUp, moveDown);\r
         }\r
-        public virtual void Attack(List<Keys> keysPressed)\r
-        {\r
-                \r
-        }\r
+        \r
         public void powerUp(int amount)\r
         {\r
             playerHealth += amount;\r
@@ -117,8 +114,29 @@ namespace CarFire
 \r
         public void Spawn(Vector2 spawn)\r
         {\r
-            \r
+\r
         }\r
+        public void AddHealth(int healthBoost)\r
+        {\r
+            Health += healthBoost;\r
+        }\r
+        public void IncreaseDamage(int damageBoost)\r
+        {\r
+            Damage += damageBoost;\r
+        }\r
+        #endregion\r
+\r
+        #region Abstract Methods\r
+        public abstract void PlayAttackSound();\r
+        public abstract void PlayDieSound();\r
+        public abstract void LoadContent(ContentManager contentManager);\r
+        /// <summary>\r
+        /// This method will draw a character to the screen.\r
+        /// </summary>\r
+        /// <param name="spriteBatch"></param>\r
+        public abstract void Draw(SpriteBatch spriteBatch);\r
+        public abstract void Attack(List<Keys> keysPressed);\r
+        #endregion\r
 \r
 \r
     }\r
This page took 0.023405 seconds and 4 git commands to generate.