+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
+\r
+namespace CarFire\r
+{\r
+ public class Player : ICharacter\r
+ {\r
+ #region Member variables\r
+ //The number of frames between each projectile is spawned.\r
+ const int shootCoolDown = 18;\r
+ String CharName;\r
+ Game game;\r
+ int playerHealth;\r
+ int playerDamage;\r
+ int score;\r
+ MovementManager mMotion;\r
+ int mPlayerIndex;\r
+ #endregion\r
+\r
+\r
+ public Player(Game theGame, String Name, Point position, int playerIndex, int health, int damage)\r
+ {\r
+ game = theGame;\r
+ CharName = Name;\r
+ score = 0;\r
+ playerHealth = health;\r
+ playerDamage = damage;\r
+ 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
+ }\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
+ }\r
+\r
+ public void Update(TimeSpan timeSpan)\r
+ {\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 UpdateInput(TimeSpan timeSpan, List<Keys> keysPressed)\r
+ {\r
+\r
+ UpdatePosition(timeSpan, keysPressed);\r
+ Attack(keysPressed);\r
+ \r
+ }\r
+ public void UpdatePosition(TimeSpan timeSpan, List<Keys> keysPressed)\r
+ {\r
+ bool moveLeft = keysPressed.Contains(Keys.Left);\r
+ 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
+ if (game.IsCellOpen(destination))\r
+ {\r
+ mMotion.Update(timeSpan, moveLeft, moveRight, moveUp, moveDown);\r
+ }\r
+ else\r
+ {\r
+ mMotion.Update(timeSpan);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ mMotion.LockUpdate(timeSpan, moveLeft, moveRight, moveUp, moveDown);\r
+ }\r
+ }\r
+ public virtual void Attack(List<Keys> keysPressed)\r
+ {\r
+ \r
+ }\r
+ public void powerUp(int amount)\r
+ {\r
+ playerHealth += amount;\r
+ }\r
+\r
+ public void Spawn(Vector2 spawn)\r
+ {\r
+ \r
+ }\r
+\r
+\r
+ }\r
+ \r
+}\r