\r
namespace CarFire\r
{\r
- public class Human : IPlayer\r
+ public class Ranged : IPlayer\r
{\r
//The number of frames between each projectile is spawned.\r
const int shootCoolDown = 18;\r
int mPlayerIndex;\r
\r
\r
- public Human(Game theGame, String Name, Point position, int playerIndex)\r
+ public Ranged(Game theGame, String Name, Point position, int playerIndex)\r
{\r
game = theGame;\r
CharName = Name;\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(TimeSpan timeSpan, List<Keys> keysPressed)\r
+ public void UpdateInput(TimeSpan timeSpan, List<Keys> keysPressed)\r
+ {\r
+\r
+ UpdatePosition(timeSpan, keysPressed);\r
+\r
+ if (projectileCoolDown > 0)\r
+ projectileCoolDown--;\r
+ else if (projectileCoolDown == 0)\r
+ {\r
+ if (keysPressed.Contains<Keys>(Keys.Space))\r
+ {\r
+ Attack();\r
+ }\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
{\r
mMotion.LockUpdate(timeSpan, moveLeft, moveRight, moveUp, moveDown);\r
}\r
-\r
-\r
- if (projectileCoolDown > 0)\r
- projectileCoolDown--;\r
- else if (projectileCoolDown == 0)\r
- {\r
- if (keysPressed.Contains<Keys>(Keys.Space))\r
- {\r
- float velocityX = 0;\r
+ }\r
+ public void Attack()\r
+ {\r
+ float velocityX = 0;\r
float velocityY = 0;\r
int startX = Coordinates.X;\r
int startY = Coordinates.Y;\r
toShoot *= projectileSpeed;\r
projectileCoolDown = shootCoolDown;\r
game.State.mDisplay.AddProjectiles(new Projectile(game, projectileModel,\r
- toShoot, new Point(startX, startY), mPlayerIndex));\r
-\r
- \r
- }\r
- }\r
+ toShoot, new Point(startX, startY), mPlayerIndex, damage));\r
+ \r
}\r
-\r
-\r
public void powerUp(int amount)\r
{\r
health += amount;\r