{\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
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
/// <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